[rspec-users] RSpec and simply_helpful

David Goodlad dgoodlad at gmail.com
Wed Dec 13 01:30:43 EST 2006


Hi All

I'm having some problems running my view specs when using
simply_helpful.  I have it semi-working via the following:

module SimplyHelpfulHelper
  def self.included(base)
    base.send :include, SimplyHelpful::RecordIdentificationHelper
    base.send :include, SimplyHelpful::RecordTagHelper
  end
end

context "The index template" do
  setup do
    @shift = mock("shift")
    @shift.stub!(:class).and_return(Shift)
    @shift.stub!(:id).and_return(1)

    assigns[:shifts] = [@shift]
  end

  specify "should have a div tag for the shift" do
    render 'shifts/index', :helper => 'simply_helpful'
    response.should_have_tag 'div', :attributes => { :id => 'shift_1' }
  end
end

My template just makes a call like this:

<%= render :partial => @shifts %>

I've done some experimentation, and it seems that RSpec's
implementation of 'render_partial' is rewriting the partial path
trying to be smart about it but breaking things.  The partial_path,
once it reaches render_partial_with_record_identification, ends up
being "/shifts//#<Spec::Mocks::Mock:0x28450cc>".  This is caused by
the method being overwritten in
rspec_on_rails/lib/extensions/action_view/base.rb.

I suggest that there be a second condition attached to the unless
statement on line 5, to ensure that the partial_path is a String; if
it is not, the partial_path should be passed straight on through...

Thoughts?

Dave

-- 
Dave Goodlad
dgoodlad at gmail.com or dave at goodlad.ca
http://david.goodlad.ca/


More information about the rspec-users mailing list