[rspec-users] Mock_model not recognizing act_as_mappable
isignin at gmail.com
Fri Aug 3 13:33:07 UTC 2012
I am using mock_model in my tests, and I encountered a situation where my
stub is failing. Here's the scenario:
@locations = Location.al(:bounds=>bounds)l
@location = mock_model(Location)
Within real model: Location
the :sort_by_distance_from is a method from within act_as_mappable.
Upon investigation, when I compare the available methods for both the
Location model and the mock_model, I found act_as_mappable is missing from
Which accounts for why it was failing in the
stub @location.stub!(:sort_by_distance_from). It gives an error "unexpected
message :distance_to" and the :distance_to method comes from
When I switch to using Factory for the @location instance, the test passed.
How should I go about using the mock_model for a situation as this, without
resorting to using Factory? I believe this issue also the same for other
act_as_ situations because I also noted that a number of my act_as.. are
not available in the mock_model as they are in the actual model.
Thanks for the help
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users