simplecov 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -7
  2. data/.rspec +3 -1
  3. data/.rubocop.yml +6 -5
  4. data/CHANGELOG.md +16 -2
  5. data/Gemfile +14 -14
  6. data/README.md +28 -12
  7. data/Rakefile +5 -8
  8. data/features/config_formatters.feature +1 -1
  9. data/features/config_tracked_files.feature +29 -0
  10. data/features/step_definitions/transformers.rb +1 -1
  11. data/features/support/env.rb +6 -3
  12. data/lib/simplecov.rb +19 -2
  13. data/lib/simplecov/configuration.rb +24 -4
  14. data/lib/simplecov/defaults.rb +28 -5
  15. data/lib/simplecov/file_list.rb +11 -0
  16. data/lib/simplecov/filter.rb +1 -1
  17. data/lib/simplecov/formatter/multi_formatter.rb +17 -13
  18. data/lib/simplecov/result.rb +1 -1
  19. data/lib/simplecov/source_file.rb +6 -3
  20. data/lib/simplecov/version.rb +1 -1
  21. data/spec/1_8_fallbacks_spec.rb +29 -0
  22. data/spec/command_guesser_spec.rb +46 -0
  23. data/spec/deleted_source_spec.rb +12 -0
  24. data/{test → spec}/faked_project/Gemfile +0 -0
  25. data/{test → spec}/faked_project/Rakefile +0 -0
  26. data/{test → spec}/faked_project/cucumber.yml +0 -0
  27. data/{test → spec}/faked_project/features/step_definitions/my_steps.rb +0 -0
  28. data/{test → spec}/faked_project/features/support/env.rb +0 -0
  29. data/{test → spec}/faked_project/features/test_stuff.feature +0 -0
  30. data/{test → spec}/faked_project/lib/faked_project.rb +1 -1
  31. data/{test → spec}/faked_project/lib/faked_project/framework_specific.rb +0 -0
  32. data/{test → spec}/faked_project/lib/faked_project/meta_magic.rb +0 -0
  33. data/{test → spec}/faked_project/lib/faked_project/some_class.rb +0 -0
  34. data/spec/faked_project/lib/faked_project/untested_class.rb +11 -0
  35. data/{test → spec}/faked_project/spec/faked_spec.rb +0 -0
  36. data/{test → spec}/faked_project/spec/forking_spec.rb +0 -0
  37. data/{test → spec}/faked_project/spec/meta_magic_spec.rb +0 -0
  38. data/{test → spec}/faked_project/spec/some_class_spec.rb +0 -0
  39. data/{test → spec}/faked_project/spec/spec_helper.rb +0 -0
  40. data/{test → spec}/faked_project/test/faked_test.rb +0 -0
  41. data/{test → spec}/faked_project/test/meta_magic_test.rb +0 -0
  42. data/{test → spec}/faked_project/test/some_class_test.rb +0 -0
  43. data/{test → spec}/faked_project/test/test_helper.rb +0 -0
  44. data/spec/file_list_spec.rb +48 -0
  45. data/spec/filters_spec.rb +96 -0
  46. data/{test → spec}/fixtures/app/controllers/sample_controller.rb +0 -0
  47. data/{test → spec}/fixtures/app/models/user.rb +0 -0
  48. data/{test → spec}/fixtures/deleted_source_sample.rb +0 -0
  49. data/{test → spec}/fixtures/frameworks/rspec_bad.rb +0 -0
  50. data/{test → spec}/fixtures/frameworks/rspec_good.rb +0 -0
  51. data/{test → spec}/fixtures/frameworks/testunit_bad.rb +0 -0
  52. data/{test → spec}/fixtures/frameworks/testunit_good.rb +0 -0
  53. data/{test → spec}/fixtures/iso-8859.rb +0 -0
  54. data/{test → spec}/fixtures/resultset1.rb +0 -0
  55. data/{test → spec}/fixtures/resultset2.rb +0 -0
  56. data/{test → spec}/fixtures/sample.rb +0 -0
  57. data/{test → spec}/fixtures/utf-8.rb +0 -0
  58. data/{test → spec}/helper.rb +3 -7
  59. data/spec/merge_helpers_spec.rb +108 -0
  60. data/spec/result_spec.rb +207 -0
  61. data/spec/return_codes_spec.rb +37 -0
  62. data/spec/source_file_line_spec.rb +153 -0
  63. data/spec/source_file_spec.rb +75 -0
  64. metadata +163 -149
  65. data/test/shoulda_macros.rb +0 -19
  66. data/test/test_1_8_fallbacks.rb +0 -31
  67. data/test/test_command_guesser.rb +0 -19
  68. data/test/test_deleted_source.rb +0 -14
  69. data/test/test_file_list.rb +0 -23
  70. data/test/test_filters.rb +0 -94
  71. data/test/test_merge_helpers.rb +0 -112
  72. data/test/test_result.rb +0 -175
  73. data/test/test_return_codes.rb +0 -41
  74. data/test/test_source_file.rb +0 -73
  75. data/test/test_source_file_line.rb +0 -106
@@ -1,41 +0,0 @@
1
- require "helper"
2
-
3
- # Make sure that exit codes of tests are propagated properly when using
4
- # simplecov. See github issue #5
5
- class TestReturnCodes < Minitest::Test
6
- def self.test_order
7
- :alpha
8
- end
9
-
10
- context "Inside fixtures/frameworks" do
11
- setup do
12
- @current_dir = Dir.getwd
13
- Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks"))
14
- FileUtils.rm_rf("./coverage")
15
- end
16
-
17
- should "have return code 0 when running testunit_good.rb" do
18
- `ruby testunit_good.rb`
19
- assert_equal 0, $?.exitstatus
20
- end
21
-
22
- should "have return code 0 when running rspec_good.rb" do
23
- `rspec rspec_good.rb`
24
- assert_equal 0, $?.exitstatus
25
- end
26
-
27
- should "have non-0 return code when running testunit_bad.rb" do
28
- `ruby testunit_bad.rb`
29
- refute_equal 0, $?.exitstatus
30
- end
31
-
32
- should "have return code 1 when running rspec_bad.rb" do
33
- `rspec rspec_bad.rb`
34
- refute_equal 0, $?.exitstatus
35
- end
36
-
37
- teardown do
38
- Dir.chdir(@current_dir)
39
- end
40
- end
41
- end
@@ -1,73 +0,0 @@
1
- require "helper"
2
-
3
- class TestSourceFile < Minitest::Test
4
- COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil]
5
- context "A source file initialized with some coverage data" do
6
- setup do
7
- @source_file = SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
8
- end
9
-
10
- should "have a filename" do
11
- assert @source_file.filename
12
- end
13
-
14
- should "have source equal to src" do
15
- assert_equal @source_file.source, @source_file.src
16
- end
17
-
18
- should "have source_lines equal to lines" do
19
- assert_equal @source_file.source_lines, @source_file.lines
20
- end
21
-
22
- should "have 16 source lines" do
23
- assert_equal 16, @source_file.lines.count
24
- end
25
-
26
- should "have all source lines of type SimpleCov::SourceFile::Line" do
27
- assert @source_file.lines.all? { |l| l.instance_of?(SimpleCov::SourceFile::Line) }
28
- end
29
-
30
- should "have 'class Foo' as line(2).source" do
31
- assert_equal "class Foo\n", @source_file.line(2).source
32
- end
33
-
34
- should "return lines number 2, 3, 4, 7 for covered_lines" do
35
- assert_equal [2, 3, 4, 7], @source_file.covered_lines.map(&:line)
36
- end
37
-
38
- should "return lines number 8 for missed_lines" do
39
- assert_equal [8], @source_file.missed_lines.map(&:line)
40
- end
41
-
42
- should "return lines number 1, 5, 6, 9, 10, 11, 15, 16 for never_lines" do
43
- assert_equal [1, 5, 6, 9, 10, 11, 15, 16], @source_file.never_lines.map(&:line)
44
- end
45
-
46
- should "return line numbers 12, 13, 14 for skipped_lines" do
47
- assert_equal [12, 13, 14], @source_file.skipped_lines.map(&:line)
48
- end
49
-
50
- should "have 80% covered_percent" do
51
- assert_equal 80.0, @source_file.covered_percent
52
- end
53
- end
54
-
55
- context "Simulating potential Ruby 1.9 defect -- see Issue #56" do
56
- setup do
57
- @source_file = SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB + [nil])
58
- end
59
-
60
- should "have 16 source lines regardless of extra data in coverage array" do
61
- # Do not litter test output with known warning
62
- capture_stderr { assert_equal 16, @source_file.lines.count }
63
- end
64
-
65
- should "print a warning to stderr if coverage array contains more data than lines in the file" do
66
- captured_output = capture_stderr do
67
- @source_file.lines
68
- end
69
-
70
- assert_match(/^Warning: coverage data provided/, captured_output)
71
- end
72
- end
73
- end if SimpleCov.usable?
@@ -1,106 +0,0 @@
1
- require "helper"
2
-
3
- class TestSourceFileLine < Minitest::Test
4
- context "A source line" do
5
- setup do
6
- @line = SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
7
- end
8
- subject { @line }
9
-
10
- should 'return "# the ruby source" as src' do
11
- assert_equal "# the ruby source", @line.src
12
- end
13
-
14
- should "return the same for source as for src" do
15
- assert_equal @line.src, @line.source
16
- end
17
-
18
- should "have line number 5" do
19
- assert_equal 5, @line.line_number
20
- end
21
-
22
- should "have equal line_number, line and number" do
23
- assert_equal @line.line_number, @line.line
24
- assert_equal @line.line_number, @line.number
25
- end
26
-
27
- context "flagged as skipped!" do
28
- setup { @line.skipped! }
29
-
30
- should_not_be :covered?
31
- should_be :skipped?
32
- should_not_be :missed?
33
- should_not_be :never?
34
- should_have :status, "skipped"
35
- end
36
- end
37
-
38
- context "A source line with coverage" do
39
- setup do
40
- @line = SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
41
- end
42
- subject { @line }
43
-
44
- should "have coverage of 3" do
45
- assert_equal 3, @line.coverage
46
- end
47
-
48
- should_be :covered?
49
- should_not_be :skipped?
50
- should_not_be :missed?
51
- should_not_be :never?
52
- should_have :status, "covered"
53
- end
54
-
55
- context "A source line without coverage" do
56
- setup do
57
- @line = SimpleCov::SourceFile::Line.new("# the ruby source", 5, 0)
58
- end
59
- subject { @line }
60
-
61
- should "have coverage of 0" do
62
- assert_equal 0, @line.coverage
63
- end
64
-
65
- should_not_be :covered?
66
- should_not_be :skipped?
67
- should_be :missed?
68
- should_not_be :never?
69
- should_have :status, "missed"
70
- end
71
-
72
- context "A source line with no code" do
73
- setup do
74
- @line = SimpleCov::SourceFile::Line.new("# the ruby source", 5, nil)
75
- end
76
- subject { @line }
77
-
78
- should "have nil coverage" do
79
- assert_nil @line.coverage
80
- end
81
-
82
- should_not_be :covered?
83
- should_not_be :skipped?
84
- should_not_be :missed?
85
- should_be :never?
86
- should_have :status, "never"
87
- end
88
-
89
- should "raise ArgumentError when initialized with invalid src" do
90
- assert_raises ArgumentError do
91
- SimpleCov::SourceFile::Line.new(:symbol, 5, 3)
92
- end
93
- end
94
-
95
- should "raise ArgumentError when initialized with invalid line_number" do
96
- assert_raises ArgumentError do
97
- SimpleCov::SourceFile::Line.new("some source", "five", 3)
98
- end
99
- end
100
-
101
- should "raise ArgumentError when initialized with invalid coverage" do
102
- assert_raises ArgumentError do
103
- SimpleCov::SourceFile::Line.new("some source", 5, "three")
104
- end
105
- end
106
- end if SimpleCov.usable?