simplecov-ruby / simplecov

Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
MIT License
4.78k stars 553 forks source link

Code shown as skipped after rake #487

Closed thebravoman closed 4 years ago

thebravoman commented 8 years ago

When I do

bin/rspec spec/mailer/custom_devise_mailer.rb

I get a total 100% coverage of the class. This is the class:

class CustomDeviseMailer < Devise::Mailer protected def subject_for(key) return super unless key.to_s == 'invitation_instructions' I18n.t('devise.mailer.invitation_instructions.subject',:name => resource.invited_by.try(:full_name) || 'Someone') end end

When I do

rake 

I get 80% of the coverage of the class with the line I18n.t('devise.mailer.invitation_instructions.subject',:name => resource.invited_by.try(:full_name) || 'Someone') shown as missed

Using rails 4.2.4. This is the gemfile.lock

GIT remote: https://github.com/FastSpring/fastspring-ruby.git revision: c78ecf9957581383dd172107a29a623dfef9b5a5 specs: FastSpring (1.0.0)

GIT remote: https://github.com/nholmes/SaasySimple.git revision: 0c9f9f08985e01d52abae17ee379be68273f28ed specs: saasy_simple (0.1.1) rails

GIT remote: https://github.com/twitter/activerecord-reputation-system.git revision: df77666a5d61ce74781b11a84c1a8944cff10779 specs: activerecord-reputation-system (3.0.1)

