simplecov 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -7
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +69 -0
  4. data/CHANGELOG.md +39 -22
  5. data/Gemfile +16 -15
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +183 -178
  8. data/Rakefile +16 -7
  9. data/doc/alternate-formatters.md +36 -0
  10. data/doc/commercial-services.md +20 -0
  11. data/doc/editor-integration.md +13 -0
  12. data/features/rspec_basic.feature +3 -2
  13. data/features/rspec_groups_and_filters_complex.feature +2 -0
  14. data/features/rspec_groups_using_filter_class.feature +3 -2
  15. data/features/step_definitions/html_steps.rb +6 -7
  16. data/features/step_definitions/simplecov_steps.rb +18 -16
  17. data/features/step_definitions/transformers.rb +2 -2
  18. data/features/step_definitions/web_steps.rb +4 -4
  19. data/features/support/env.rb +17 -15
  20. data/lib/simplecov.rb +35 -24
  21. data/lib/simplecov/command_guesser.rb +33 -34
  22. data/lib/simplecov/configuration.rb +238 -234
  23. data/lib/simplecov/defaults.rb +37 -36
  24. data/lib/simplecov/exit_codes.rb +7 -5
  25. data/lib/simplecov/file_list.rb +38 -36
  26. data/lib/simplecov/filter.rb +12 -2
  27. data/lib/simplecov/formatter.rb +2 -2
  28. data/lib/simplecov/formatter/simple_formatter.rb +1 -1
  29. data/lib/simplecov/jruby_fix.rb +4 -4
  30. data/lib/simplecov/last_run.rb +15 -13
  31. data/lib/simplecov/merge_helpers.rb +26 -27
  32. data/lib/simplecov/no_defaults.rb +2 -2
  33. data/lib/simplecov/profiles.rb +21 -19
  34. data/lib/simplecov/railtie.rb +1 -1
  35. data/lib/simplecov/railties/tasks.rake +7 -7
  36. data/lib/simplecov/result.rb +5 -5
  37. data/lib/simplecov/result_merger.rb +65 -62
  38. data/lib/simplecov/source_file.rb +23 -24
  39. data/lib/simplecov/version.rb +20 -1
  40. data/simplecov.gemspec +14 -12
  41. data/test/faked_project/Gemfile +5 -5
  42. data/test/faked_project/Rakefile +4 -4
  43. data/test/faked_project/features/step_definitions/my_steps.rb +3 -4
  44. data/test/faked_project/features/support/env.rb +5 -5
  45. data/test/faked_project/lib/faked_project.rb +1 -1
  46. data/test/faked_project/lib/faked_project/some_class.rb +3 -4
  47. data/test/faked_project/spec/faked_spec.rb +2 -2
  48. data/test/faked_project/spec/forking_spec.rb +7 -0
  49. data/test/faked_project/spec/meta_magic_spec.rb +1 -1
  50. data/test/faked_project/spec/some_class_spec.rb +3 -3
  51. data/test/faked_project/spec/spec_helper.rb +4 -8
  52. data/test/faked_project/test/faked_test.rb +2 -2
  53. data/test/faked_project/test/meta_magic_test.rb +1 -1
  54. data/test/faked_project/test/some_class_test.rb +3 -3
  55. data/test/faked_project/test/test_helper.rb +5 -9
  56. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  57. data/test/fixtures/app/models/user.rb +1 -1
  58. data/test/fixtures/deleted_source_sample.rb +3 -3
  59. data/test/fixtures/frameworks/rspec_bad.rb +4 -4
  60. data/test/fixtures/frameworks/rspec_good.rb +4 -4
  61. data/test/fixtures/frameworks/testunit_bad.rb +3 -3
  62. data/test/fixtures/frameworks/testunit_good.rb +3 -3
  63. data/test/fixtures/resultset2.rb +0 -1
  64. data/test/fixtures/sample.rb +1 -1
  65. data/test/fixtures/utf-8.rb +1 -1
  66. data/test/helper.rb +8 -8
  67. data/test/test_1_8_fallbacks.rb +6 -6
  68. data/test/test_command_guesser.rb +7 -7
  69. data/test/test_deleted_source.rb +2 -2
  70. data/test/test_file_list.rb +8 -6
  71. data/test/test_filters.rb +29 -13
  72. data/test/test_merge_helpers.rb +26 -23
  73. data/test/test_result.rb +32 -23
  74. data/test/test_return_codes.rb +3 -3
  75. data/test/test_source_file.rb +4 -4
  76. data/test/test_source_file_line.rb +13 -13
  77. metadata +145 -63
  78. data/lib/simplecov/json.rb +0 -27
@@ -1,12 +1,12 @@
1
- require 'bundler/setup'
1
+ require "bundler/setup"
2
2
 
3
3
  # We're injecting simplecov_config via aruba in cucumber here
4
4
  # depending on what the test case is...
5
5
  begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
6
+ require File.join(File.dirname(__FILE__), "simplecov_config")
7
+ rescue LoadError
8
8
  $stderr.puts "No SimpleCov config file found!"
9
9
  end
10
10
 
11
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../lib'))
12
- require 'faked_project'
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../../lib"))
12
+ require "faked_project"
@@ -4,7 +4,7 @@ class FakedProject
4
4
  end
5
5
  end
6
6
 
7
- Dir[File.join(File.dirname(__FILE__), 'faked_project/*.rb')].each do |file|
7
+ Dir[File.join(File.dirname(__FILE__), "faked_project/*.rb")].each do |file|
8
8
  require file # Require all source files in project dynamically so we can inject some stuff depending on test situation
9
9
  end
10
10
 
@@ -14,14 +14,13 @@ class SomeClass
14
14
  if item == label
15
15
  return true
16
16
  else
17
- raise "Item does not match label"
17
+ fail "Item does not match label"
18
18
  end
19
-
20
- rescue => err
19
+ rescue
21
20
  false
22
21
  end
23
22
 
24
- private
23
+ private
25
24
 
26
25
  def uncovered
27
26
  "private method"
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe FakedProject do
4
4
  it "should return proper foo" do
5
- expect(FakedProject.foo).to eq('bar')
5
+ expect(FakedProject.foo).to eq("bar")
6
6
  end
7
7
 
8
8
  it "should test it's framework specific method" do
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe "forking" do
4
+ it do
5
+ Process.waitpid(Kernel.fork {})
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe FakedProject do
4
4
  it "should have added a class method to FakedProject" do
@@ -1,13 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe SomeClass do
4
4
  subject { SomeClass.new("foo") }
5
5
 
6
6
  it "should be reversible" do
7
- expect(subject.reverse).to eq('oof')
7
+ expect(subject.reverse).to eq("oof")
8
8
  end
9
9
 
10
10
  it "should compare with 'foo'" do
11
- expect(subject.compare_with('foo')).to be true
11
+ expect(subject.compare_with("foo")).to be true
12
12
  end
13
13
  end
@@ -1,15 +1,11 @@
1
- require 'bundler/setup'
1
+ require "bundler/setup"
2
2
 
3
3
  # We're injecting simplecov_config via aruba in cucumber here
4
4
  # depending on what the test case is...
5
5
  begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
6
+ require File.join(File.dirname(__FILE__), "simplecov_config")
7
+ rescue LoadError
8
8
  $stderr.puts "No SimpleCov config file found!"
9
9
  end
10
10
 
11
- require 'faked_project'
12
-
13
- RSpec.configure do |config|
14
- # some (optional) config here
15
- end
11
+ require "faked_project"
@@ -1,8 +1,8 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class FakedTest < Test::Unit::TestCase
4
4
  def test_something
5
- assert_equal 'bar', FakedProject.foo
5
+ assert_equal "bar", FakedProject.foo
6
6
  end
7
7
 
8
8
  def test_framework_specific
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class MetaMagicTest < Test::Unit::TestCase
4
4
  def test_class_methods
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class SomeClassTest < Test::Unit::TestCase
4
4
  def setup
@@ -6,10 +6,10 @@ class SomeClassTest < Test::Unit::TestCase
6
6
  end
7
7
 
8
8
  def test_reverse
9
- assert_equal 'oof', @instance.reverse
9
+ assert_equal "oof", @instance.reverse
10
10
  end
