Skip to content

Instantly share code, notes, and snippets.

@nickboyce
Created April 10, 2012 09:30
Show Gist options
  • Save nickboyce/2349801 to your computer and use it in GitHub Desktop.
Save nickboyce/2349801 to your computer and use it in GitHub Desktop.
context "#index (GET /artworks.json)" do
# create 30 Artwork documents using FactoryGirl, and do a HTTP GET request on "/artworks.json"
before(:each) do
30.times { FactoryGirl.create(:artwork) }
get "/artworks.json"
end
describe "should list all artworks" do
# the request returns a variable called "response", which we can then make sure comes back as expected
it { response.should be_ok }
it { JSON.parse(response.body)["results"].should be_a_kind_of(Array) }
it { JSON.parse(response.body)["results"].length.should eq 30 }
# etc...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment