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
6cbca4db
Commit
6cbca4db
authored
Jan 30, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last few tests for the night
parent
82be084e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
26 deletions
+40
-26
noahapp_configuration_spec.rb
spec/noahapp_configuration_spec.rb
+4
-14
noahapp_host_spec.rb
spec/noahapp_host_spec.rb
+2
-10
noahapp_service_spec.rb
spec/noahapp_service_spec.rb
+25
-2
spec_helper.rb
spec/spec_helper.rb
+9
-0
No files found.
spec/noahapp_configuration_spec.rb
View file @
6cbca4db
...
...
@@ -39,15 +39,11 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
end
it
"invalid application should not work"
do
get
'/c/badapp'
last_response
.
should_not
be_ok
last_response
.
status
.
should
==
404
response
=
last_response
.
should
return_json
last_response
.
should
be_missing
end
it
"invalid configuration for application should not work"
do
get
'/c/badapp/badconfig'
last_response
.
should_not
be_ok
last_response
.
status
.
should
==
404
response
=
last_response
.
should
return_json
last_response
.
should
be_missing
end
end
...
...
@@ -78,18 +74,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
it
"new configuration with missing format should not work"
do
config_data
=
{
:body
=>
"a string"
}.
to_json
put
'/c/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Missing Parameters"
last_response
.
should
be_invalid
end
it
"new configuration with missing body should not work"
do
config_data
=
{
:body
=>
"a string"
}.
to_json
put
'/c/newnewapp/someconfig'
,
config_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Missing Parameters"
last_response
.
should
be_invalid
end
end
...
...
spec/noahapp_host_spec.rb
View file @
6cbca4db
...
...
@@ -66,21 +66,13 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
it
"host missing name parameter should not work"
do
host_data
=
{
:status
=>
"pending"
}.
to_json
put
'/h/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Missing Parameters"
last_response
.
should
be_invalid
end
it
"host missing status parameter should not work"
do
host_data
=
{
:name
=>
"host100.domain.com"
}.
to_json
put
'/h/host100.domain.com'
,
host_data
,
"CONTENT_TYPE"
=>
"application/json"
last_response
.
should_not
be_ok
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Missing Parameters"
last_response
.
should
be_invalid
end
it
"host with invalid status parameter should not work"
do
...
...
spec/noahapp_service_spec.rb
View file @
6cbca4db
...
...
@@ -7,6 +7,10 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
it
"all services should work"
it
"all named services should work"
it
"named service for host should work"
it
"missing service for host should not work"
do
get
'/s/foobar/baz'
last_response
.
should
be_missing
end
end
describe
"PUT"
do
...
...
@@ -19,8 +23,27 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
end
describe
"DELETE"
do
it
"existing host should work"
it
"invalid host should not work"
before
(
:all
)
do
@h
=
Host
.
create
(
:name
=>
"h1"
,
:status
=>
"up"
)
@h
.
services
<<
Service
.
create
(
:name
=>
"s1"
,
:status
=>
"up"
,
:host
=>
@h
)
@h
.
save
@s
=
@h
.
services
.
first
end
it
"existing host should work"
do
delete
"/s/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
"result"
].
should
==
"success"
response
[
"action"
].
should
==
"delete"
response
[
"id"
].
should
==
@s
.
id
response
[
"host"
].
should
==
@h
.
name
response
[
"service"
].
should
==
@s
.
name
end
it
"invalid host should not work"
do
delete
"/s/
#{
@s
.
name
}
/
#{
@h
.
name
}
"
last_response
.
should
be_missing
end
end
end
...
...
spec/spec_helper.rb
View file @
6cbca4db
...
...
@@ -92,4 +92,13 @@ RSpec::Matchers.define :be_missing do
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Resource not found"
end
end
RSpec
::
Matchers
.
define
:be_invalid
do
match
do
|
last_response
|
last_response
.
headers
[
"Content-Type"
].
should
==
"application/json"
response
=
JSON
.
parse
(
last_response
.
body
)
response
[
"result"
].
should
==
"failure"
response
[
"error_message"
].
should
==
"Missing Parameters"
end
end
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