11
11
 
12
12
  def test_comparison
13
- assert @instance.compare_with('foo')
13
+ assert @instance.compare_with("foo")
14
14
  end
15
15
  end
@@ -1,16 +1,12 @@
1
- require 'bundler/setup'
1
+ require "bundler/setup"
2
2
 
3
3
  # We're injecting simplecov_config via aruba in cucumber here
4
4
  # depending on what the test case is...
5
5
  begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
6
+ require File.join(File.dirname(__FILE__), "simplecov_config")
7
+ rescue LoadError
8
8
  $stderr.puts "No SimpleCov config file found!"
9
9
  end
10
10
 
11
- require 'faked_project'
12
-
13
- require 'test/unit'
14
-
15
- class Test::Unit::TestCase
16
- end
11
+ require "faked_project"
12
+ require "test/unit"
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,5 +1,5 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
2
- require 'lib/simplecov'
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", ".."))
2
+ require "lib/simplecov"
3
3
  SimpleCov.start { command_name "Test" }
4
4
 
5
5
  dir = File.expand_path(File.dirname(__FILE__))
@@ -12,4 +12,4 @@ code = %{
12
12
  File.open(file, "w") { |f| f.print code }
13
13
  load file
14
14
  File.unlink file
15
- raise unless kill_the_buddha(3) == 27
15
+ fail unless kill_the_buddha(3) == 27
@@ -1,8 +1,8 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
2
+ require "lib/simplecov"
3
+ require "rspec"
4
4
  SimpleCov.start
5
- describe 'exit status' do
5
+ describe "exit status" do
6
6
  it "should exit with a non-zero exit status when assertion fails" do
7
7
  expect(1).to eq(2)
8
8
  end
@@ -1,8 +1,8 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
2
+ require "lib/simplecov"
3
+ require "rspec"
4
4
  SimpleCov.start
5
- describe 'exit status' do
5
+ describe "exit status" do
6
6
  it "should exit with a zero exit status when assertion fails" do
7
7
  expect(1).to eq(1)
8
8
  end
@@ -1,7 +1,7 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
2
+ require "lib/simplecov"
3
3
  SimpleCov.start
4
- require 'test/unit'
4
+ require "test/unit"
5
5
  class FooTest < Test::Unit::TestCase
6
6
  def test_foo
7
7
  assert false
@@ -1,7 +1,7 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
2
+ require "lib/simplecov"
3
3
  SimpleCov.start
4
- require 'test/unit'
4
+ require "test/unit"
5
5
  class FooTest < Test::Unit::TestCase
6
6
  def test_foo
7
7
  assert true
@@ -2,4 +2,3 @@
2
2
  class Resultset
3
3
  VERSION = 2
4
4
  end
5
-
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,3 +1,3 @@
1
1
  # encoding: utf-8
2
2
 
3
- puts '135°C'
3
+ puts "135°C"
@@ -1,19 +1,19 @@
1
- require 'bundler/setup'
2
- require 'simplecov'
3
- require 'minitest/autorun'
4
- require 'shoulda'
1
+ require "bundler/setup"
2
+ require "simplecov"
3
+ require "minitest/autorun"
4
+ require "shoulda"
5
5
 
6
- SimpleCov.coverage_dir('tmp/coverage')
6
+ SimpleCov.coverage_dir("tmp/coverage")
7
7
 
8
8
  def source_fixture(filename)
9
- File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
9
+ File.expand_path(File.join(File.dirname(__FILE__), "fixtures", filename))
10
10
  end
11
11
 
12
- require 'shoulda_macros'
12
+ require "shoulda_macros"
13
13
  Minitest::Test.send :extend, ShouldaMacros
14
14
 
15
15
  # Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
16
- require 'stringio'
16
+ require "stringio"
17
17
 
18
18
  def capture_stderr
19
19
  # The output stream must be an IO-like object. In this case we capture it in
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  # Tests that verify that on 1.8 versions of ruby, simplecov simply
4
4
  # does not launch and does not cause errors on the way
@@ -12,20 +12,20 @@ class Test18FallBacks < Minitest::Test
12
12
  end
13
13
 
14
14
  should "return false when calling SimpleCov.start with a block" do
15
- assert_equal false, SimpleCov.start { raise "Shouldn't reach this!?" }
15
+ assert_equal false, SimpleCov.start { fail "Shouldn't reach this!?" }
16
16
  end
17
17
 
18
18
  should "return false when calling SimpleCov.configure with a block" do
19
- assert_equal false, SimpleCov.configure { raise "Shouldn't reach this!?" }
19
+ assert_equal false, SimpleCov.configure { fail "Shouldn't reach this!?" }
20
20
  end
21
21
 
22
22
  should "allow to define a profile" do
23
23
  begin
24
- SimpleCov.profiles.define 'testprofile' do
25
- add_filter '/config/'
24
+ SimpleCov.profiles.define "testprofile" do
25
+ add_filter "/config/"
26
26
  end
27
27
  rescue => err
28
28
  assert false, "Profile definition should have been fine, but raised #{err}"
29
29
  end
30
30
  end
31
- end if RUBY_VERSION.start_with? '1.8'
31
+ end if RUBY_VERSION.start_with? "1.8"
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  class TestCommandGuesser < Minitest::Test
4
4
  def self.should_guess_command_name(expectation, *argv)
@@ -10,10 +10,10 @@ class TestCommandGuesser < Minitest::Test
10
10
  end
11
11
  end
12
12
 
13
- should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb', 'test/{models,helpers,unit}/**/*_test.rb'
14
- should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb', 'test/{controllers,mailers,functional}/**/*_test.rb'
15
- should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb', 'test/integration/**/*_test.rb'
16
- should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
17
- should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
18
- should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined!
13
+ should_guess_command_name "Unit Tests", "/some/path/test/units/foo_bar_test.rb", "test/units/foo.rb", "test/foo.rb", "test/{models,helpers,unit}/**/*_test.rb"
14
+ should_guess_command_name "Functional Tests", "/some/path/test/functional/foo_bar_controller_test.rb", "test/{controllers,mailers,functional}/**/*_test.rb"
15
+ should_guess_command_name "Integration Tests", "/some/path/test/integration/foo_bar_controller_test.rb", "test/integration/**/*_test.rb"
16
+ should_guess_command_name "Cucumber Features", "features", "cucumber", "cucumber features"
17
+ should_guess_command_name "RSpec", "/some/path/spec/foo.rb"
18
+ should_guess_command_name "Unit Tests", "some_arbitrary_command with arguments" # Because Test::Unit const is defined!
19
19
  end if SimpleCov.usable?
@@ -1,11 +1,11 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  # Test to verify correct handling of deleted files,
4
4
  # see issue #9 on github
5
5
  class TestDeletedSource < Minitest::Test
6
6
  context "A source file which is subsequently deleted" do
7
7
  should "not cause an error" do
8
- Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures')) do
8
+ Dir.chdir(File.join(File.dirname(__FILE__), "fixtures")) do
9
9
  `ruby deleted_source_sample.rb`
10
10
  assert_equal 0, $?.exitstatus
11
11
  end
@@ -1,11 +1,13 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  class TestFileList < Minitest::Test
4
4
  context "With a file list from a result" do
5
5
  setup do
6
- original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
7
- source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
8
- source_fixture('app/controllers/sample_controller.rb') => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]}
6
+ original_result = {
7
+ source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
8
+ source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
9
+ source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil],
10
+ }
9
11
  @file_list = SimpleCov::Result.new(original_result).files
