Skip to content

Instantly share code, notes, and snippets.

@sumitasok
Created April 24, 2012 07:18
Show Gist options
  • Save sumitasok/2477399 to your computer and use it in GitHub Desktop.
Save sumitasok/2477399 to your computer and use it in GitHub Desktop.
Rspec Usage (Lambda, Expect)
# 1 - Lambda
lambda {
post :create, :document => FactoryGirl.attributes_for(:document)
}.should change { Document.count }.by(1)
# 2 - Expect
expect {
post :create, :document => FactoryGirl.attributes_for(:document)
}.should change { Document.count }.by(1)
# 3 - In latest RSpec
expect {
post :create, :document => FactoryGirl.attributes_for(:document)
}.to change(Document, :count).by(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment