Commit 80a2b3f9 authored by John E. Vincent's avatar John E. Vincent

fixing tests for sinatra 1.3

parent 32f7ff12
......@@ -65,8 +65,8 @@ describe "Using the Configuration Model", :reset_redis => true do
c = Noah::Configurations.all
c.class.to_s.should == 'Hash'
c.size.should == 2
c.has_key?(a.name).should == true
c.has_key?(b.name).should == true
c.has_key?(a.name.to_s).should == true
c.has_key?(b.name.to_s).should == true
end
it "return all Configurations in short form" do
......@@ -75,8 +75,8 @@ describe "Using the Configuration Model", :reset_redis => true do
c = Noah::Configurations.all({},true)
c.class.to_s.should == 'Hash'
c.size.should == 2
c.has_key?(a.name).should == true
c.has_key?(b.name).should == true
c.has_key?(a.name.to_s).should == true
c.has_key?(b.name.to_s).should == true
c.each {|k,v| v.keys.map {|k| k.to_s}.sort.should == ['created_at','format','updated_at']}
end
end
......
......@@ -58,16 +58,16 @@ describe "Using the Link Model", :reset_redis => true do
h[:name].should == l.name
h[:updated_at].should == l.updated_at
h[:created_at].should == l.created_at
h[:hosts].has_key?(@host.name).should == true
h[:hosts][@host.name].keys.map {|k| k.to_s}.sort.should == [:id, :status, :tags, :services].map {|k| k.to_s}.sort
h[:services].has_key?(@service.name).should == true
h[:services][@service.name][@host.name].keys.map {|k| k.to_s}.sort.should == [:id, :status, :tags].map {|k| k.to_s}.sort
h[:applications].has_key?(@application.name).should == true
h[:applications][@application.name].keys.map {|k| k.to_s}.sort.should == [:id, :tags, :configurations].map {|k| k.to_s}.sort
h[:configurations].has_key?(@configuration.name).should == true
h[:configurations][@configuration.name].keys.map {|k| k.to_s }.sort.should == [:id, :tags, :format, :body].map {|k| k.to_s}.sort
h[:ephemerals].has_key?(@ephemeral.name).should == true
h[:ephemerals][@ephemeral.name].keys.map {|k| k.to_s}.sort.should == [:id, :tags, :path, :data].map {|k| k.to_s}.sort
h[:hosts].has_key?(@host.name.to_s).should == true
h[:hosts]["#{@host.name}"].keys.map {|k| k.to_s}.sort.should == [:id, :status, :tags, :services].map {|k| k.to_s}.sort
h[:services].has_key?(@service.name.to_s).should == true
h[:services]["#{@service.name}"]["#{@host.name}"].keys.map {|k| k.to_s}.sort.should == [:id, :status, :tags].map {|k| k.to_s}.sort
h[:applications].has_key?(@application.name.to_s).should == true
h[:applications]["#{@application.name}"].keys.map {|k| k.to_s}.sort.should == [:id, :tags, :configurations].map {|k| k.to_s}.sort
h[:configurations].has_key?(@configuration.name.to_s).should == true
h[:configurations]["#{@configuration.name}"].keys.map {|k| k.to_s }.sort.should == [:id, :tags, :format, :body].map {|k| k.to_s}.sort
h[:ephemerals].has_key?(@ephemeral.name.to_s).should == true
h[:ephemerals]["#{@ephemeral.name}"].keys.map {|k| k.to_s}.sort.should == [:id, :tags, :path, :data].map {|k| k.to_s}.sort
end
end
......
......@@ -27,7 +27,7 @@ describe "Using the Application API", :reset_redis => false do
response["name"].should == @a.name
response.has_key?("configurations").should == true
c = response["configurations"]
c.has_key?(@c.name).should == true
c.has_key?(@c.name.to_s).should == true
c["#{@c.name}"]["format"].should == "#{@c.format}"
c["#{@c.name}"]["body"].should == "#{@c.body}"
end
......
......@@ -22,13 +22,13 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
get "/services/#{@sample_service[:name]}"
last_response.should be_ok
response = last_response.should return_json
response.is_a?(Hash).should == true
response.has_key?(@s.name).should == true
response[@s.name].is_a?(Hash).should == true
response[@s.name].has_key?(@h.name).should == true
response[@s.name][@h.name].is_a?(Hash).should == true
response[@s.name][@h.name]["id"].should == @s.id
response[@s.name][@h.name]["status"].should == @s.status
response.class.to_s.should == "Hash"
response.has_key?(@s.name.to_s).should == true
response["#{@s.name}"].class.to_s.should == "Hash"
response["#{@s.name}"].has_key?(@h.name.to_s).should == true
response["#{@s.name}"]["#{@h.name}"].class.to_s.should == "Hash"
response["#{@s.name}"]["#{@h.name}"]["id"].should == @s.id
response["#{@s.name}"]["#{@h.name}"]["status"].should == @s.status
end
it "named service for host should work" do
get "/services/#{@sample_service[:name]}/#{@sample_host[:name]}"
......
......@@ -11,7 +11,7 @@ describe "Noah App Basics", :reset_redis => true do
it "should test the 404 message" do
get '/foo'
last_response.status.should == 404
last_response.headers["Content-Type"].should == "application/json"
last_response.should return_json
response = JSON.parse(last_response.body)
response["result"].should == "failure"
response["error_message"].should == "Resource not found"
......
......@@ -72,7 +72,7 @@ end
RSpec::Matchers.define :return_json do
match do |last_response|
last_response.headers["Content-Type"].should == "application/json"
last_response.headers["Content-Type"].should =~ /^application\/json;.*/
response = JSON.parse(last_response.body)
end
......@@ -83,7 +83,7 @@ end
RSpec::Matchers.define :be_missing do
match do |last_response|
last_response.headers["Content-Type"].should == "application/json"
last_response.headers["Content-Type"].should =~ /^application\/json;.*/
last_response.status.should == 404
response = JSON.parse(last_response.body)
response["result"].should == "failure"
......@@ -93,7 +93,7 @@ end
RSpec::Matchers.define :be_invalid do
match do |last_response|
last_response.headers["Content-Type"].should == "application/json"
last_response.headers["Content-Type"].should =~ /^application\/json;.*/
response = JSON.parse(last_response.body)
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment