Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Rails first since rspec-rails use the Rails constant #22

Closed
wants to merge 1 commit into from

Conversation

strzibny
Copy link

Requiring ammeter/init directly fails[1] due to missing constant in rspec-rails[2]:

/usr/share/gems/gems/rspec-rails-2.14.0/lib/rspec/rails/example/rails_example_group.rb:10:in `<module:RailsExampleGroup>': uninitialized constant Rails::VERSION (NameError)
    from /usr/share/gems/gems/rspec-rails-2.14.0/lib/rspec/rails/example/rails_example_group.rb:7:in `<module:Rails>'
    from /usr/share/gems/gems/rspec-rails-2.14.0/lib/rspec/rails/example/rails_example_group.rb:6:in `<module:RSpec>'
    from /usr/share/gems/gems/rspec-rails-2.14.0/lib/rspec/rails/example/rails_example_group.rb:5:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/share/gems/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example/generator_example_group.rb:4:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/share/gems/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example.rb:2:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/share/gems/gems/ammeter-0.2.9/lib/ammeter/init.rb:1:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:116:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:116:in `rescue in require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:122:in `require'
    from test.rb:2:in `<main>'

Reversing the order fixes the issue.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1007631
[2] https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/rails_example_group.rb#L10

@felixbuenemann
Copy link

I'm running into the same issue, solved it by adding require 'rails/version' to generator_example_group.rb prior to require 'rspec/rails/example/rails_example_group'.

@alexrothenberg
Copy link
Owner

Merged this change. Thank you for the change!

The specs were failing due to a Rails 4.1 change and I just got that fixed. Sorry this took so long.

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

Successfully merging this pull request may close these issues.

3 participants