Testing REST-API responses with Rspec and Rack::Test
问题 I am a bit stumped. I have the following integration test: require "spec_helper" describe "/foods", :type => :api do include Rack::Test::Methods let(:current_user) { create_user! } let(:host) { "http://www.example.com" } before do login(current_user) @food = FactoryGirl.create_list(:food, 10, :user => current_user) end context "viewing all foods owned by user" do it "as JSON" do get "/foods", :format => :json foods_json = current_user.foods.to_json last_response.body.should eql(foods_json)