# Rspec controller test -- ERROR

**URL:** <https://www.ruby-forum.com/t/rspec-controller-test-error/146198>\
**Category:** Rails\
**Created:** [August 19, 2008, 12:49am UTC](https://www.ruby-forum.com/t/rspec-controller-test-error/146198 "2008-08-19T00:49:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcernelli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@jcernelli](https://www.ruby-forum.com/u/jcernelli)\
**Post date:** [August 19, 2008, 12:49am UTC](https://www.ruby-forum.com/t/rspec-controller-test-error/146198/1 "2008-08-19T00:49:23Z")

</div>

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.
