When I first learned about the View specs I was very excited. I still am. However, I haven''t found them useful yet for one reason. They throw the following exception when ever a view renders another view, which is very common. ActionView::TemplateError in ''Event View message'' No rhtml, rxml, rjs or delegate template found for spec/rails/ view_spec/_info I''d really like to be able to write view spec but this is holding me up. Has anyone else bumped into this wall? Is there something I''m missing? Micah -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061128/9905f168/attachment.html
On 11/28/06, Micah Martin <micah at 8thlight.com> wrote:> When I first learned about the View specs I was very excited. I still am. > However, I haven''t found them useful yet for one reason. They throw the > following exception when ever a view renders another view, which is very > common. > > ActionView::TemplateError in ''Event View message'' > No rhtml, rxml, rjs or delegate template found for > spec/rails/view_spec/_info > > I''d really like to be able to write view spec but this is holding me up. > Has anyone else bumped into this wall? Is there something I''m missing? > > Micah > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >Hey Micah, Check out http://rubyforge.org/tracker/index.php?func=detail&aid=6903&group_id=797&atid=3149 which is a bug report I filed for the same issue. Basically in the mean time, just do render :partial => "controller_name/partial_name" So like if the partial is named "person" and it''s under the "people" views dir, it''d be render :partial => "people/person" That''ll work until we get it fixed in the plugin. Pat
That did the trick. Thanks Pat. Micah Martin On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote:> > Basically in the mean time, just do > render :partial => "controller_name/partial_name" > > So like if the partial is named "person" and it''s under the "people" > views dir, it''d be > render :partial => "people/person" > > That''ll work until we get it fixed in the plugin.-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061128/ae3eb681/attachment.html
On 11/28/06, Micah Martin <micah at 8thlight.com> wrote:> That did the trick. Thanks Pat. > > > Micah Martin > > On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > > Basically in the mean time, just do > render :partial => "controller_name/partial_name" > > So like if the partial is named "person" and it''s under the "people" > views dir, it''d be > render :partial => "people/person" > > That''ll work until we get it fixed in the plugin.We got it fixed in the plugin. In trunk (rev 1174). Cheers, David> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >
Great to finally having view specs work with edge rails! To bad I can''t actually use them, since I use helper methods in my views. Has anybody gotten calls to helper methods to work in view tests under Rails 1.2 RC1? Currently I get "undefined method `crumbs'' for #<#<Class:0x340b70c>: 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs (@var) %>) Hope there''s a solution out there! Regards, Mathias On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote:> On 11/28/06, Micah Martin <micah at 8thlight.com> wrote: >> That did the trick. Thanks Pat. >> >> >> Micah Martin >> >> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: >> >> Basically in the mean time, just do >> render :partial => "controller_name/partial_name" >> >> So like if the partial is named "person" and it''s under the "people" >> views dir, it''d be >> render :partial => "people/person" >> >> That''ll work until we get it fixed in the plugin. > > We got it fixed in the plugin. In trunk (rev 1174). > > Cheers, > David > >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 11/29/06, Mathias Biilmann Christensen <info at mathias-biilmann.net> wrote:> Great to finally having view specs work with edge rails! > > To bad I can''t actually use them, since I use helper methods in my > views. Has anybody gotten calls to helper methods to work in view > tests under Rails 1.2 RC1? > > Currently I get "undefined method `crumbs'' for #<#<Class:0x340b70c>: > 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > (@var) %>) > > Hope there''s a solution out there!There IS!!!!! Incomplete though they are, the specs are the best source of documentation for questions like this. Take a look at vendor/plugins/rspec/spec/view_spec_spec. It has the answer to your question. I''ll give you the highlights, but check out the spec if you''re unsure of anything: context "/some/template" do setup do render ''/some/template'', :helper => :some_other #_helper will get appended end ... end OR, if you need more than one: context "/some/template" do setup do render ''/some/template'', :helpers => [:one, :another, :yet_another] end ... end Cheers, David> > Regards, > Mathias > > > On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > > > On 11/28/06, Micah Martin <micah at 8thlight.com> wrote: > >> That did the trick. Thanks Pat. > >> > >> > >> Micah Martin > >> > >> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >> > >> Basically in the mean time, just do > >> render :partial => "controller_name/partial_name" > >> > >> So like if the partial is named "person" and it''s under the "people" > >> views dir, it''d be > >> render :partial => "people/person" > >> > >> That''ll work until we get it fixed in the plugin. > > > > We got it fixed in the plugin. In trunk (rev 1174). > > > > Cheers, > > David > > > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Thanks a lot - that helped a great deal. I still seem to have problems with helper methods that are not defined in a helper module. In my Application controller I have a current_user method and then uses " helper_method :current_user" to be make it usable for my views. Any way to stub that method in a view test? (I suspect a way to do this would also solve Michael Johnston''s error_messages_for problem) Regards, Mathias On Nov 30, 2006, at 1:05 AM, David Chelimsky wrote:> On 11/29/06, Mathias Biilmann Christensen <info at mathias- > biilmann.net> wrote: >> Great to finally having view specs work with edge rails! >> >> To bad I can''t actually use them, since I use helper methods in my >> views. Has anybody gotten calls to helper methods to work in view >> tests under Rails 1.2 RC1? >> >> Currently I get "undefined method `crumbs'' for #<#<Class:0x340b70c>: >> 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs >> (@var) %>) >> >> Hope there''s a solution out there! > > There IS!!!!! Incomplete though they are, the specs are the best > source of documentation for questions like this. Take a look at > vendor/plugins/rspec/spec/view_spec_spec. It has the answer to your > question. I''ll give you the highlights, but check out the spec if > you''re unsure of anything: > > context "/some/template" do > setup do > render ''/some/template'', :helper => :some_other #_helper will > get appended > end > ... > end > > OR, if you need more than one: > > context "/some/template" do > setup do > render ''/some/template'', :helpers => > [:one, :another, :yet_another] > end > ... > end > > Cheers, > David > >> >> Regards, >> Mathias >> >> >> On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: >> >>> On 11/28/06, Micah Martin <micah at 8thlight.com> wrote: >>>> That did the trick. Thanks Pat. >>>> >>>> >>>> Micah Martin >>>> >>>> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: >>>> >>>> Basically in the mean time, just do >>>> render :partial => "controller_name/partial_name" >>>> >>>> So like if the partial is named "person" and it''s under the >>>> "people" >>>> views dir, it''d be >>>> render :partial => "people/person" >>>> >>>> That''ll work until we get it fixed in the plugin. >>> >>> We got it fixed in the plugin. In trunk (rev 1174). >>> >>> Cheers, >>> David >>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 11/30/06, Mathias Biilmann Christensen <info at mathias-biilmann.net> wrote:> Thanks a lot - that helped a great deal. > > I still seem to have problems with helper methods that are not > defined in a helper module. In my Application controller I have a > current_user method and then uses " helper_method :current_user" to > be make it usable for my views. Any way to stub that method in a > view test? (I suspect a way to do this would also solve Michael > Johnston''s error_messages_for problem)By design, view specs do not include any controllers in your application. The point is to minimize coupling w/ other parts of your application. We offer the helpers because they are really part of the view infrastructure. Would it be unreasonable to add methods that you want in both your controllers and views to a helper that you include in the controller? It''s backwards from what you''re doing, but it would solve the problem without sacrificing the good separation that we''ve achieved. David> > Regards, > Mathias > > > On Nov 30, 2006, at 1:05 AM, David Chelimsky wrote: > > > On 11/29/06, Mathias Biilmann Christensen <info at mathias- > > biilmann.net> wrote: > >> Great to finally having view specs work with edge rails! > >> > >> To bad I can''t actually use them, since I use helper methods in my > >> views. Has anybody gotten calls to helper methods to work in view > >> tests under Rails 1.2 RC1? > >> > >> Currently I get "undefined method `crumbs'' for #<#<Class:0x340b70c>: > >> 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > >> (@var) %>) > >> > >> Hope there''s a solution out there! > > > > There IS!!!!! Incomplete though they are, the specs are the best > > source of documentation for questions like this. Take a look at > > vendor/plugins/rspec/spec/view_spec_spec. It has the answer to your > > question. I''ll give you the highlights, but check out the spec if > > you''re unsure of anything: > > > > context "/some/template" do > > setup do > > render ''/some/template'', :helper => :some_other #_helper will > > get appended > > end > > ... > > end > > > > OR, if you need more than one: > > > > context "/some/template" do > > setup do > > render ''/some/template'', :helpers => > > [:one, :another, :yet_another] > > end > > ... > > end > > > > Cheers, > > David > > > >> > >> Regards, > >> Mathias > >> > >> > >> On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > >> > >>> On 11/28/06, Micah Martin <micah at 8thlight.com> wrote: > >>>> That did the trick. Thanks Pat. > >>>> > >>>> > >>>> Micah Martin > >>>> > >>>> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >>>> > >>>> Basically in the mean time, just do > >>>> render :partial => "controller_name/partial_name" > >>>> > >>>> So like if the partial is named "person" and it''s under the > >>>> "people" > >>>> views dir, it''d be > >>>> render :partial => "people/person" > >>>> > >>>> That''ll work until we get it fixed in the plugin. > >>> > >>> We got it fixed in the plugin. In trunk (rev 1174). > >>> > >>> Cheers, > >>> David > >>> > >>>> > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-users at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>>> > >>>> > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
OFF TOPIC: I couldn''t help but notice that the helper you''re using is "crumbs". Is this an implementation of breadcrumbs? I have been trying to think of some elegant ways to implement breadcrumbs in my app. Care to share a bit? On 11/29/06, Mathias Biilmann Christensen <info at mathias-biilmann.net> wrote:> Great to finally having view specs work with edge rails! > > To bad I can''t actually use them, since I use helper methods in my > views. Has anybody gotten calls to helper methods to work in view > tests under Rails 1.2 RC1? > > Currently I get "undefined method `crumbs'' for #<#<Class:0x340b70c>: > 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > (@var) %>) > > Hope there''s a solution out there! > > Regards, > Mathias > > > On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > > > On 11/28/06, Micah Martin <micah at 8thlight.com> wrote: > >> That did the trick. Thanks Pat. > >> > >> > >> Micah Martin > >> > >> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >> > >> Basically in the mean time, just do > >> render :partial => "controller_name/partial_name" > >> > >> So like if the partial is named "person" and it''s under the "people" > >> views dir, it''d be > >> render :partial => "people/person" > >> > >> That''ll work until we get it fixed in the plugin. > > > > We got it fixed in the plugin. In trunk (rev 1174). > > > > Cheers, > > David > > > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >