On 7/6/07, Marcus Crafter <crafterm at gmail.com>
wrote:> Hi All,
>
> Anyone noticed that using the newer link_to syntax in edge currently
> fails with mocked objects in view specs or helpers.
>
> eg. if you have something like the following in your view (or
> equivalent in a helper):
>
> <%= link_to @dog.name, @dog %>
>
> as opposed to the current 1.2 syntax:
>
> <%= link_to @dog.name, dog_path(@dog) %>
>
> Using a mock_model as the ''dog'' will raise a:
>
> undefined method `polymorphic_path'' for [Dynamically
generated class
> for RSpec example]:#<Class:0x26814f4>
>
> error - I presume due to the introspection on the @dog object to find
> out what kind of class it is to create it''s URL.
>
> Anyone worked around this at all, other than using the older syntax?
> Any ideas appreciated.
All mock_model does is that it wraps mock, adding some method stubs.
So you can do this:
thing = mock_model(Thing)
thing.polymorphic_path = ''whatever''
...
Also - please report this sort of thing to rspec''s tracker:
http://rubyforge.org/tracker/?group_id=797
>
> Cheers,
>
> Marcus
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>