Questions tagged [simplecov]

Simplecov is a code coverage tool for Ruby 1.9+.

Simplecov is a code coverage tool for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites.

https://github.com/colszowka/simplecov

https://www.ruby-toolbox.com/projects/simplecov

95 questions
0
votes
1 answer

How do I unit test the current_user RoR

I have this method to check if the user is admin: def admin? current_user.admin == true end The unit test is: require 'rails_helper' describe StubController do describe '.admin?' do it "should tell if the user is admin" do user =…
0
votes
1 answer

Ruby Code Coverage: SimpleCov + MiniTest?

I integrated SimpleCov into my Ruby project (simple Ruby Gem project, no framework), which uses MiniTest for testing. Here is test_helper.rb: require 'simplecov' SimpleCov.start require 'minitest/autorun' All my test files have require…
amihaiemil
  • 623
  • 8
  • 19
0
votes
1 answer

Ruby SimpleCov 0.0 LOC with stand alone .rb code

I am trying to use SimpleCov to gather code coverage information but I can't seem to understand how it works. It always give me 0.0% LOC. Do I need to do something to make it work? require 'simplecov' SimpleCov.start SimpleCov.command_name 'Unit…
some user
  • 876
  • 1
  • 12
  • 26
0
votes
1 answer

Simplecov fails to exit on rspec suite completion in Ruby 2.6.3

So after upgrading the Ruby version used with my app from 2.5.5 to 2.6.3, simplecov 0.17.0 now hangs silently and permanently at the end of my test suite. I'm running Ruby 2.6.3 and Rails 5.2.3. As for what else may be relevant, I have capybara…
batch
  • 1
  • 2
0
votes
1 answer

Skip simplecov summary when there are test failures

I have a requirement, Simplecov should print this line Coverage report generated ... only if the test suite is green. Is this possible? Here's my initializer SimpleCov.start do add_filter "/test/" coverage_dir "/tmp/coverage/" end
american-ninja-warrior
  • 7,397
  • 11
  • 46
  • 80
0
votes
2 answers

simplecov: extract coverage percentage

I run simplecov like this # test/test_helper.rb require 'simplecov' SimpleCov.start do add_filter "/test/" coverage_dir "/tmp/coverage/" end Instead, or in addition to printing this Coverage report generated for Unit Tests to /tmp/coverage. 30…
american-ninja-warrior
  • 7,397
  • 11
  • 46
  • 80
0
votes
0 answers

SimpleCov ignoring the app folder

I have a simple Ruby app with the following structure root |___ app |___ a.rb |___ b.rb |___ z.rb |___ spec |___ app |___ a_spec.rb |___ b_spec.rb |___ z_spec.rb |___ tasks …
Sig
  • 5,476
  • 10
  • 49
  • 89
0
votes
1 answer

Rails: merge simplecov results gives RuntimeError (can't modify frozen object)

I'm trying to use simplecov to check code coverage by tests in Rails application. So I bumped into common problem: the uncovered files are not shown in the report. Adding Rails.application.eager_load! to test_helper.rb as well as changing…
Tami
  • 153
  • 2
  • 2
  • 11
0
votes
0 answers

simplecov code coverage for my delayed_job tasks?

Anyone know a way to get simplecov code coverage from my delayed_job jobs? I'm using minitest and using Delayed::Worker.new.work_off to cause the job to run but the coverage stubbornly remains at zero.
Paul D Smith
  • 639
  • 5
  • 16
0
votes
1 answer

Cucumber test results not showing up in SimpleCov report

Edit: I am now using a .simplecov file in the root of my directory as per the SimpleCov directions. I have also added some groups including "app/views". However, Cucumber tests are still not being logged into SimpleCov. I even used the launchy gem…
Antonio
  • 731
  • 7
  • 28
0
votes
1 answer

simplecov class test example

I am needing to achieve 100% code coverage for this class. How would I test the following class in simplecov? How can I test the save_user method in rspec? class Log < ActiveRecord::Base has_and_belongs_to_many :tags has_one :asset has_one…
Max Copley
  • 430
  • 3
  • 15
0
votes
1 answer

Rspec test coverage on initializer private method on proxy class

I have the following proxy class that I am trying to hit 100% test coverage on. No matter how I construct this Rspec test simplecov reports the klass_constructor method as not covered. How would I alter these specs to make sure that is covered. I…
Chris Hough
  • 3,389
  • 3
  • 41
  • 80
0
votes
0 answers

SimpleCov Not Giving Code Coverage for Watir-Rails Actions

Using Rails 3, SimpleCov (0.9.2) gives me code coverage for all of my tests but fails to give me a report on what my automated Watir-Rails (1.2.1) browser calls in an ActionDispatch::IntegrationTest. Code that is called normally (ie not through…
andmcadams
  • 43
  • 5
0
votes
1 answer

Simplecov coverage and Spree decorators

I'm trying to use simplecov to get some spec coverage of my customisations to a Spree powered store. Classes are usually stored in /app/models/spree/price_decorator.rb and in the file we crack open the class with a Spree::Price.class_eval block to…
John Smith
  • 1,726
  • 2
  • 18
  • 30
0
votes
1 answer

Rakefile not calling default task

I am trying my hand at writing a rakefile, and have what I think should call simplecov and then call rspec to run tests, but when I run my rakefile nothing gets executed. Am I doing something wrong? Also, is there a way to give the :spec task a…
ThomYorkkke
  • 2,061
  • 3
  • 18
  • 26