diff --git a/spec/noahapp_spec.rb b/spec/noahapp_spec.rb index a5a3a3a..10f00e0 100644 --- a/spec/noahapp_spec.rb +++ b/spec/noahapp_spec.rb @@ -2,12 +2,23 @@ describe "Noah App Basics", :reset_redis => true do - it "should show the index page" do + it "should show the index page as html" do + header "Accept", "text/html" get '/' last_response.should be_ok last_response.body.include?("Noah Start Page").should == true end + it "should show the index page as json" do + header "Accept", "application/json" + get '/' + last_response.should return_json + response = JSON.parse(last_response.body) + response.has_key?("redis_version").should == true + response.has_key?("noah_version").should == true + response.has_key?("resources").should == true + end + it "should test the 404 message" do get '/foo' last_response.status.should == 404 diff --git a/views/index.json.erb b/views/index.json.erb index 67c568d..06749d9 100644 --- a/views/index.json.erb +++ b/views/index.json.erb @@ -1,10 +1,10 @@ { - "redis_verion":"<%= locals[:redis_version] %>", + "redis_version":"<%= locals[:redis_version] %>", "noah_version":"<%= locals[:noah_version] %>", "resources":{ - "hosts":{"link":"<%= request.url %>hosts"} - "services":{"link":"<%= request.url %>services"} - "applications":{"link":"<%= request.url %>applications"} + "hosts":{"link":"<%= request.url %>hosts"}, + "services":{"link":"<%= request.url %>services"}, + "applications":{"link":"<%= request.url %>applications"}, "configurations":{"link":"<%= request.url %>configurations"} } }