diff --git a/lib/mutant/rspec/killer.rb b/lib/mutant/rspec/killer.rb index de60cc21..2505b8d2 100644 --- a/lib/mutant/rspec/killer.rb +++ b/lib/mutant/rspec/killer.rb @@ -88,41 +88,51 @@ module Mutant strategy.example_groups end - # Instantiate and memoize RSpec reporter + # Choose and memoize RSpec reporter # # @return [RSpec::Core::Reporter] # # @api private # def reporter - rspec2? ? rspec_reporter.new : rspec_reporter.new(strategy.configuration) + if strategy.rspec2? + rspec2_reporter + else + rspec3_reporter + end end memoize :reporter, freezer: :noop + # Instantiate RSpec 2 reporter + # + # @return [RSpec::Core::Reporter] + # + # @api private + # + def rspec2_reporter + reporter_class.new + end + + # Instantiate RSpec 3 reporter + # + # @return [RSpec::Core::Reporter] + # + # @api private + # + def rspec3_reporter + reporter_class.new(strategy.configuration) + end + # Reporter class # # @return [Class] # # @api private # - def rspec_reporter + def reporter_class RSpec::Core::Reporter end - # Detect RSpec 2 - # - # @return [true] - # when RSpec 2 - # - # @return [false] - # otherwise - # - # @api private - # - def rspec2? - RSpec::Core::Version::STRING.start_with?('2.') - end - end # Killer end # Rspec end # Mutant diff --git a/lib/mutant/rspec/strategy.rb b/lib/mutant/rspec/strategy.rb index b7597d37..701d4533 100644 --- a/lib/mutant/rspec/strategy.rb +++ b/lib/mutant/rspec/strategy.rb @@ -46,6 +46,20 @@ module Mutant world.example_groups end + # Detect RSpec 2 + # + # @return [true] + # when RSpec 2 + # + # @return [false] + # otherwise + # + # @api private + # + def rspec2? + RSpec::Core::Version::STRING.start_with?('2.') + end + private # Return world @@ -67,7 +81,7 @@ module Mutant # def options options = RSpec::Core::ConfigurationOptions.new(%w(--fail-fast spec)) - options.parse_options + options.parse_options if rspec2? options end memoize :options, freezer: :noop diff --git a/spec/integration/mutant/rspec_spec.rb b/spec/integration/mutant/rspec_spec.rb index b7fa8ff1..6babd35d 100644 --- a/spec/integration/mutant/rspec_spec.rb +++ b/spec/integration/mutant/rspec_spec.rb @@ -11,6 +11,7 @@ describe Mutant, 'rspec integration' do Bundler.with_clean_env do Dir.chdir(TestApp.root) do Kernel.system("bundle install --gemfile=#{gemfile}") + ENV['BUNDLE_GEMFILE'] = gemfile example.run end end diff --git a/test_app/Gemfile.rspec2 b/test_app/Gemfile.rspec2 index 9123d6fe..c113ac0e 100644 --- a/test_app/Gemfile.rspec2 +++ b/test_app/Gemfile.rspec2 @@ -1 +1,2 @@ gem 'rspec', '~> 2.14.1' +gem 'mutant', path: '../.' diff --git a/test_app/Gemfile.rspec3 b/test_app/Gemfile.rspec3 index 72809c0f..9380bebb 100644 --- a/test_app/Gemfile.rspec3 +++ b/test_app/Gemfile.rspec3 @@ -1 +1,2 @@ gem 'rspec', '~> 3.0.0.beta2' +gem 'mutant', path: '../.'