[rspec-users] Attempting to speed up my controller specs: using before all fails?
nathanvda
nathanvda at gmail.com
Tue Oct 11 07:05:38 EDT 2011
I have a simple controller test, containing a.o. the following code:
context "POST :create" do
before (:each) do
post :create, :user_id => @user.id,
:account => { .. some data ... }
end
it { response.status.should == 201 }
it { response.location.should be_present }
end
Now I thought of a very simple way to speed up this test, and to use a
`before(:all)` instead of a `before(:each)`. In that case the POST
would only be done once.
So i wrote:
context "POST :create" do
before (:all) do
post :create, :user_id => @user.id,
:account => { .. some data ... }
end
it { response.status.should == 201 }
it { response.location.should be_present }
end
But then I get the following errors:
RuntimeError:
@routes is nil: make sure you set it in your test's setup
method.
Is this by design? Is there a way to circumvent it?
More information about the rspec-users
mailing list