[rspec-users] MockExpectationError

Song Lee lists at ruby-forum.com
Sat Dec 6 00:18:52 EST 2008


no matter how I try to stub! it still showing this error

I have the following in my spec
    Profile.stub!(:new).and_return(@profile = mock_model(Profile))

Then

(rdb:1) @profile.stub!(:user)
#<Spec::Mocks::MessageExpectation:0x9fa1c94 @at_most=nil, @sym=:user,
@expected_
from="D:/Songrit/_rails_apps/ului_new/app/controllers/registrations_controller.r
b:199:in `transaction'", @exception_to_raise=nil,
@actual_received_count=0, @at_
least=nil, @consecutive=false, @return_block=nil,
@order_group=#<Spec::Mocks::Or
derGroup:0xa1b060c @ordering=[],
@error_generator=#<Spec::Mocks::ErrorGenerator:
0xa1b0634 @opts={}, @target=#<Profile:0x50d841e @name="Profile_1300">,
@name="Pr
ofile_1300">>,
@args_expectation=#<Spec::Mocks::ArgumentExpectation:0x9fa0c04 @c
onstraints_block=nil,
@args=[#<Spec::Mocks::ArgumentConstraints::AnyArgsConstrai
nt:0x9fa0d1c>], @match_any_args=true>, @args_to_yield=[],
@method_block=nil, @sy
mbol_to_throw=nil, @expected_received_count=:any,
@error_generator=#<Spec::Mocks
::ErrorGenerator:0xa1b0634 @opts={}, @target=#<Profile:0x50d841e
@name="Profile_
1300">, @name="Profile_1300">>

(rdb:1) @profile.user = 3
Spec::Mocks::MockExpectationError Exception: Mock 'Profile_1300'
received unexpe
cted message :user= with (3)

..........
Try many variations of stub!, stub!..with, should_recieve, etc nothing
works
I'm using rspec and rspec-rails version 1.1.11
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list