[rspec-users] One error reported recursively if two pages visited by request spec

Mark Berry mcbsystems at gmail.com
Wed Apr 18 04:11:07 UTC 2012


Hi,

I'm using Rails 3.1.3, rspec-rails 2.9.0, and Ruby 1.9.3p0.

I've been getting recursive errors, where one error is reported
multiple times. It's quite spectacular in a long suite, with the
errors overflowing the console buffer. I've whittled down a simple
example:

require 'spec_helper'
describe "public pages" do
  subject { page }
  describe "details page" do
    before do
      visit root_path
    end
    describe "when visiting a second page before example" do
      before { visit sign_in_path }
      it { should have_link("Sign in") }
    end
  end
end

The error here is that "sign_in_path" should really be "signin_path".
But I get that error five times, and when I run with --format
documentation, it looks like RSpec is generating it recursively before
it "blows up" with a stack trace (see output below).

Obviously this test doesn't really need two before blocks, but
sometimes I do want to visit two pages before a test.

Am I doing something wrong, or is this a bug?

Mark Berry

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test output:

[myproject (tests)]$ rspec spec/requests/test2* --format documentation
No DRb server is running. Running in local process instead ...

public pages
  details page
    when no user is signed in
      when visiting a second page before example
      when visiting a second page before example
      when no user is signed in
        when visiting a second page before example
        details page
          when no user is signed in
            when visiting a second page before example

Failures:

  1) public pages details page when no user is signed in when visiting
a second page before example
     Failure/Error: before { visit sign_in_path }
     NameError:
       undefined local variable or method `sign_in_path' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0xb6f3460>
     # ./spec/requests/test2_pages_spec.rb:16:in `block (5 levels) in
<top (required)>'

  2) public pages details page when no user is signed in when visiting
a second page before example
     Failure/Error: before { visit sign_in_path }
     NameError:
       undefined local variable or method `sign_in_path' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0xb6f3460>
     # ./spec/requests/test2_pages_spec.rb:16:in `block (5 levels) in
<top (required)>'

  3) public pages details page when no user is signed in when visiting
a second page before example
     Failure/Error: before { visit sign_in_path }
     NameError:
       undefined local variable or method `sign_in_path' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0xb6f3460>
     # ./spec/requests/test2_pages_spec.rb:16:in `block (5 levels) in
<top (required)>'

  4) public pages details page when no user is signed in when visiting
a second page before example
     Failure/Error: before { visit sign_in_path }
     NameError:
       undefined local variable or method `sign_in_path' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0xb6f3460>
     # ./spec/requests/test2_pages_spec.rb:16:in `block (5 levels) in
<top (required)>'

  5) public pages details page when no user is signed in when visiting
a second page before example
     Failure/Error: before { visit sign_in_path }
     NameError:
       undefined local variable or method `sign_in_path' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0xb6f3460>
     # ./spec/requests/test2_pages_spec.rb:16:in `block (5 levels) in
<top (required)>'

Finished in 0.33725 seconds
5 examples, 5 failures

Failed examples:

rspec ./spec/requests/test2_pages_spec.rb:18 # public pages details
page when no user is signed in when visiting a second page before
example
rspec ./spec/requests/test2_pages_spec.rb:18 # public pages details
page when no user is signed in when visiting a second page before
example
rspec ./spec/requests/test2_pages_spec.rb:18 # public pages details
page when no user is signed in when visiting a second page before
example
rspec ./spec/requests/test2_pages_spec.rb:18 # public pages details
page when no user is signed in when visiting a second page before
example
rspec ./spec/requests/test2_pages_spec.rb:18 # public pages details
page when no user is signed in when visiting a second page before
example
/home/myuser/.rvm/gems/ruby-1.9.3-p0 at myproject/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in
`method_missing': undefined method `strip' for nil:NilClass
(NoMethodError)
	from /home/myuser/.rvm/gems/ruby-1.9.3-p0 at myproject/gems/rspec-core-2.9.0/lib/rspec/core/formatters/documentation_formatter.rb:41:in
`failure_output'
	from /home/myuser/.rvm/gems/ruby-1.9.3-p0 at myproject/gems/rspec-core-2.9.0/lib/rspec/core/formatters/documentation_formatter.rb:37:in
`example_failed'
	from /home/myuser/.rvm/gems/ruby-1.9.3-p0 at myproject/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:98:in
`block in notify'
...


More information about the rspec-users mailing list