TypeError: can't convert RSpec::Mocks::Mock to Hash

In MoneyOrdersController controller:

def create
@money_order = current_user.money_orders.build(params[:money_order])
if @money_order.save
flash.now[:msg_ok] = “Added money order for:
#{number_to_currency(@money_order.amount)}”
end
respond_with(@money_order)
end

In MoneyOrdersController spec:

describe “POST create” do
describe “with valid params” do
it “assigns a newly created money_order as @money_order” do
MoneyOrder.stub(:new).with({‘these’ => ‘params’})
{ mock_money_order(:save => true) }
post :create, :money_order => {‘these’ => ‘params’}
assigns(:money_order).should be(mock_money_order)
end
end

It always throws this error:

Failure/Error: post :create, :money_order => {‘these’ => ‘params’}
TypeError:
can’t convert RSpec::Mocks::Mock to Hash
(RSpec::Mocks::Mock#to_hash gives RSpec::Mocks::Mock)

I’m sure the reason is simple, why I am getting this TypeError?

On Feb 15, 10:25am, Karl [email protected] wrote:

end
rspec-users mailing list
[email protected]://rubyforge.org/mailman/listinfo/rspec-users

Hmmm…what is the “mock_money_order” method doing? Care to paste it?

What’s orm you are using? activerecord?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs