simplecov-patched 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +31 -0
- data/.rspec +3 -0
- data/.rubocop.yml +88 -0
- data/.travis.yml +29 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +435 -0
- data/CONTRIBUTING.md +48 -0
- data/Gemfile +38 -0
- data/MIT-LICENSE +20 -0
- data/README.md +646 -0
- data/Rakefile +41 -0
- data/cucumber.yml +13 -0
- data/doc/alternate-formatters.md +36 -0
- data/doc/commercial-services.md +20 -0
- data/doc/editor-integration.md +13 -0
- data/features/config_autoload.feature +46 -0
- data/features/config_command_name.feature +45 -0
- data/features/config_coverage_dir.feature +33 -0
- data/features/config_deactivate_merging.feature +42 -0
- data/features/config_formatters.feature +77 -0
- data/features/config_merge_timeout.feature +39 -0
- data/features/config_nocov_token.feature +79 -0
- data/features/config_profiles.feature +44 -0
- data/features/config_project_name.feature +27 -0
- data/features/config_styles.feature +121 -0
- data/features/config_tracked_files.feature +29 -0
- data/features/cucumber_basic.feature +29 -0
- data/features/maximum_coverage_drop.feature +89 -0
- data/features/merging_test_unit_and_rspec.feature +44 -0
- data/features/minimum_coverage.feature +59 -0
- data/features/refuse_coverage_drop.feature +95 -0
- data/features/rspec_basic.feature +32 -0
- data/features/rspec_fails_on_initialization.feature +14 -0
- data/features/rspec_groups_and_filters_basic.feature +29 -0
- data/features/rspec_groups_and_filters_complex.feature +37 -0
- data/features/rspec_groups_using_filter_class.feature +41 -0
- data/features/rspec_without_simplecov.feature +20 -0
- data/features/skipping_code_blocks_manually.feature +70 -0
- data/features/step_definitions/html_steps.rb +44 -0
- data/features/step_definitions/simplecov_steps.rb +68 -0
- data/features/step_definitions/transformers.rb +13 -0
- data/features/step_definitions/web_steps.rb +64 -0
- data/features/support/env.rb +50 -0
- data/features/test_unit_basic.feature +34 -0
- data/features/test_unit_groups_and_filters_basic.feature +29 -0
- data/features/test_unit_groups_and_filters_complex.feature +35 -0
- data/features/test_unit_groups_using_filter_class.feature +40 -0
- data/features/test_unit_without_simplecov.feature +20 -0
- data/features/unicode_compatiblity.feature +67 -0
- data/lib/simplecov.rb +189 -0
- data/lib/simplecov/command_guesser.rb +59 -0
- data/lib/simplecov/configuration.rb +307 -0
- data/lib/simplecov/defaults.rb +121 -0
- data/lib/simplecov/exit_codes.rb +8 -0
- data/lib/simplecov/file_list.rb +59 -0
- data/lib/simplecov/filter.rb +54 -0
- data/lib/simplecov/formatter.rb +8 -0
- data/lib/simplecov/formatter/multi_formatter.rb +32 -0
- data/lib/simplecov/formatter/simple_formatter.rb +23 -0
- data/lib/simplecov/jruby_fix.rb +42 -0
- data/lib/simplecov/last_run.rb +24 -0
- data/lib/simplecov/load_global_config.rb +6 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles.rb +31 -0
- data/lib/simplecov/railtie.rb +7 -0
- data/lib/simplecov/railties/tasks.rake +11 -0
- data/lib/simplecov/raw_coverage.rb +39 -0
- data/lib/simplecov/result.rb +86 -0
- data/lib/simplecov/result_merger.rb +95 -0
- data/lib/simplecov/source_file.rb +196 -0
- data/lib/simplecov/version.rb +25 -0
- data/spec/1_8_fallbacks_spec.rb +31 -0
- data/spec/command_guesser_spec.rb +48 -0
- data/spec/config_loader_spec.rb +14 -0
- data/spec/configuration_spec.rb +35 -0
- data/spec/deleted_source_spec.rb +12 -0
- data/spec/faked_project/Gemfile +6 -0
- data/spec/faked_project/Rakefile +8 -0
- data/spec/faked_project/cucumber.yml +13 -0
- data/spec/faked_project/features/step_definitions/my_steps.rb +22 -0
- data/spec/faked_project/features/support/env.rb +12 -0
- data/spec/faked_project/features/test_stuff.feature +6 -0
- data/spec/faked_project/lib/faked_project.rb +11 -0
- data/spec/faked_project/lib/faked_project/framework_specific.rb +18 -0
- data/spec/faked_project/lib/faked_project/meta_magic.rb +24 -0
- data/spec/faked_project/lib/faked_project/some_class.rb +28 -0
- data/spec/faked_project/lib/faked_project/untested_class.rb +11 -0
- data/spec/faked_project/spec/faked_spec.rb +11 -0
- data/spec/faked_project/spec/forking_spec.rb +8 -0
- data/spec/faked_project/spec/meta_magic_spec.rb +15 -0
- data/spec/faked_project/spec/some_class_spec.rb +13 -0
- data/spec/faked_project/spec/spec_helper.rb +11 -0
- data/spec/faked_project/test/faked_test.rb +11 -0
- data/spec/faked_project/test/meta_magic_test.rb +13 -0
- data/spec/faked_project/test/some_class_test.rb +15 -0
- data/spec/faked_project/test/test_helper.rb +12 -0
- data/spec/file_list_spec.rb +50 -0
- data/spec/filters_spec.rb +98 -0
- data/spec/fixtures/app/controllers/sample_controller.rb +10 -0
- data/spec/fixtures/app/models/user.rb +10 -0
- data/spec/fixtures/deleted_source_sample.rb +15 -0
- data/spec/fixtures/frameworks/rspec_bad.rb +9 -0
- data/spec/fixtures/frameworks/rspec_good.rb +9 -0
- data/spec/fixtures/frameworks/testunit_bad.rb +9 -0
- data/spec/fixtures/frameworks/testunit_good.rb +9 -0
- data/spec/fixtures/iso-8859.rb +3 -0
- data/spec/fixtures/never.rb +2 -0
- data/spec/fixtures/resultset1.rb +4 -0
- data/spec/fixtures/resultset2.rb +4 -0
- data/spec/fixtures/sample.rb +16 -0
- data/spec/fixtures/skipped.rb +4 -0
- data/spec/fixtures/skipped_and_executed.rb +8 -0
- data/spec/fixtures/utf-8.rb +3 -0
- data/spec/helper.rb +26 -0
- data/spec/last_run_spec.rb +48 -0
- data/spec/multi_formatter_spec.rb +20 -0
- data/spec/raw_coverage_spec.rb +92 -0
- data/spec/result_merger_spec.rb +96 -0
- data/spec/result_spec.rb +209 -0
- data/spec/return_codes_spec.rb +34 -0
- data/spec/simplecov_spec.rb +110 -0
- data/spec/source_file_line_spec.rb +155 -0
- data/spec/source_file_spec.rb +141 -0
- data/spec/support/fail_rspec_on_ruby_warning.rb +75 -0
- metadata +320 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
@test_unit @config
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Exit code should be non-zero if the overall coverage decreases.
|
5
|
+
And last_run file should not be overwritten with new coverage value.
|
6
|
+
|
7
|
+
Scenario: refuse_coverage_drop configured
|
8
|
+
Given SimpleCov for Test/Unit is configured with:
|
9
|
+
"""
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter 'test.rb'
|
13
|
+
refuse_coverage_drop
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
|
17
|
+
When I run `bundle exec rake test`
|
18
|
+
Then the exit status should be 0
|
19
|
+
And a file named "coverage/.last_run.json" should exist
|
20
|
+
And the file "coverage/.last_run.json" should contain:
|
21
|
+
"""
|
22
|
+
{
|
23
|
+
"result": {
|
24
|
+
"covered_percent": 88.1
|
25
|
+
}
|
26
|
+
}
|
27
|
+
"""
|
28
|
+
|
29
|
+
Given a file named "lib/faked_project/missed.rb" with:
|
30
|
+
"""
|
31
|
+
class UncoveredSourceCode
|
32
|
+
def foo
|
33
|
+
never_reached
|
34
|
+
rescue => err
|
35
|
+
but no one cares about invalid ruby here
|
36
|
+
end
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
|
40
|
+
When I run `bundle exec rake test`
|
41
|
+
Then the exit status should not be 0
|
42
|
+
And the output should contain "Coverage has dropped by 3.32% since the last time (maximum allowed: 0.00%)."
|
43
|
+
And a file named "coverage/.last_run.json" should exist
|
44
|
+
And the file "coverage/.last_run.json" should contain:
|
45
|
+
"""
|
46
|
+
{
|
47
|
+
"result": {
|
48
|
+
"covered_percent": 88.1
|
49
|
+
}
|
50
|
+
}
|
51
|
+
"""
|
52
|
+
|
53
|
+
Scenario: refuse_coverage_drop not configured updates resultset
|
54
|
+
Given SimpleCov for Test/Unit is configured with:
|
55
|
+
"""
|
56
|
+
require 'simplecov'
|
57
|
+
SimpleCov.start do
|
58
|
+
add_filter 'test.rb'
|
59
|
+
end
|
60
|
+
"""
|
61
|
+
|
62
|
+
When I run `bundle exec rake test`
|
63
|
+
Then the exit status should be 0
|
64
|
+
And a file named "coverage/.last_run.json" should exist
|
65
|
+
And the file "coverage/.last_run.json" should contain:
|
66
|
+
"""
|
67
|
+
{
|
68
|
+
"result": {
|
69
|
+
"covered_percent": 88.1
|
70
|
+
}
|
71
|
+
}
|
72
|
+
"""
|
73
|
+
|
74
|
+
Given a file named "lib/faked_project/missed.rb" with:
|
75
|
+
"""
|
76
|
+
class UncoveredSourceCode
|
77
|
+
def foo
|
78
|
+
never_reached
|
79
|
+
rescue => err
|
80
|
+
but no one cares about invalid ruby here
|
81
|
+
end
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
|
85
|
+
When I run `bundle exec rake test`
|
86
|
+
Then the exit status should be 0
|
87
|
+
And a file named "coverage/.last_run.json" should exist
|
88
|
+
And the file "coverage/.last_run.json" should contain:
|
89
|
+
"""
|
90
|
+
{
|
91
|
+
"result": {
|
92
|
+
"covered_percent": 84.78
|
93
|
+
}
|
94
|
+
}
|
95
|
+
"""
|
@@ -0,0 +1,32 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Simply adding the basic simplecov lines to a project should get
|
5
|
+
the user a coverage report after running `rspec`
|
6
|
+
|
7
|
+
Scenario:
|
8
|
+
Given SimpleCov for RSpec is configured with:
|
9
|
+
"""
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start
|
12
|
+
"""
|
13
|
+
|
14
|
+
When I open the coverage report generated with `bundle exec rspec spec`
|
15
|
+
Then I should see the groups:
|
16
|
+
| name | coverage | files |
|
17
|
+
| All Files | 91.8% | 7 |
|
18
|
+
|
19
|
+
And I should see the source files:
|
20
|
+
| name | coverage |
|
21
|
+
| lib/faked_project.rb | 100.0 % |
|
22
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
23
|
+
| lib/faked_project/framework_specific.rb | 75.0 % |
|
24
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
25
|
+
| spec/forking_spec.rb | 100.0 % |
|
26
|
+
| spec/meta_magic_spec.rb | 100.0 % |
|
27
|
+
| spec/some_class_spec.rb | 100.0 % |
|
28
|
+
|
29
|
+
# Note: faked_spec.rb is not appearing here since that's the first unit test file
|
30
|
+
# loaded by Rake, and only there test_helper is required, which then loads simplecov
|
31
|
+
# and triggers tracking of all other loaded files! Solution for this would be to
|
32
|
+
# configure simplecov in this first test instead of test_helper.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Running specs with a failing rspec setup
|
5
|
+
|
6
|
+
Scenario: Fail if rspec fails before starting its tests
|
7
|
+
Given a file named "spec/spec_helper.rb" with:
|
8
|
+
"""
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start
|
11
|
+
raise "some exception in the class loading before the tests start"
|
12
|
+
"""
|
13
|
+
When I run `bundle exec rspec spec`
|
14
|
+
Then the exit status should not be 0
|
@@ -0,0 +1,29 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Defining some groups and filters should give a corresponding
|
5
|
+
coverage report that respects those settings after running rspec
|
6
|
+
|
7
|
+
Scenario:
|
8
|
+
Given SimpleCov for RSpec is configured with:
|
9
|
+
"""
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start do
|
12
|
+
add_group 'Libs', 'lib/faked_project/'
|
13
|
+
add_filter '/spec/'
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
|
17
|
+
When I open the coverage report generated with `bundle exec rspec spec`
|
18
|
+
And I should see the groups:
|
19
|
+
| name | coverage | files |
|
20
|
+
| All Files | 88.1% | 4 |
|
21
|
+
| Libs | 86.11% | 3 |
|
22
|
+
| Ungrouped | 100.0% | 1 |
|
23
|
+
|
24
|
+
And I should see the source files:
|
25
|
+
| name | coverage |
|
26
|
+
| lib/faked_project.rb | 100.0 % |
|
27
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
28
|
+
| lib/faked_project/framework_specific.rb | 75.0 % |
|
29
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
@@ -0,0 +1,37 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature: Sophisticated grouping and filtering on RSpec
|
3
|
+
|
4
|
+
Defining groups and filters can be done by passing blocks or strings.
|
5
|
+
Blocks get each SimpleCov::SourceFile instance passed an can use arbitrary
|
6
|
+
and potentially weird conditions to remove files from the report or add them
|
7
|
+
to specific groups.
|
8
|
+
|
9
|
+
Scenario:
|
10
|
+
Given SimpleCov for RSpec is configured with:
|
11
|
+
"""
|
12
|
+
require 'simplecov'
|
13
|
+
SimpleCov.start do
|
14
|
+
add_group 'By block' do |src_file|
|
15
|
+
src_file.filename =~ /MaGiC/i
|
16
|
+
end
|
17
|
+
add_group 'By string', 'project/meta_magic'
|
18
|
+
add_group 'By array', ['project/meta_magic']
|
19
|
+
|
20
|
+
add_filter 'faked_project.rb'
|
21
|
+
# Remove all files that include "describe" in their source
|
22
|
+
add_filter {|src_file| src_file.lines.any? {|line| line.src =~ /describe/ } }
|
23
|
+
add_filter {|src_file| src_file.covered_percent < 100 }
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
|
27
|
+
When I open the coverage report generated with `bundle exec rspec spec`
|
28
|
+
Then I should see the groups:
|
29
|
+
| name | coverage | files |
|
30
|
+
| All Files | 100.0% | 1 |
|
31
|
+
| By block | 100.0% | 1 |
|
32
|
+
| By string | 100.0% | 1 |
|
33
|
+
| By array | 100.0% | 1 |
|
34
|
+
|
35
|
+
And I should see the source files:
|
36
|
+
| name | coverage |
|
37
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
@@ -0,0 +1,41 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature: Grouping on RSpec using a custom filter class
|
3
|
+
|
4
|
+
Next to passing a block or a string to define a group, you can also pass
|
5
|
+
a filter class. The filter class inherits from SimpleCov::Filter and
|
6
|
+
must implement the matches? method, which is used to determine whether
|
7
|
+
or not a file should be added to the group.
|
8
|
+
|
9
|
+
Scenario:
|
10
|
+
Given SimpleCov for RSpec is configured with:
|
11
|
+
"""
|
12
|
+
require 'simplecov'
|
13
|
+
class CoverageFilter < SimpleCov::Filter
|
14
|
+
def matches?(source_file)
|
15
|
+
source_file.covered_percent < filter_argument
|
16
|
+
end
|
17
|
+
end
|
18
|
+
SimpleCov.start do
|
19
|
+
add_group 'By filter class', CoverageFilter.new(90)
|
20
|
+
add_group 'By string', 'project/meta_magic'
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
|
24
|
+
When I open the coverage report generated with `bundle exec rspec spec`
|
25
|
+
Then I should see the groups:
|
26
|
+
| name | coverage | files |
|
27
|
+
| All Files | 91.8% | 7 |
|
28
|
+
| By filter class | 78.26% | 2 |
|
29
|
+
| By string | 100.0% | 1 |
|
30
|
+
| Ungrouped | 100.0% | 4 |
|
31
|
+
|
32
|
+
And I should see the source files:
|
33
|
+
| name | coverage |
|
34
|
+
| lib/faked_project/framework_specific.rb | 75.0 % |
|
35
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
36
|
+
| lib/faked_project.rb | 100.0 % |
|
37
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
38
|
+
| spec/forking_spec.rb | 100.0 % |
|
39
|
+
| spec/meta_magic_spec.rb | 100.0 % |
|
40
|
+
| spec/some_class_spec.rb | 100.0 % |
|
41
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Running specs without simplecov configuration
|
5
|
+
|
6
|
+
Scenario: No config at all
|
7
|
+
When I successfully run `bundle exec rspec spec`
|
8
|
+
Then no coverage report should have been generated
|
9
|
+
|
10
|
+
Scenario: Configured, but not started
|
11
|
+
Given SimpleCov for RSpec is configured with:
|
12
|
+
"""
|
13
|
+
require 'simplecov'
|
14
|
+
SimpleCov.configure do
|
15
|
+
add_filter 'somefilter'
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
|
19
|
+
When I successfully run `bundle exec rspec spec`
|
20
|
+
Then no coverage report should have been generated
|
@@ -0,0 +1,70 @@
|
|
1
|
+
@test_unit @nocov
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
When code is wrapped in :nocov: comment blocks, it does not count
|
5
|
+
against the coverage numbers.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given SimpleCov for Test/Unit is configured with:
|
9
|
+
"""
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start 'test_frameworks'
|
12
|
+
"""
|
13
|
+
|
14
|
+
Scenario: Plain run with a nocov'd method
|
15
|
+
Given a file named "lib/faked_project/nocov.rb" with:
|
16
|
+
"""
|
17
|
+
class SourceCodeWithNocov
|
18
|
+
#:nocov:
|
19
|
+
def some_weird_code
|
20
|
+
never_reached
|
21
|
+
rescue => err
|
22
|
+
but no one cares about invalid ruby here
|
23
|
+
end
|
24
|
+
#:nocov:
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
|
28
|
+
When I open the coverage report generated with `bundle exec rake test`
|
29
|
+
|
30
|
+
Then I should see the source files:
|
31
|
+
| name | coverage |
|
32
|
+
| lib/faked_project.rb | 100.0 % |
|
33
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
34
|
+
| lib/faked_project/framework_specific.rb | 75.0 % |
|
35
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
36
|
+
| lib/faked_project/nocov.rb | 100.0 % |
|
37
|
+
|
38
|
+
And there should be 7 skipped lines in the source files
|
39
|
+
|
40
|
+
And the report should be based upon:
|
41
|
+
| Unit Tests |
|
42
|
+
|
43
|
+
Scenario: Number of spaces should not mix up nocov results
|
44
|
+
Given a file named "lib/faked_project/nocov.rb" with:
|
45
|
+
"""
|
46
|
+
class SourceCodeWithNocov
|
47
|
+
# :nocov:
|
48
|
+
def some_weird_code
|
49
|
+
never_reached
|
50
|
+
rescue => err
|
51
|
+
but no one cares about invalid ruby here
|
52
|
+
end
|
53
|
+
# :nocov:
|
54
|
+
end
|
55
|
+
"""
|
56
|
+
|
57
|
+
When I open the coverage report generated with `bundle exec rake test`
|
58
|
+
|
59
|
+
Then I should see the source files:
|
60
|
+
| name | coverage |
|
61
|
+
| lib/faked_project.rb | 100.0 % |
|
62
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
63
|
+
| lib/faked_project/framework_specific.rb | 75.0 % |
|
64
|
+
| lib/faked_project/meta_magic.rb | 100.0 % |
|
65
|
+
| lib/faked_project/nocov.rb | 100.0 % |
|
66
|
+
|
67
|
+
And there should be 7 skipped lines in the source files
|
68
|
+
|
69
|
+
And the report should be based upon:
|
70
|
+
| Unit Tests |
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module GroupHelpers
|
2
|
+
def available_groups
|
3
|
+
all("#content .file_list_container")
|
4
|
+
end
|
5
|
+
|
6
|
+
def available_source_files
|
7
|
+
all(".source_files .source_table")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
World(GroupHelpers)
|
11
|
+
|
12
|
+
Then /^I should see the groups:$/ do |table|
|
13
|
+
expected_groups = table.hashes
|
14
|
+
# Given group names should be the same number than those rendered in report
|
15
|
+
expect(expected_groups.count).to eq(available_groups.count)
|
16
|
+
|
17
|
+
# Verify each of the expected groups has a file list container and corresponding title and coverage number
|
18
|
+
# as well as the correct number of links to files.
|
19
|
+
expected_groups.each do |group|
|
20
|
+
with_scope "#content ##{group['name'].gsub(/[^a-z]/i, '')}.file_list_container" do
|
21
|
+
file_count_in_group = page.all("a.src_link").count
|
22
|
+
expect(file_count_in_group).to eq(group["files"].to_i)
|
23
|
+
|
24
|
+
with_scope "h2" do
|
25
|
+
expect(page).to have_content(group["name"])
|
26
|
+
expect(page).to have_content(group["coverage"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should see the source files:$/ do |table|
|
33
|
+
expected_files = table.hashes
|
34
|
+
expect(expected_files.length).to eq(available_source_files.count)
|
35
|
+
|
36
|
+
# Find all filenames and their coverage present in coverage report
|
37
|
+
files = available_source_files.map { |f| {"name" => f.find("h3").text, "coverage" => f.find("h4 > span").text} }
|
38
|
+
|
39
|
+
expect(files.sort_by { |hsh| hsh["name"] }).to eq(expected_files.sort_by { |hsh| hsh["name"] })
|
40
|
+
end
|
41
|
+
|
42
|
+
Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
|
43
|
+
expect(all(".source_table ol li.skipped").count).to eq(expected_count.to_i)
|
44
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Just a shortcut to make framework setup more readable
|
2
|
+
# The test project is using separate config files to avoid specifying all of
|
3
|
+
# test/spec_helper in the features every time.
|
4
|
+
Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
|
5
|
+
framework_dir = begin
|
6
|
+
case framework
|
7
|
+
when /RSpec/i
|
8
|
+
"spec"
|
9
|
+
when /Test\/Unit/i
|
10
|
+
"test"
|
11
|
+
when /Cucumber/i
|
12
|
+
"features/support"
|
13
|
+
else
|
14
|
+
raise ArgumentError, "Could not identify test framework #{framework}!"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
steps %(
|
19
|
+
Given a file named "#{framework_dir}/simplecov_config.rb" with:
|
20
|
+
"""
|
21
|
+
#{config_body}
|
22
|
+
"""
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
|
27
|
+
steps %(
|
28
|
+
When I successfully run `#{command}`
|
29
|
+
Then a coverage report should have been generated
|
30
|
+
When I open the coverage report
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
Then /^a coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
35
|
+
coverage_dir ||= "coverage"
|
36
|
+
steps %(
|
37
|
+
Then the output should contain "Coverage report generated"
|
38
|
+
And a directory named "#{coverage_dir}" should exist
|
39
|
+
And the following files should exist:
|
40
|
+
| #{coverage_dir}/index.html |
|
41
|
+
| #{coverage_dir}/.resultset.json |
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
46
|
+
coverage_dir ||= "coverage"
|
47
|
+
steps %(
|
48
|
+
Then the output should not contain "Coverage report generated"
|
49
|
+
And a directory named "#{coverage_dir}" should not exist
|
50
|
+
And the following files should not exist:
|
51
|
+
| #{coverage_dir}/index.html |
|
52
|
+
| #{coverage_dir}/.resultset.json |
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^the report should be based upon:$/ do |table|
|
57
|
+
frameworks = table.raw.flatten
|
58
|
+
steps %(
|
59
|
+
Then the output should contain "Coverage report generated for #{frameworks.join(', ')}"
|
60
|
+
And I should see "using #{frameworks.join(', ')}" within "#footer"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
# This is necessary to ensure timing-dependant tests like the merge timeout
|
65
|
+
# do not fail on powerful machines.
|
66
|
+
When /^I wait for (\d+) seconds$/ do |seconds|
|
67
|
+
sleep seconds.to_i
|
68
|
+
end
|