GEM remote: http://rubygems.org/ specs: actionmailer (4.2.4) actionpack (= 4.2.4) actionview (= 4.2.4) activejob (= 4.2.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) actionpack (4.2.4) actionview (= 4.2.4) activesupport (= 4.2.4) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-action_caching (1.1.1) actionpack (>= 4.0.0, < 5.0) actionview (4.2.4) activesupport (= 4.2.4) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) activejob (4.2.4) activesupport (= 4.2.4) globalid (>= 0.3.0) activemodel (4.2.4) activesupport (= 4.2.4) builder (~> 3.1) activerecord (4.2.4) activemodel (= 4.2.4) activesupport (= 4.2.4) arel (~> 6.0) activesupport (4.2.4) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) acts_as_list (0.7.2) activerecord (>= 3.0) addressable (2.4.0) arel (6.0.3) autoprefixer-rails (6.3.6) execjs awesome_nested_set (3.0.3) activerecord (>= 4.0.0, < 5) aws-sdk-v1 (1.66.0) json (~> 1.4) nokogiri (>= 1.4.4) bcrypt (3.1.11) better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) buftok (0.2.0) builder (3.2.2) byebug (8.2.2) cancancan (1.13.1) canonical-rails (0.0.11) rails (>= 3.1, < 5.0) capybara (2.6.2) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) carmen (1.0.2) activesupport (>= 3.0.0) carmen-rails (1.0.1) carmen (~> 1.0.0) rails ckeditor_rails (4.5.3) railties (>= 3.0) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) cocoon (1.2.9) coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.1) cucumber (2.3.3) builder (>= 2.1.2) cucumber-core (~> 1.4.0) cucumber-wire (~> 0.0.1) diff-lcs (>= 1.1.3) gherkin (~> 3.2.0) multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.1.2) cucumber-core (1.4.0) gherkin (~> 3.2.0) cucumber-rails (1.4.3) capybara (>= 1.1.2, < 3) cucumber (>= 1.3.8, < 3) mime-types (>= 1.16, < 4) nokogiri (~> 1.5) railties (>= 3, < 5) cucumber-wire (0.0.1) dalli (2.7.6) database_cleaner (1.5.1) debug_inspector (0.0.2) devise (3.5.6) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) responders thread_safe (~> 0.1) warden (~> 1.2.3) devise_invitable (1.5.5) actionmailer (>= 3.2.6, < 5) devise (>= 3.2.0) diff-lcs (1.2.5) docile (1.1.5) domain_name (0.5.20160310) unf (>= 0.0.5, < 1.0.0) email_spec (2.0.0) htmlentities (~> 4.3.3) launchy (~> 2.1) mail (~> 2.6.3) equalizer (0.0.10) erubis (2.7.0) exception_notification (4.1.4) actionmailer (~> 4.0) activesupport (~> 4.0) execjs (2.6.0) factory_girl (4.5.0) activesupport (>= 3.0.0) factory_girl_rails (4.6.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) flying-sphinx (1.2.0) faraday (>= 0.9) multi_json (>= 1.3.0) pusher-client (~> 0.3) riddle (>= 1.5.6) thinking-sphinx friendly_id (5.1.0) activerecord (>= 4.0.0) fun_sftp (1.1.0) net-sftp gherkin (3.2.0) globalid (0.3.6) activesupport (>= 4.1.0) hashie (3.4.3) heroku-deflater (0.6.2) rack (>= 1.4.5) htmlentities (4.3.4) http (1.0.4) addressable (~> 2.3) http-cookie (~> 1.0) http-form_data (~> 1.0.1) http_parser.rb (~> 0.6.0) http-cookie (1.0.2) domain_name (~> 0.5) http-form_data (1.0.1) http_parser.rb (0.6.0) httparty (0.13.7) json (~> 1.8) multi_xml (>= 0.5.2) i18n (0.7.0) innertube (1.1.0) joiner (0.3.4) activerecord (>= 4.1.0) jquery-rails (4.1.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) railties (>= 3.2.16) json (1.8.3) jwt (1.5.1) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.10.0) launchy (2.4.3) addressable (~> 2.3) libv8 (3.16.14.13) liquid (3.0.6) liquid-rails (0.1.3) kaminari (~> 0.16.1) liquid (>= 3.0.0) rails (>= 3.2) loofah (2.0.3) nokogiri (>= 1.5.9) macaddr (1.7.1) systemu (~> 2.6.2) mail (2.6.4) mime-types (>= 1.16, < 4) memcachier (0.0.2) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) method_source (0.8.2) middleware (0.1.0) mime-types (3.0) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) mimemagic (0.3.0) mini_portile2 (2.0.0) minitest (5.8.4) modernizr-rails (2.7.1) multi_json (1.11.2) multi_test (0.1.2) multi_xml (0.5.5) multipart-post (2.0.0) mysql2 (0.3.20) naught (1.1.0) net-sftp (2.1.2) net-ssh (>= 2.6.5) net-ssh (3.1.1) newrelic_rpm (3.15.1.316) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) oauth2 (1.1.0) faraday (>= 0.8, < 0.10) jwt (~> 1.0, < 1.5.2) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) omniauth (1.3.1) hashie (>= 1.2, < 4) rack (>= 1.0, < 3) omniauth-facebook (3.0.0) omniauth-oauth2 (~> 1.2) omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) paperclip (4.3.6) activemodel (>= 3.2.0) activesupport (>= 3.2.0) cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) permanent_records (3.3.0) activerecord (>= 3.0.0) pg (0.18.4) polyamorous (1.1.0) activerecord (>= 3.0) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pusher-client (0.6.2) json websocket (~> 1.0) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) rack-timeout (0.4.2) rails (4.2.4) actionmailer (= 4.2.4) actionpack (= 4.2.4) actionview (= 4.2.4) activejob (= 4.2.4) activemodel (= 4.2.4) activerecord (= 4.2.4) activesupport (= 4.2.4) bundler (>= 1.3.0, < 2.0) railties (= 4.2.4) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails4-autocomplete (1.1.1) rails (>= 3.0) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (4.2.4) actionpack (= 4.2.4) activesupport (= 4.2.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.16.0) rake (11.1.2) ref (2.0.0) responders (2.1.2) railties (>= 4.2.0, < 5.1) riddle (1.5.12) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) rspec-mocks (~> 3.4.0) rspec-activemodel-mocks (1.0.3) activemodel (>= 3.0) activesupport (>= 3.0) rspec-mocks (>= 2.99, < 4.0) rspec-core (3.4.4) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-html-matchers (0.7.1) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-rails (3.4.2) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) sass (3.4.22) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) shareable (1.1.4) actionpack (>= 3.0.0) activesupport (>= 3.0.0) simple_oauth (0.3.1) simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) sitemap_generator (5.1.0) builder slop (3.6.0) spork (0.9.2) spring (1.6.4) spring-commands-rspec (1.0.4) spring (>= 0.9.1) sprockets (3.5.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (2.3.3) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) squeel (1.2.3) activerecord (>= 3.0) activesupport (>= 3.0) polyamorous (~> 1.1.0) systemu (2.6.5) therubyracer (0.12.2) libv8 (~> 3.16.14.0) ref thinking-sphinx (3.1.4) activerecord (>= 3.1.0) builder (>= 2.1.2) innertube (>= 1.0.2) joiner (>= 0.2.0) middleware (>= 0.1.0) riddle (>= 1.5.11) thor (0.19.1) thread_safe (0.3.5) tilt (2.0.2) twitter (5.16.0) addressable (~> 2.3) buftok (~> 0.2.0) equalizer (= 0.0.10) faraday (~> 0.9.0) http (~> 1.0) http_parser.rb (~> 0.6.0) json (~> 1.8) memoizable (~> 0.4.0) naught (~> 1.0) simple_oauth (~> 0.3.0) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.2) unicorn (5.1.0) kgio (~> 2.6) raindrops (~> 0.7) uuid (2.3.8) macaddr (~> 1.0) warden (1.2.6) rack (>= 1.0) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) websocket (1.2.3) webvtt-ruby (0.3.2) will_paginate (3.1.0) xpath (2.0.0) nokogiri (~> 1.3) yt (0.25.28) activesupport

