On Tuesday, April 17, 2012 at 11:11 PM, Mark Berry wrote: > 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)>' > > >
This is what I would expect. There is nothing "recursive" about this. There is a failure in a before block that runs before every example. It's the same as if you had the same broken code directly in each example. HTH, David
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users