[rspec-devel] [ rspec-Bugs-12404 ] Edge Rails breaks RSpec with newer link_to syntax

noreply at rubyforge.org noreply at rubyforge.org
Sun Jul 22 19:57:44 EDT 2007

Bugs item #12404, was opened at 2007-07-19 17:03
You can respond by visiting: 

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Marcus Crafter (crafterm)
Assigned to: Nobody (None)
Summary: Edge Rails breaks RSpec with newer link_to syntax

Initial Comment:
Hi All,

Hope all is going well.

In Edge Rails you can specify link to using:

link_to('path, @model)

as opposed to:

link_to('path', model_path(@model))

in 1.2 and earlier.

The newer syntax breaks rspec though if you have any helpers or view specs that test code that uses it with mock models. The error it prints is:

undefined method `polymorphic_path' for [Dynamically generated class
for RSpec example]:#<Class:0x26814f4>

Example to reproduce:

describe ApplicationHelper do
  it "should demo edge link_to problem" do
    mock = mock_model(User, :name => test)
    link_to(mock.name, mock).should == '<a href="/users/1000">test</a>'

I've been able to fix this with the following monkey patch:

module Spec
  module Rails
    module DSL
      class EvalContext < Spec::Rails::TestCase
        def polymorphic_path(uri)

However there may be a more appropriate solution? Would be great to get this fixed, please let me know if there's anything else I can do.




>Comment By: Marcus Crafter (crafterm)
Date: 2007-07-23 09:57

Hi David,

My apologies, I've attached a tar.bz2 archive that includes
a working example of the issue.

Please extract the polymorphic-path-example.tar.bz2, and run
the notes_helper_spec.rb spec, or simply run rake spec after
creating the test database, and you'll see the error.

I haven't included rails, or rspec with this example, in the
vendor directory, I've symlinked rails to the latest trunk
(rev 7209), and in the plugins directory rspec/rpec_on_rails
(rev 2181).

The notes_helper_spec.rb includes the fix I wrote but I'm
unsure if this is the correct solution. I'm happy to write a
patch for this for rspec itself if you're happy with it.




Comment By: David Chelimsky (dchelimsky)
Date: 2007-07-23 06:03

I'm not able to reproduce this error using the example you've provided. Please submit an example that we can get to fail running rspec's own examples. See http://rspec.rubyforge.org/community/contribute.html for more information.



You can respond by visiting: 

More information about the rspec-devel mailing list