[rspec-users] Specing Layouts
Daniel N
has.sox at gmail.com
Sun Jul 15 10:08:00 EDT 2007
On 7/15/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> On 7/14/07, Daniel N <has.sox at gmail.com> wrote:
> >
> >
> > On 7/15/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > On 7/14/07, Daniel N <has.sox at gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I've just started to try and spec my application.html.erb layout as
> one
> > of
> > > > the view specs but it totally barfs.
> > > >
> > > > I'm guessing that it's due to the yield statements in the layout.
> > > >
> > > > Any clues as to how to proceed?
> > >
> > > Backtrace please? Could be any number of things.
> > >
> > > >
> >
> > Sorry, here it is
> >
> > ......rake aborted!
> > Command ruby
> >
> -I"/Users/dneighman/Documents/Projects/rails_projects/update_to_clippings/vendor/plugins/rspec/lib"
> >
> "/Users/dneighman/Documents/Projects/rails_projects/update_to_clippings/vendor/plugins/rspec/bin/spec"
> > "spec/controllers/books_controller_spec.rb"
> > "spec/controllers/sessions_controller_spec.rb"
> > "spec/controllers/users_controller_spec.rb"
> > "spec/helpers/books_helper_spec.rb"
> > "spec/helpers/sessions_helper_spec.rb"
> > "spec/helpers/users_helper_spec.rb"
> > "spec/models/book_spec.rb"
> > "spec/models/user_notifier_spec.rb"
> > "spec/models/user_spec.rb"
> > "spec/views/books/_detail.html.erb_spec.rb"
> > "spec/views/books/edit.html.erb_spec.rb"
> > "spec/views/books/index.html.erb_spec.rb"
> > "spec/views/books/new.html.erb_spec.rb"
> > "spec/views/books/new_rjs.html.erb_spec.rb"
> > "spec/views/books/rjs_index.html.erb_spec.rb"
> > "spec/views/books/show.html.erb_spec.rb"
> > "spec/views/layouts/application.html.erb_spec.rb" --options
> >
> "/Users/dneighman/Documents/Projects/rails_projects/update_to_clippings/spec/spec.opts"
> > failed
> >
> /Users/dneighman/Documents/Projects/rails_projects/update_to_clippings/vendor/plugins/rspec/lib/spec/rake/spectask.rb:166:in
> > `define'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in
> > `verbose'
> >
> /Users/dneighman/Documents/Projects/rails_projects/update_to_clippings/vendor/plugins/rspec/lib/spec/rake/spectask.rb:138:in
> > `define'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
> > `call'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
> > `execute'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
> > `each'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
> > `execute'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in
> > `invoke'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
> > `synchronize'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
> > `invoke'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in
> > `top_level'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in
> > `each'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in
> > `top_level'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
> > `standard_exception_handling'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in
> > `top_level'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-
> > 0.7.3/lib/rake.rb:1711:in `run'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
> > `standard_exception_handling'
> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in
> > `run'
> > /usr/local/lib/ruby/gems/1.8/gems/rake- 0.7.3/bin/rake:7
> > /usr/local/bin/rake:16:in `load'
> > /usr/local/bin/rake:16
> >
> > And the test is
> >
> > require File.dirname(__FILE__) + '/../../spec_helper'
> >
> > describe "/layouts/application.html.erb" do
> >
> > it "should render" do
> > render "/layouts/application.html.erb"
> > end
> >
> >
> > end
>
> Thanks. Unfortunately there's nothing in that backtrace that talks
> about application.html.erb. Would you please run this command and post
> the result?
>
> script/spec spec/views/layouts/application.html.erb -b
>
> Thanks,
> David
Hi David,
Very strange indeed. I had to change the command to
script/spec spec/views/layouts/application.html.erb_spec.rb -b
When I run this I get no errors at all. But I also get no output at all.
When I run the focused example in Textmate it passes but there is no listing
of the example in the output. This is the same as running the Behaviour
Description
It also does not seem to fail anything. I ran the following
def do_render
> render "/layouts/application.html.erb"
> end
>
> it "should render the template" do
> do_render
> response.should have_tag("not_there_tag")
> flunk
> end
This seems to pass everything. But when I run it with
rake spec I get the same error as before
In an attempt to see if it is running the template at all I put a dodgy
method call in the template to try to crash it. It crashes.
Here's the stack trace
ActionView::TemplateError in '/layouts/application.html.erb should render
the template'
undefined local variable or method `bad_method' for
#<#<Class:0x3344718>:0x33446f0>
On line #14 of app/views/layouts/application.html.erb
11: <%= javascript_include_tag :defaults, 'lowpro' -%>
12: <%= stylesheet_link_tag 'common' -%>
13: <%= resource_on_demand %>
14: <%= bad_method %>
15:
16: </head>
17:
#{RAILS_ROOT}/app/views//layouts/application.html.erb:14:in
`_run_erb_47app47views47layouts47application46html46erb'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_view/base.rb:346:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_view/base.rb:346:in
`compile_and_render_template'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_view/base.rb:322:in
`render_template_old'
#{RAILS_ROOT}/vendor/plugins/stable/lib/haml/template.rb:96:in
`render_template'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_view/base.rb:282:in
`render_file'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_controller/base.rb:854:in
`render_file'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_controller/base.rb:789:in
`render_with_no_layout'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_controller/layout.rb:258:in
`render_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_controller/benchmarking.rb:51:in
`render'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3.6752/lib/action_controller/benchmarking.rb:51:in
`render'
#{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in
`send'
#{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in
`render'
spec/views/layouts/application.html.erb_spec.rb:6:in `do_render'
spec/views/layouts/application.html.erb_spec.rb:10
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/example.rb:81:in
`instance_eval'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/example.rb:81:in
`run_example'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/example.rb:26:in `run'
/usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in `run'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:80:in `run'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:74:in
`each'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:74:in `run'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in
`run_behaviours'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in
`each'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in
`run_behaviours'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in
`run'
#{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in
`run'
script/spec:4
I've changed to a haml template, and used the same spec but with a different
file (.haml) to render and it ran fine. Passes everything with complete
listings etc.
I really don't know what to make of it.
Cheers
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070716/cd6d8130/attachment.html
More information about the rspec-users
mailing list