10
12
  end
11
13
 
@@ -15,7 +17,7 @@ class TestFileList < Minitest::Test
15
17
  should("have 14 lines_of_code") { assert_equal 14, @file_list.lines_of_code }
16
18
  should("have 3 skipped_lines") { assert_equal 3, @file_list.skipped_lines }
17
19
 
18
- should("have correct covered_percent") { assert_equal 100.0*11/14, @file_list.covered_percent }
19
- should("have correct covered_strength") { assert_equal 13.to_f/14, @file_list.covered_strength }
20
+ should("have correct covered_percent") { assert_equal 100.0 * 11 / 14, @file_list.covered_percent }
21
+ should("have correct covered_strength") { assert_equal 13.to_f / 14, @file_list.covered_strength }
20
22
  end
21
23
  end if SimpleCov.usable?
@@ -1,44 +1,60 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  class TestFilters < Minitest::Test
4
4
  context "A source file initialized with some coverage data" do
5
5
  setup do
6
- @source_file = SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
6
+ @source_file = SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
7
7
  end
8
8
 
9
9
  should "not match a new SimpleCov::StringFilter 'foobar'" do
10
- assert !SimpleCov::StringFilter.new('foobar').matches?(@source_file)
10
+ assert !SimpleCov::StringFilter.new("foobar").matches?(@source_file)
11
11
  end
