Yup that fixed it, thanks!

Mark Berry

On Sun, Apr 22, 2012 at 2:41 AM, David Chelimsky <dchelim...@gmail.com> wrote:
> Looks like this is related
> to https://github.com/rspec/rspec-core/issues/585, which is already fixed in
> master. If you point your Gemfile to github now you'll see it fixed. 2.10
> release coming soon.
>
> group :test do
>   gem 'rspec-rails',        :git => "git://github.com/rspec/rspec-rails.git"
>   gem 'rspec-core',         :git => "git://github.com/rspec/rspec-core.git"
>   gem 'rspec-expectations', :git =>
> "git://github.com/rspec/rspec-expectations.git"
>   gem 'rspec-mocks',        :git => "git://github.com/rspec/rspec-mocks.git"
>   gem 'capybara', '1.1.2'
> end
>
> Cheers,
> David
>
> --
> David Chelimsky
> Sent with Sparrow
>
> On Thursday, April 19, 2012 at 5:55 PM, Mark Berry wrote:
>
> On Thu, Apr 19, 2012 at 8:54 AM, Mark Berry <mcbsyst...@gmail.com> wrote:
>
> On Wed, Apr 18, 2012 at 8:09 PM, David Chelimsky <dchelim...@gmail.com>
> wrote:
>
> On Wednesday, April 18, 2012 at 4:30 PM, Mark Berry wrote:
>
> On Wed April 18, 2012 at 5:35 AM, David Chelimsky wrote:
> 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
>
>
> [Sorry if this starts a new thread. I was attempting to monitor and
> reply to the group through Google Groups, but apparently that mirror
> stopped working on April 10, so I'm having to reconstruct this reply.]
>
> Thanks for the reply.
>
> Although the output says "5 examples, 5 failures," there is only one
> example, hence my confusion about it failing five times. Also, the
> "documentation" output lists each describe block (except the first)
> two to four times.
>
> When I fix the error, I get one line per describe, plus one example
> completed, as expected:
>
>
> [myproject (tests)]$ rspec spec/requests/test2* --format documentation
>
> public pages
> details page
> when visiting a second page before example
> should has link "Sign in"
>
> Finished in 1.44 seconds
> 1 example, 0 failures
>
>
> I have since discovered that the problem only occurs when using
> "--format documentation". Without that, with the error back in place,
> RSpec only gives me one error, not five:
>
>
> [myproject (tests)]$ rspec spec/requests/test2*
> F
>
> Failures:
>
> 1) public pages details page 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:0xa1f2ef8>
> # ./spec/requests/test2_pages_spec.rb:9:in `block (4 levels) in
> <top (required)>'
>
> Finished in 1.07 seconds
> 1 example, 1 failure
>
> Failed examples:
>
> rspec ./spec/requests/test2_pages_spec.rb:10 # public pages details
> page when visiting a second page before example
>
> Does that clarify the issue?
>
> Yes. Is the repo public?
>
>
> No, but I think it will duplicate the issue if you drop this into into
> almost any project with a root_path.
>
> spec/requests/test_spec.rb
>
> 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
>
> gemfile:
>
> gem 'rails', '3.1.3'
> gem 'devise', '1.5.3' # required to succeed, but not to fail
> group :test do
>  gem 'rspec-rails', '2.9.0'
>  gem 'capybara', '1.1.2'
> end
>
> Run:
>
> rspec spec/requests/test* --format documentation
>
> Or try with another failing test. I see the issue with any failing
> test if I "--format documentation".
>
> If it doesn't duplicate, let me know and I'll try to build a public
> mini project.
>
> I've seen mention of another recursion issue traced back to Ruby 1.9;
> don't know if this is related:
>
> http://myronmars.to/n/dev-blog/2011/11/recent-rspec-configuration-warnings-and-errors
>
> Mark Berry
>
>
> Or try with another failing test. I see the issue with any failing
> test if I "--format documentation".
>
>
> Let me amend that: I see it on any test with "--format documentation"
> IF the test fails due to a syntax error.
>
> So if "should have_link('foo')" fails because the link is not there, I
> only get one error.
>
> But if I fumble-finger and type "should havelink('foo')", I get the
> syntax error many times.
>
> Mark Berry
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to