Hi,

On Wed, Apr 20, 2011 at 05:32, planon <spockspla...@gmail.com> wrote:
> I'm running into this error while trying to run a unit test on a
> Mongoid database:
>
>  def show
>    id=params[:id]
>    @user=User.find(:first,id)
>  end
>
> My test
>
>  before(:each) do
>    @user = Fabricate(:user)
>    sign_in @user
>  end
>  ...
>  it "should be successful" do
>    get "show", :id => @user
>    response.should be_success
>  end
>
> And the error message
>
>  1) UsersController GET 'show' for the logged in user should be
> successful
>     Failure/Error: get "show", :id => @user
>     TypeError:
>       can't convert Symbol into Integer
>     # ./app/controllers/users_controller.rb:6:in `show'
>     # ./spec/controllers/users_controller_spec.rb:31:in `block (4
> levels) in <top (required)>'

Try adding to_param in your spec:

  get "show", :id => @user.to_param

What's happening is the "show" action receives the entire user object
in params[:id] instead of just an id.

Mike
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to