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/
Specrs, Just a fly on the wall perspective here, but based on the behaviour I''m seeing, it seems like RSpec is reimplementing a lot of the Rails test goodies. Is there a reason not to write simple wrappers for Rails'' asserts, or something, so RSpec doesn''t have to work so hard to keep up with changes in core? I speak as someone who''s only glanced at the RSpec code, so maybe I should just keep it to myself. I do enjoy using RSpec with Ruby code, and I can''t wait for the day the Rails implementation is stable. Also, why not package the Rails plugin in the gem releases? It might help with the version mismatch problems. I know; I should PDI. If a core developer could do a walk through of RSpec internals, like Jamis has been doing with ActiveRecord, surely I''m not the only one who would appreciate it. Chris On 12/12/06, David Goodlad <dgoodlad at gmail.com> wrote:> 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. > > Thoughts? > > Dave >-- Chris Anderson http://jchris.mfdz.com
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. Thanks, David> > Dave > > -- > Dave Goodlad > dgoodlad at gmail.com or dave at goodlad.ca > http://david.goodlad.ca/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 12/13/06, Chris Anderson <jchris at mfdz.com> wrote:> Specrs, > Just a fly on the wall perspective here, but based on the behaviour > I''m seeing, it seems like RSpec is reimplementing a lot of the Rails > test goodies. Is there a reason not to write simple wrappers for > Rails'' asserts, or something, so RSpec doesn''t have to work so hard to > keep up with changes in core?Ah, that would be lovely! Many of the goodies use different approaches, so I''m not sure a single wrapper mechanism would work. What would be fantastic in the long run would be a world in which the various goodies were not tied so directly to test/unit, allowing either framework to use it. But that would require a critical mass of rails developers who prefer to work w/ rspec and I think that''s a LONG way off if even possible.> > I speak as someone who''s only glanced at the RSpec code, so maybe I > should just keep it to myself.Not at all. We want this to be usable and useful.> I do enjoy using RSpec with Ruby code, > and I can''t wait for the day the Rails implementation is stable.You are NOT alone!> Also, why not package the Rails plugin in the gem releases? It might > help with the version mismatch problems. I know; I should PDI.We''ve been talking about that. Originally it was a gem, but we made it a plugin sometime ago - I think it was when we added the generators. But the mismatch problem is a pain in the ass, so perhaps a gem is the right approach.> If a core developer could do a walk through of RSpec internals, like > Jamis has been doing with ActiveRecord, surely I''m not the only one > who would appreciate it.Are you talking about RSpec core or the rails plugin? I''m not sure when time will allow for this, but I''ll take it under advisement. It could provide a great opportunity for us all to better understand where things are now and the most pragmatic path to where we want to be. Thanks, David> > > Chris > > > On 12/12/06, David Goodlad <dgoodlad at gmail.com> wrote: > > 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. > > > > Thoughts? > > > > Dave > > > > -- > Chris Anderson > http://jchris.mfdz.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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/