[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:53:16 EDT 2007


Bugs item #12404, was opened at 2007-07-19 17:03
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12404&group_id=797

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>'
  end
end

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)
          "/#{uri.class.to_s.underscore.pluralize}/#{uri.id}"
        end
      end
    end
  end
end

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.

Cheers,

Marcus


----------------------------------------------------------------------

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

Message:
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.

Thanks

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12404&group_id=797


More information about the rspec-devel mailing list