12
12
 
13
13
  should "not match a new SimpleCov::StringFilter 'some/path'" do
14
- assert !SimpleCov::StringFilter.new('some/path').matches?(@source_file)
14
+ assert !SimpleCov::StringFilter.new("some/path").matches?(@source_file)
15
15
  end
16
16
 
17
17
  should "match a new SimpleCov::StringFilter 'test/fixtures'" do
18
- assert SimpleCov::StringFilter.new('test/fixtures').matches?(@source_file)
18
+ assert SimpleCov::StringFilter.new("test/fixtures").matches?(@source_file)
19
19
  end
20
20
 
21
21
  should "match a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do
22
- assert SimpleCov::StringFilter.new('test/fixtures/sample.rb').matches?(@source_file)
22
+ assert SimpleCov::StringFilter.new("test/fixtures/sample.rb").matches?(@source_file)
23
23
  end
24
24
 
25
25
  should "match a new SimpleCov::StringFilter 'sample.rb'" do
26
- assert SimpleCov::StringFilter.new('sample.rb').matches?(@source_file)
26
+ assert SimpleCov::StringFilter.new("sample.rb").matches?(@source_file)
27
27
  end
28
28
 
29
29
  should "not match a new SimpleCov::BlockFilter that is not applicable" do
30
- assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).matches?(@source_file)
30
+ assert !SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "foo.rb" }).matches?(@source_file)
31
31
  end
32
32
 
33
33
  should "match a new SimpleCov::BlockFilter that is applicable" do
34
- assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).matches?(@source_file)
34
+ assert SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "sample.rb" }).matches?(@source_file)
35
+ end
36
+
37
+ should "match a new SimpleCov::ArrayFilter when 'sample.rb' is passed as array" do
38
+ assert SimpleCov::ArrayFilter.new(["sample.rb"]).matches?(@source_file)
39
+ end
40
+
41
+ should "not match a new SimpleCov::ArrayFilter when a file path different than 'sample.rb' is passed as array" do
42
+ assert !SimpleCov::ArrayFilter.new(["other_file.rb"]).matches?(@source_file)
43
+ end
44
+
45
+ should "match a new SimpleCov::ArrayFilter when two file paths including 'sample.rb' are passed as array" do
46
+ assert SimpleCov::ArrayFilter.new(["sample.rb", "other_file.rb"]).matches?(@source_file)
35
47
  end
36
48
  end
37
49
 
38
50
  context "with no filters set up and a basic source file in an array" do
39
51
  setup do
40
- SimpleCov.filters = []
41
- @files = [SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])]
52
+ @prev_filters, SimpleCov.filters = SimpleCov.filters, []
53
+ @files = [SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])]
54
+ end
55
+
56
+ teardown do
57
+ SimpleCov.filters = @prev_filters
42
58
  end
43
59
 
44
60
  should "return 0 items after executing SimpleCov.filtered on files when using a 'sample' string filter" do
@@ -57,14 +73,14 @@ class TestFilters < Minitest::Test
57
73
  end
58
74
 
59
75
  should "return 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do
60
- SimpleCov.add_filter do |src_file|
76
+ SimpleCov.add_filter do
61
77
  true
62
78
  end
63
79
  assert_equal 0, SimpleCov.filtered(@files).count
64
80
  end
65
81
 
66
82
  should "return 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do
67
- SimpleCov.add_filter do |src_file|
83
+ SimpleCov.add_filter do
68
84
  false
69
85
  end
70
86
  assert_equal 1, SimpleCov.filtered(@files).count