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

ActiveSupport::Concern coverage #167

Closed
masterkain opened this issue Sep 18, 2012 · 4 comments
Closed

ActiveSupport::Concern coverage #167

masterkain opened this issue Sep 18, 2012 · 4 comments
Labels

Comments

@masterkain
Copy link

Hello,

    require 'simplecov'
    SimpleCov.use_merging false
    SimpleCov.start 'rails'

I have this structure:

app/models/concerns/api/account.rb

Added via application.rb:

config.autoload_paths += ["#{config.root}/app/models/concerns", "#{config.root}/app/sweepers)"]

My model app/models/account.rb

class Account < ActiveRecord::Base
  include Api::Account
end

The coverage report does not include app/models/concerns/api/account.rb at all.

I tried to add_group, no dice.

@willmanduffy
Copy link

I've found that this Just Works™ if your concern test is also in a concern folder like so:

app/models/concerns/foo.rb
test/models/concerns/foo_test.rb

Working

This is in line with the behavior I have otherwise seen in SimpleCov where it does not include files in coverage reports where it cannot find the corresponding test.

Philips-MacBook-Pro:untitled philip$ rake
Run options: --seed 30262

# Running tests:

......

Finished tests in 0.281714s, 21.2982 tests/s, 21.2982 assertions/s.

6 tests, 6 assertions, 0 failures, 0 errors, 0 skips
Coverage report generated for Unit Tests to /Users/philip/code/untitled/coverage. 56 / 56 LOC (100.0%) covered.
Philips-MacBook-Pro:untitled philip$ rm test/models/vote_test.rb
Philips-MacBook-Pro:untitled philip$ rake
Run options: --seed 59321

# Running tests:

..

Finished tests in 0.196214s, 10.1930 tests/s, 10.1930 assertions/s.

2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
Coverage report generated for Unit Tests to /Users/philip/code/untitled/coverage. 49 / 49 LOC (100.0%) covered.

Note the changing total LOC covered.

@xaviershay
Copy link
Collaborator

Recommend closing until/unless this can be verified on modern versions.

This is in line with the behavior I have otherwise seen in SimpleCov where it does not include files in coverage reports where it cannot find the corresponding test.

I cannot observe this in my current project.

@bf4 bf4 closed this as completed Jul 11, 2014
@DannyBen
Copy link

DannyBen commented Mar 2, 2016

I can confirm I am experiencing this as well, in 0.10.0
My concerns are not tested for coverage, even if its test is in models/concerns
(I cant work with any of the 0.11.x versions, as it generates reduced coverage with the blank line issues and such).

@simplecov-ruby simplecov-ruby locked and limited conversation to collaborators Mar 2, 2016
@bf4
Copy link
Collaborator

bf4 commented Mar 2, 2016

@DannyBen please open a new issue describing your version, your test suite, how your running your tests, your gem statement in your gemfile, and where you require/configure simplecov (and reference this issue), as well as expected and observed output. Thanks!

Any code that let's us reproduce the problem is a big help

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

No branches or pull requests

5 participants