Brandon, can you get your Helpers to work in rspec 0.7 ? I''m including them in the context but the render fails to see it. If you have it working, I''ll go back and bang my head against it some more, otherwise I''ll file a bug! Many thanks, Jerry context "account/login (view)" do include StandardHelpers specify ''displays title "Login"'' do self.methods.should_include ''title'' render ''account/login'' response.should_have_tag ''h1'', :content => ''Login'' end end # fails with: ActionView::TemplateError in ''account/login (view) displays title "Login"'' undefined method `title'' for #<#<Class:0xb73154ac>:0xb7314f70> On line #1 of app/views/account/login.rhtml 1: <% title ''Login'' %> (a yield block in the layout) Note that methods.should_include ''title'' passes!
On 11/7/06, Jerry West <jerry.west at ntlworld.com> wrote:> Brandon, > > can you get your Helpers to work in rspec 0.7 ? I''m including them in > the context but the render fails to see it. > > If you have it working, I''ll go back and bang my head against it some > more, otherwise I''ll file a bug! > > Many thanks, > Jerry > > context "account/login (view)" do > include StandardHelpers > specify ''displays title "Login"'' do > self.methods.should_include ''title'' > render ''account/login'' > response.should_have_tag ''h1'', :content => ''Login'' > end > endIs this a view spec or a helper spec? If it''s a view spec, it must be in a views directory: spec/views/**/*_spec.rb http://rspec.rubyforge.org/documentation/rails/writing/index.html Let us know if that solves your problem. Thanks, David> # fails with: > ActionView::TemplateError in ''account/login (view) displays title "Login"'' > undefined method `title'' for #<#<Class:0xb73154ac>:0xb7314f70> > On line #1 of app/views/account/login.rhtml > > 1: <% title ''Login'' %> (a yield block in the layout) > > Note that methods.should_include ''title'' passes! > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
> Is this a view spec or a helper spec? If it''s a view spec, it must be > in a views directory:It''s a view spec and it is now in spec/views/account/login_spec.rb; but still fails :-( . I also do not know what is actually performing the render - what should I be examining in the debugger? I''ve looked at self (within specify) and extended it manually with the helper module but to no avail. I have also tried this: class X include StandardHelpers end context "Given a fresh login" do include StandardHelpers specify ''the account/login view should ask for the user\''s email'' do X.new.should_respond_to ''title'' render ''account/login'' response.should_have_tag ''hi'', :content => ''Login'' end end which still fails on the render but (presumably) the "X.new.should_respond_to ''title''" has worked which at least shows that StandardHelpers are available to be included. Weird. BTW: setup do self.extend(StandardHelpers) end doesn''t work either :-( . Many thanks, Jerry> Is this a view spec or a helper spec? If it''s a view spec, it must be > in a views directory: > > spec/views/**/*_spec.rb > > http://rspec.rubyforge.org/documentation/rails/writing/index.html > > Let us know if that solves your problem. > > Thanks, > David > > >> # fails with: >> ActionView::TemplateError in ''account/login (view) displays title "Login"'' >> undefined method `title'' for #<#<Class:0xb73154ac>:0xb7314f70> >> On line #1 of app/views/account/login.rhtml >> >> 1: <% title ''Login'' %> (a yield block in the layout)
PS: making it a controller spec and calling integrate_views WORKS FINE. (Sounds of quiet sobbing) Jerry West wrote:>> Is this a view spec or a helper spec? If it''s a view spec, it must be >> in a views directory: > > It''s a view spec and it is now in spec/views/account/login_spec.rb; > but still fails :-( . I also do not know what is actually performing > the render - what should I be examining in the debugger? I''ve looked > at self (within specify) and extended it manually with the helper > module but to no avail. > > I have also tried this: > > class X > include StandardHelpers > end > > context "Given a fresh login" do > include StandardHelpers > specify ''the account/login view should ask for the user\''s email'' do > X.new.should_respond_to ''title'' render ''account/login'' > response.should_have_tag ''hi'', :content => ''Login'' > end > end > > > which still fails on the render but (presumably) the > "X.new.should_respond_to ''title''" has worked which at least shows that > StandardHelpers are available to be included. > > Weird. > > BTW: > > setup do > self.extend(StandardHelpers) > end > > doesn''t work either :-( . > > Many thanks, > Jerry > >> Is this a view spec or a helper spec? If it''s a view spec, it must be >> in a views directory: >> >> spec/views/**/*_spec.rb >> >> http://rspec.rubyforge.org/documentation/rails/writing/index.html >> >> Let us know if that solves your problem. >> >> Thanks, >> David >> >> >>> # fails with: >>> ActionView::TemplateError in ''account/login (view) displays title >>> "Login"'' >>> undefined method `title'' for #<#<Class:0xb73154ac>:0xb7314f70> >>> On line #1 of app/views/account/login.rhtml >>> >>> 1: <% title ''Login'' %> (a yield block in the layout) >