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

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

Closed
davispuh opened this issue Aug 11, 2018 · 5 comments · Fixed by #790
Closed

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

davispuh opened this issue Aug 11, 2018 · 5 comments · Fixed by #790

Comments

@davispuh
Copy link

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
@PragTob
Copy link
Collaborator

PragTob commented Aug 12, 2018

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 :(

@davispuh
Copy link
Author

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

@PragTob
Copy link
Collaborator

PragTob commented Dec 3, 2019

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.

@PragTob PragTob changed the title rake simplecov doesn't include RSpec rake simplecov doesn't include RSpec / remove simplecoc railtie Dec 3, 2019
@davispuh
Copy link
Author

davispuh commented Dec 3, 2019

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.

@PragTob
Copy link
Collaborator

PragTob commented Dec 4, 2019

@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.

@PragTob PragTob changed the title rake simplecov doesn't include RSpec / remove simplecoc railtie rake simplecov doesn't include RSpec / remove simplecov railtie Dec 4, 2019
PragTob added a commit that referenced this issue Dec 15, 2019
Was causing issues, was undocumented either way and too many
headaches to make it work fully with all integrations
#689 (comment)

Fixes #689
PragTob added a commit that referenced this issue Dec 15, 2019
Was causing issues, was undocumented either way and too many
headaches to make it work fully with all integrations
#689 (comment)

Fixes #689
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 5, 2020
Update ruby-simplecov to  0.18.1.

0.18.1 (2020-01-31)
===================

Small Bugfix release.

## Bugfixes
* Just putting `# :nocov:` on top of a file or having an uneven number of them in general works again and acts as if ignoring until the end of the file. See [#846](simplecov-ruby/simplecov#846) and thanks [@DannyBen](https://github.com/DannyBen) for the report.

0.18.0 (2020-01-28)
===================

Huge release! Highlights are support for branch coverage (Ruby 2.5+) and dropping support for EOL'ed Ruby versions (< 2.4).
Please also read the other beta patch notes.

## Enhancements
* You can now define the minimum expected coverage by criterion like `minimum_coverage line: 90, branch: 80`
* Memoized some internal data structures that didn't change to reduce SimpleCov overhead
* Both `FileList` and `SourceFile` now have a `coverage` method that returns a hash that points from a coverage criterion to a `CoverageStatistics` object for uniform access to overall coverage statistics for both line and branch coverage

## Bugfixes
* we were losing precision by rounding the covered strength early, that has been removed. **For Formatters** this also means that you may need to round it yourself now.
* Removed an inconsistency in how we treat skipped vs. irrelevant lines (see [#565](simplecov-ruby/simplecov#565)) - SimpleCov's definition of 100% is now "You covered everything that you could" so if coverage is 0/0 that's counted as a 100% no matter if the lines were irrelevant or ignored/skipped

## Noteworthy
* `FileList` stopped inheriting from Array, it includes Enumerable so if you didn't use Array specific methods on it in formatters you should be fine

0.18.0.beta3 (2020-01-20)
========================

## Enhancements
* Instead of ignoring old `.resultset.json`s that are inside the merge timeout, adapt and respect them

## Bugfixes
* Remove the constant warning printing if you still have a `.resultset.json` in pre 0.18 layout that is within your merge timeout

0.18.0.beta2 (2020-01-19)
===================

## Enhancements
* only turn on the requested coverage criteria (when activating branch coverage before SimpleCov would also instruct Ruby to take Method coverage)
* Change how branch coverage is displayed, now it's `branch_type: hit_count` which should be more self explanatory. See [#830](simplecov-ruby/simplecov#830) for an example and feel free to give feedback!
* Allow early running exit tasks and avoid the `at_exit` hook through the `SimpleCov.run_exit_tasks!` method. (thanks [@macumber](https://github.com/macumber))
* Allow manual collation of result sets through the `SimpleCov.collate` entrypoint. See the README for more details (thanks [@ticky](https://github.com/ticky))
* Within `case`, even if there is no `else` branch declared show missing coverage for it (aka no branch of it). See [#825](simplecov-ruby/simplecov#825)
* Stop symbolizing all keys when loading cache (should lead to be faster and consume less memory)
* Cache whether we can use/are using branch coverage (should be slightly faster)

## Bugfixes
* Fix a crash that happened when an old version of our internal cache file `.resultset.json` was still present

0.18.0.beta1 (2020-01-05)
===================

This is a huge release highlighted by changing our support for ruby versions to 2.4+ (so things that aren't EOL'ed) and finally adding branch coverage support!

This release is still beta because we'd love for you to test out branch coverage and get your feedback before doing a full release.

On a personal note from [@PragTob](https://github.com/PragTob/) thanks to [ruby together](https://rubytogether.org/) for sponsoring this work on SimpleCov making it possible to deliver this and subsequent releases.

## Breaking
* Dropped support for all EOL'ed rubies meaning we only support 2.4+. Simplecov can no longer be installed on older rubies, but older simplecov releases should still work. (thanks [@deivid-rodriguez](https://github.com/deivid-rodriguez))
* Dropped the `rake simplecov` task that "magically" integreated with rails. It was always undocumented, caused some issues and [had some issues](simplecov-ruby/simplecov#689 (comment)). Use the integration as described in the README please :)

## Enhancements

* Branch coverage is here! Please try it out and test it! You can activate it with `enable_coverage :branch`. See the README for more details. This is thanks to a bunch of people most notably [@som4ik](https://github.com/som4ik), [@tycooon](https://github.com/tycooon), [@stepozer](https://github.com/stepozer),  [@klyonrad](https://github.com/klyonrad) and your humble maintainers also contributed ;)
* If the minimum coverage is set to be greater than 100, a warning will be shown. See [#737](simplecov-ruby/simplecov#737) (thanks [@belfazt](https://github.com/belfazt))
* Add a configuration option to disable the printing of non-successful exit statuses. See [#747](simplecov-ruby/simplecov#746) (thanks [@JacobEvelyn](https://github.com/JacobEvelyn))
* Calculating 100% coverage is now stricter, so 100% means 100%. See [#680](simplecov-ruby/simplecov#680) thanks [@gleseur](https://github.com/gleseur)

## Bugfixes

* Add new instance of `Minitest` constant. The `MiniTest` constant (with the capital T) will be removed in the next major release of Minitest. See [#757](simplecov-ruby/simplecov#757) (thanks [@adam12](https://github.com/adam12))
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 a pull request may close this issue.

2 participants