Skip to content

Instantly share code, notes, and snippets.

@kaznum
Created September 27, 2011 01:52
Show Gist options
  • Save kaznum/1244104 to your computer and use it in GitHub Desktop.
Save kaznum/1244104 to your computer and use it in GitHub Desktop.
Is there more beautiful expression of lazy evaluation for expect{} and DRY?
# FIXME
# Is there more beautiful expression of lazy evaluation for expect{} and DRY?
#
describe ItemsController do
describe "POST 'create'" do
before do
@action = lambda { post :create, :name => 'foo' }
end
describe "response" do
before do
@action.call
end
subject {response}
it { should redirect_to items_url }
end
describe "the change of the number of items" do
specify {
expect { @action.call }.to change(Item.count).by(1) }
}
end
end
end
@kaznum
Copy link
Author

kaznum commented Sep 27, 2011

:item => { :name => 'foo' }が良い、というのはナシの方向で(笑)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment