Commit f899b568 authored by John E. Vincent's avatar John E. Vincent

specs for configurations short form

parent 0a2d3d72
......@@ -68,6 +68,17 @@ describe "Using the Configuration Model", :reset_redis => true do
c.has_key?(a.name).should == true
c.has_key?(b.name).should == true
end
it "return all Configurations in short form" do
a = Noah::Configuration.find_or_create(@appconf_string)
b = Noah::Configuration.find_or_create(@appconf_json)
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.each {|k,v| v.keys.map {|k| k.to_s}.sort.should == ['created_at','format','updated_at']}
end
end
describe "should not" do
......
......@@ -41,7 +41,34 @@ describe "Using the Configuration API", :reset_redis => true, :populate_sample_d
end
end
end
it "all configurations in short form"
it "all configurations in short form with no trailing slash" do
get '/configurations?short=true'
last_response.should be_ok
response = last_response.should return_json
response.keys.size.should == 3
%w[redis_url json_config yaml_config].each do |c|
response.keys.member?(c).should == true
%w[format location created_at updated_at].each do |ck|
response[c].keys.member?(ck).should == true
end
end
response.each {|k,v| v['location'].should =~ /^http:\/\/.*\/configurations\/#{k}/}
end
it "all configurations in short form with trailing slash" do
get '/configurations/?short=true'
last_response.should be_ok
response = last_response.should return_json
response.keys.size.should == 3
%w[redis_url json_config yaml_config].each do |c|
response.keys.member?(c).should == true
%w[format location created_at updated_at].each do |ck|
response[c].keys.member?(ck).should == true
end
end
response.each {|k,v| v['location'].should =~ /^http:\/\/.*\/configurations\/#{k}/}
end
it "named configuration should work as JSON" do
header "Accept", "application/json"
......
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