Topic: Order of paramaters on RSpec mock expectation

Hi all,

I'm having a little trouble with RSpec, probably doing somehing very silly... I'd appreciate it if someone could point me in the right direction.

This is a simplified version of my RSpec Controller example (I just took out a load of paramaters)

  it "should allow the user to create a new Loan by supplying the relevant details" do
    params = {:title => "The Three Musketeers", :due => ( + 30 ), :user_id => 1}

    post :create, :loan => params
    response.should redirect_to(:action =>:list)

My controller does this:

      loan =[:loan])
      redirect_to :action => :list

but when I run this the expectation fails ->

Mock 'Class' expected :new with
({:user_id=>1, :expires=>Fri, 25 Jan 2008, :title=>"The Three Musketeers"})

but received it with
({"title"=>"The Three Musketeers", "expires"=>Fri, 25 Jan 2008, "user_id"=>1})

It's the order of the paramaters that's wrong... am I doing something wacko here, because no one else seems to have complained about this (or so google tells me), so is my testing approach just stupid?

thoughts appreciated,

thanks a lot,

Re: Order of paramaters on RSpec mock expectation

You're sending in :title, when you should be sending in "title". Strings and symbols as keys for hashes are two different things. Send it as strings and you should be fine.

:title is not the same as "title"

Re: Order of paramaters on RSpec mock expectation


Thanks for the reply, I really appreciate it.  Problem solved!