Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
42f35f04
Commit
42f35f04
authored
Jan 25, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rack::Test tests started
parent
a94b187f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
8 deletions
+30
-8
noah.rb
noah.rb
+1
-0
noahapp_spec.rb
spec/noahapp_spec.rb
+20
-0
spec_helper.rb
spec/spec_helper.rb
+7
-0
404.erb
views/404.erb
+1
-4
500.erb
views/500.erb
+1
-4
No files found.
noah.rb
View file @
42f35f04
...
...
@@ -44,6 +44,7 @@ class NoahApp < Sinatra::Base
end
not_found
do
content_type
"application/json"
erb
:'404'
end
...
...
spec/noahapp_spec.rb
0 → 100644
View file @
42f35f04
require
File
.
expand_path
(
File
.
dirname
(
__FILE__
)
+
'/spec_helper'
)
describe
"Noah App Basics"
,
:reset_redis
=>
true
do
it
"should show the index page"
do
get
'/'
last_response
.
should
be_ok
last_response
.
body
.
include?
(
"Noah Start Page"
).
should
==
true
end
it
"should test the 404 message"
do
get
'/foo'
last_response
.
status
.
should
==
404
last_response
.
headers
[
"Content-Type"
].
should
==
"application/json"
response
=
JSON
.
parse
(
last_response
.
body
)
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Resource not found"
end
end
spec/spec_helper.rb
View file @
42f35f04
...
...
@@ -7,8 +7,15 @@ rescue LoadError
end
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'config'
,
'db'
)
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'lib'
,
'models'
)
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'noah'
)
require
'rspec'
require
'rack/test'
RSpec
.
configure
do
|
config
|
config
.
before
(
:each
,
:reset_redis
=>
true
)
{
Ohm
::
redis
.
flushdb
}
config
.
include
Rack
::
Test
::
Methods
end
def
app
NoahApp
end
views/404.erb
View file @
42f35f04
{
"result":"failure",
"error_message":"Resource not found"
}
{"result":"failure","error_message":"Resource not found"}
views/500.erb
View file @
42f35f04
{
"result":"failure",
"error_message":"
<%=
request
.
env
[
'sinatra.error'
].
message
%>
"
}
{"result":"failure","error_message":"
<%=
request
.
env
[
'sinatra.error'
].
message
%>
"}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment