Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

undefined method prepend for nil:NilClass #3

Open
bronson opened this issue Jun 23, 2014 · 1 comment
Open

undefined method prepend for nil:NilClass #3

bronson opened this issue Jun 23, 2014 · 1 comment

Comments

@bronson
Copy link

bronson commented Jun 23, 2014

Hi, my do-nothing test file is crashing inside the around(:all) function.

describe "around all" do
  around(:all) do |group|
  end

  it "works" do
  end
end

I'm hoping you'll know what's going on offhand... If not, I'm happy to look deeper.

Here's the crash:

/Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/hooks.rb:476:in `register': undefined method `prepend' for nil:NilClass (NoMethodError)
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/hooks.rb:317:in `around'
    from /Users/bronson/tablediffer/spec/diff_spec.rb:2:in `block in <top (required)>'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/example_group.rb:331:in `module_exec'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/example_group.rb:331:in `subclass'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
    from /Users/bronson/tablediffer/spec/diff_spec.rb:1:in `<top (required)>'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1051:in `load'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1051:in `block in load_spec_files'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1051:in `each'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/configuration.rb:1051:in `load_spec_files'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:97:in `setup'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:85:in `run'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:70:in `run'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/runner.rb:38:in `invoke'
    from /Users/bronson/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/exe/rspec:4:in `<top (required)>'
    from /Users/bronson/.rbenv/versions/2.1.2/bin/rspec:23:in `load'
    from /Users/bronson/.rbenv/versions/2.1.2/bin/rspec:23:in `<main>'

And my Gemfile.lock:

PATH
  remote: .
  specs:
    tablediffer (0.0.1)

GEM
  remote: https://rubygems.org/
  specs:
    diff-lcs (1.2.5)
    rspec (3.0.0)
      rspec-core (~> 3.0.0)
      rspec-expectations (~> 3.0.0)
      rspec-mocks (~> 3.0.0)
    rspec-core (3.0.1)
      rspec-support (~> 3.0.0)
    rspec-expectations (3.0.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.0.0)
    rspec-mocks (3.0.1)
      rspec-support (~> 3.0.0)
    rspec-support (3.0.0)
    rspec_around_all (0.2.0)
      rspec (>= 2.0)

PLATFORMS
  ruby

DEPENDENCIES
  rspec
  rspec_around_all
  tablediffer!
@akcrono
Copy link

akcrono commented Dec 17, 2020

For future people googling this error message, around(:all) was not a valid rspec hook for a long time, and wasn't added to rspec-core until the end of 2016 (and doesn't behave as expected). Relevant discussion: rspec/rspec-core#1031

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants