Hello,
I am trying to figure out how to pass the test for create controller
action:
def create
@artist = Artist.new(params[:artist])
if @artist.save
flash[:notice] = “#{@artist.name} dodany do bazy”
redirect_to list_artists_path
else
render :action => ‘new’
end
end
it "should redirect to artists/list after successful save" do
artist = mock('artist')
@artist = Artist.should_receive(:new).and_return(artist)
@artist.stub!(:save).and_return(true)
post :create
response.should redirect_to(list_artists_path)
end
rspec error:
Spec::Mocks::MockExpectationError in ‘ArtistsController CREATE should
redirect to artists/list after successful save’
Mock ‘artist’ received unexpected message :save with (no args)
/home/cfx/NetBeansProjects/purp/app/controllers/artists_controller.rb:19:in
`create’
./spec/controllers/artists_controller_spec.rb:48:
Finished in 0.197619 seconds
8 examples, 1 failure
oh I would like to add that I am completely newbie to rspec.