rspec_tap
rspec_tap copied to clipboard
"Uninitialized constant RSpec::Support"
Hi,
We are having trouble using rspec_tap in a project.
It works fine in development but as soon as RAILS_ENV is set to test we get the following errors, e.g. when running rake tasks:
RAILS_ENV=test ./bin/rake db:drop
The Gemfile's dependencies are satisfied
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'rspec_tap'.
Gem Load Error is: uninitialized constant RSpec::Support
Backtrace for gem load error is:
/rubygems/gems/rspec-core-3.5.4/lib/rspec/core/formatters/base_text_formatter.rb:1:in `<top (required)>'
/rubygems/gems/rspec_tap-0.1.0/lib/rspec_tap/formatter.rb:2:in `<top (required)>'
/rubygems/gems/rspec_tap-0.1.0/lib/rspec_tap.rb:2:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
/app/config/application.rb:8:in `<top (required)>'
/app/rakefile:4:in `require_relative'
/app/rakefile:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:687:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:96:in `block in load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:95:in `load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:79:in `block in run'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/app/bin/docker/rake:4:in `<main>'
Bundler Error Backtrace:
/app/config/application.rb:8:in `<top (required)>'
/app/rakefile:4:in `require_relative'
/app/rakefile:4:in `<top (required)>'
/app/bin/docker/rake:4:in `<main>'
NameError: uninitialized constant RSpec::Support
/rubygems/gems/rspec-core-3.5.4/lib/rspec/core/formatters/base_text_formatter.rb:1:in `<top (required)>'
/rubygems/gems/rspec_tap-0.1.0/lib/rspec_tap/formatter.rb:2:in `<top (required)>'
/rubygems/gems/rspec_tap-0.1.0/lib/rspec_tap.rb:2:in `<top (required)>'
/app/config/application.rb:8:in `<top (required)>'
/app/rakefile:4:in `require_relative'
/app/rakefile:4:in `<top (required)>'
/app/bin/docker/rake:4:in `<main>'
My first thought was that the issue might be down to this line in the gemspec: https://github.com/appleton/rspec_tap/blob/master/rspec_tap.gemspec#L21 - is it requiring rspec under development environment but not under any others?
This also raises another question: should rspec_tap / rspec be loaded when we're not running specs?
I just ran into this. Adding require: false in the Gemfile fixed it.
@adamdullenty is rspec itself not in your Gemfile for the test environment?