I'm migrating over to shoulda from rspec and I can't seem to get access to the http response. Can someone point out what I may be doing wrong?
context "doing somethin" do
setup do
get :index
end
开发者_如何学Python@response.body
should respond_with :success
end
When i run this i get an error saying that @response is a nill object.
If you want to access the response you should first wrap into a "should" like this:
context "doing somethin" do
setup do
get :index
end
should "i access..." do
assert response.status, 200
end
end
It's like you try to use the response outside a test, each should represents a test case, and a context is like a before(:each) in rspec.
I believe the shoulda syntax is:
should_respond_with :success
instead of:
should respond_with :success
精彩评论