Skip to content

rake simplecov doesn't include RSpec / remove simplecov railtie #689

Closed

Description

@davispuh

Created new Rails 5.2.1 project.
Added RSpec and SimpleCov.

rake spec works fine but rake simplecov doesn't include RSpec and so fails with

$ rake simplecov
Coverage report generated for RSpec to proj/coverage. 0 / 15 LOC (0.0%) covered.
Traceback (most recent call last):
        8: from -e:2:in `<main>'
        7: from -e:2:in `each'
        6: from -e:2:in `block in <main>'
        5: from -e:2:in `require'
        4: from spec/controllers/pp_controller_spec.rb:1:in `<top (required)>'
        3: from spec/controllers/pp_controller_spec.rb:1:in `require'
        2: from spec/rails_helper.rb:2:in `<top (required)>'
        1: from spec/rails_helper.rb:2:in `require'
spec/spec_helper.rb:20:in `<top (required)>': uninitialized constant RSpec (NameError)
rake aborted!
Command failed with status (1)
Tasks: TOP => simplecov
(See full trace by running task with --trace)

Inside spec/spec_helper.rb there's

require 'simplecov'
SimpleCov.start 'rails'
RSpec.configure do |config|
  ...
end

If I add require 'rspec/core' to spec/spec_helper.rb then it works but I get

/usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40: warning: method redefined; discarding old require_relative
/usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48: warning: method redefined; discarding old load
/usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/compile_cache/yaml.rb:48: warning: method redefined; discarding old load_file
/usr/lib/ruby/2.5.0/psych.rb:496: warning: previous definition of load_file was here

Using latest SimpleCov 0.16.1 and

Rails version             5.2.1
Ruby version              2.5.1-p57 (x86_64-linux)
RubyGems version          2.7.7
Rack version              2.0.5

Inside Gemfile

gem 'rails', '~> 5.2.1'

gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails'
  gem 'capybara'
  gem 'simplecov'
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

Activity

  1. PragTob commented on Aug 12, 2018

    @PragTob
    Collaborator

    Hi there,

    I didn't even know this existed 😁

    By the looks of it it was added 7 years ago for rails 3 - I don't even now how this was supposed to work. Sorry :(

  2. davispuh commented on Aug 12, 2018

    @davispuh
    Author

    Well then solution could be just remove it 😛
    Don't really think there's point of it if rake spec does same thing.

  3. PragTob commented on Dec 3, 2019

    @PragTob
    Collaborator

    Seems it comes from #83 - it's very weird to me that something has existed for this long but isn't mentioned in the README at all. It's also completely untested as I believe we have no test that goes against any kind of rails setup (which I'd want to add).

    I'm leaning towards removing it and maybe adding it back if people complain. This seems like a complexity I'm not sure I wanna have in the project.

  4. changed the title [-]rake simplecov doesn't include RSpec[/-] [+]rake simplecov doesn't include RSpec / remove simplecoc railtie[/+] on Dec 3, 2019
  5. davispuh commented on Dec 3, 2019

    @davispuh
    Author

    This seems like a complexity I'm not sure I wanna have in the project.

    Looking at mentioned PR, I don't see much of complexity.
    Anyway removing it is fine with me.

  6. PragTob commented on Dec 4, 2019

    @PragTob
    Collaborator

    @davispuh the complexity isn't in the code but its implications. It needs we're bound to rails/railties and changes that might happen there. It also binds us to RSpec/minitest and their folders/layout. It's also arguably wrong as it doesn't execute cucumber features for instance... and it always starts the rails profile leading to potentially confusing results.

    Fixing all this requires integration with 4+ projects that might break at any point in time and at any combination of versions or pop up of a new test framework or what not.

  7. changed the title [-]rake simplecov doesn't include RSpec / remove simplecoc railtie[/-] [+]rake simplecov doesn't include RSpec / remove simplecov railtie[/+] on Dec 4, 2019
  8. added theissue type on May 7, 2026
  9. added a commit that references this issue on May 11, 2026
  10. added a commit that references this issue on May 14, 2026
  11. added a commit that references this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions