diff --git a/lib/flatware/rspec.rb b/lib/flatware/rspec.rb index 7f5ed53..1683640 100644 --- a/lib/flatware/rspec.rb +++ b/lib/flatware/rspec.rb @@ -15,18 +15,19 @@ def extract_jobs_from_args(args, workers:) JobBuilder.new(args, workers: workers).jobs end - def run(job, _options = {}) - runner = ::RSpec::Core::Runner - def runner.trap_interrupt() end + def runner + ::RSpec::Core::Runner.tap do |runner| + def runner.trap_interrupt() end + end + end - profile_examples = ::RSpec.configuration.profile_examples - ::RSpec.reset - ::RSpec.configuration.profile_examples = profile_examples + def run(job, _options = []) ::RSpec.configuration.deprecation_stream = StringIO.new ::RSpec.configuration.output_stream = StringIO.new ::RSpec.configuration.add_formatter(Flatware::RSpec::Formatter) runner.run(Array(job), $stderr, $stdout) + ::RSpec.reset # prevents duplicate runs end end end