PLATFORMS ruby

DEPENDENCIES FastSpring! actionpack-action_caching activerecord-reputation-system! acts_as_list awesome_nested_set aws-sdk-v1 better_errors binding_of_caller bootstrap-sass (>= 3.1.1.1) byebug cancancan canonical-rails carmen-rails ckeditor_rails cocoon coffee-rails (>= 4.0.0) cucumber-rails (~> 1.0) dalli database_cleaner devise devise_invitable email_spec exception_notification factory_girl_rails flying-sphinx friendly_id fun_sftp heroku-deflater httparty jquery-rails jquery-ui-rails liquid-rails memcachier modernizr-rails mysql2 (~> 0.3.20) newrelic_rpm nokogiri omniauth (>= 0.2.2) omniauth-facebook paperclip permanent_records (~> 3.3.0) pg pry rack-timeout rails (= 4.2.4) rails4-autocomplete (~> 1.1, >= 1.1.1) rails_12factor rake responders (~> 2.0) rspec-activemodel-mocks rspec-html-matchers rspec-rails saasy_simple! sass-rails (>= 4.0.0) shareable simplecov sitemap_generator spork spring (>= 1.3.5) spring-commands-rspec sprockets-rails (~> 2.3) squeel therubyracer thinking-sphinx twitter uglifier (>= 1.3.0) unicorn uuid web-console (~> 2.0) webvtt-ruby will_paginate (>= 3.0.pre2) yt

BUNDLED WITH 1.10.6

bf4 commented 8 years ago

@thebravoman Have you seen https://github.com/colszowka/simplecov/issues/340 ?

thebravoman commented 8 years ago

I did now, but except for "Running Rails tests using rake often gives erroneous coverage because the app is loaded before SimpleCov.start is run in a test helper. " I can't find other things related and it actually does not mention how to fix it.. Plus the code above

I18n.t('devise.mailer.invitation_instructions.subject',:name => resource.invited_by.try(:full_name) || 'Someone') 

is not run on load of the class, but only when the method is run and it is actually run only in the tests.

BandanaPandey commented 8 years ago

@thebravoman , can you provide more detailed description about what are you asking ?? can you share with us what is there in your test_helper? Are you sure you have written SimpleCov.start before loading your app in your test_helper ie, SimpleCov.start Load your entire project Run all my tests

PragTob commented 4 years ago

Without more feedback or an example projet there isn't much we can do here :(