Fix non-working integration test, fix broken strategy

This commit is contained in:
Andrey Savchenko 2014-03-04 22:10:23 +02:00
parent d4b232b3a5
commit e4f11543c8
5 changed files with 45 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1 +1,2 @@
gem 'rspec', '~> 2.14.1'
gem 'mutant', path: '../.'

View file

@ -1 +1,2 @@
gem 'rspec', '~> 3.0.0.beta2'
gem 'mutant', path: '../.'