[rspec-users] Mock "Consent_6335" received unexpected message :marked_for_destruction? with (no args)

thoen thoen at edgevaleinteractive.com
Wed Mar 24 14:49:24 EDT 2010


Instead of

def  @target.marked_for_destruction?
    false
end

i added marked_for_destruction in the list of stubs included in
mock_model

        options_and_stubs = options_and_stubs.reverse_merge({
          :id => id,
          :to_param => id.to_s,
          :new_record? => false,
          :destroyed? => false,
          :marked_for_destruction? => false,
          :errors => stub("errors", :count => 0)
        })

This seemed like a better place.


On Mar 24, 2:39 pm, thoen <th... at edgevaleinteractive.com> wrote:
> I have a mock object (Person) that is associated with another object
> (my_object) through a belongs_to association. When I check whether
> my_object is valid (my_object.should be_valid), I am getting an error
> like the following:
>
> Mock "Person_6338" received unexpected
> message :marked_for_destruction? with (no args)
>
> Checking the list of methods on the mock, "marked_for_destruction?" is
> not listed. Is this this something that i should expect to always
> stub?
>
> As a check, I added
>
>           def  @target.marked_for_destruction?
>             false
>           end
>
> to the mock_model definition and the test passed.
>
> Rails 2.3.5
> rspec (1.3.0, 1.2.6, 1.1.3)
> rspec-rails (1.3.2, 1.2.6)
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list