joakim...@gmail.com
unread,Mar 4, 2009, 8:30:49 AM3/4/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to resource_controller
Hi,
I just upgraded to rspec 1.1.12 and started to get this error in my
controller specs when 'render :action' is used.
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/
text_helper.rb:42:in `concat'
...
This happens both when I customize the new and update controller
method with wants.html and when it's just the standard generated
controller method for new and update.
My controller specs look like this:
describe "handling PUT /db_instances/1" do
before(:each) do
@db_instance = mock_model(DbInstance, :to_param => "1")
DbInstance.stub!(:find).and_return(@db_instance)
end
describe "with successful update" do
def do_put
@db_instance.should_receive(:update_attributes).and_return
(true)
put :update, :id => "1"
end
it "should find the db_instance requested" do
DbInstance.should_receive(:find).with("1").and_return
(@db_instance)
do_put
end
it "should update the found db_instance" do
do_put
assigns(:db_instance).should equal(@db_instance)
end
it "should assign the found db_instance for the view" do
do_put
assigns(:db_instance).should equal(@db_instance)
end
it "should redirect to the db_instance" do
do_put
response.should redirect_to(db_instance_url("1"))
end
end
describe "with failed update" do
def do_put
@db_instance.should_receive(:update_attributes).and_return
(false)
put :update, :id => "1"
end
it "should re-render 'edit'" do
do_put
response.should render_template('edit')
end
end
end
Is this a known bug or am I doing something wrong in my spec or
controller?
/Joakim