[rspec-users] RSpec and simply_helpful

David Goodlad dgoodlad at gmail.com
Thu Dec 14 02:42:37 EST 2006


On 12/13/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 12/13/06, David Goodlad <dgoodlad at gmail.com> wrote:
> > 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 - it would be quite awesome if you would submit a patch for this w/ specs.

Hi David

I've submitted my patch:
https://rubyforge.org/tracker/index.php?func=detail&aid=7270&group_id=797&atid=3151

As I note in the patch description, I am not happy with the way I
ended up specifying the behavior.  However, it's a bit of a sticky
thing to test, since the actual rails code we pass the value on to
normally doesn't support an Array being passed as the partial_path!
So, I kludged it, by chaining my own method in front of Rails'
render_partial to allow the use of an Array.  This is ugly, I know.
If you can think of a better way, please post it here as I'd like to
know about it! :)

Dave

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


More information about the rspec-users mailing list