Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compatibility with RSpec 2 #908

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking Changes

- Drop support for RSpec 2.

### Added

### Fixed
Expand Down
18 changes: 5 additions & 13 deletions lib/parallel_tests/rspec/failures_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@
require 'parallel_tests/rspec/runner'

class ParallelTests::RSpec::FailuresLogger < ParallelTests::RSpec::LoggerBase
if RSPEC_2
def dump_failures(*args); end
else
RSpec::Core::Formatters.register self, :dump_summary
end
RSpec::Core::Formatters.register(self, :dump_summary)

def dump_summary(*args)
lock_output do
if RSPEC_2
dump_commands_to_rerun_failed_examples
else
notification = args.first
unless notification.failed_examples.empty?
colorizer = ::RSpec::Core::Formatters::ConsoleCodes
output.puts notification.colorized_rerun_commands(colorizer)
end
notification = args.first
unless notification.failed_examples.empty?
colorizer = ::RSpec::Core::Formatters::ConsoleCodes
output.puts notification.colorized_rerun_commands(colorizer)
end
end
@output.flush
Expand Down
2 changes: 0 additions & 2 deletions lib/parallel_tests/rspec/logger_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module RSpec
require 'rspec/core/formatters/base_text_formatter'

class ParallelTests::RSpec::LoggerBase < RSpec::Core::Formatters::BaseTextFormatter
RSPEC_2 = RSpec::Core::Version::STRING.start_with?('2')

def initialize(*args)
super

Expand Down
5 changes: 2 additions & 3 deletions lib/parallel_tests/rspec/runtime_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(*args)
@group_nesting = 0
end

RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished, :start_dump unless RSPEC_2
RSpec::Core::Formatters.register(self, :example_group_started, :example_group_finished, :start_dump)

def example_group_started(example_group)
@time = ParallelTests.now if @group_nesting == 0
Expand All @@ -20,8 +20,7 @@ def example_group_started(example_group)
def example_group_finished(notification)
@group_nesting -= 1
if @group_nesting == 0
path = (RSPEC_2 ? notification.file_path : notification.group.file_path)
@example_times[path] += ParallelTests.now - @time
@example_times[notification.group.file_path] += ParallelTests.now - @time
end
super if defined?(super)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/parallel_tests/rspec/summary_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'parallel_tests/rspec/failures_logger'

class ParallelTests::RSpec::SummaryLogger < ParallelTests::RSpec::LoggerBase
RSpec::Core::Formatters.register self, :dump_failures unless RSPEC_2
RSpec::Core::Formatters.register(self, :dump_failures)

def dump_failures(*args)
lock_output { super }
Expand Down
2 changes: 1 addition & 1 deletion spec/parallel_tests/rspec/runtime_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def log_for_a_file(_options = {})
end

example = double(file_path: "#{Dir.pwd}/spec/foo.rb")
example = double(group: example) unless ParallelTests::RSpec::RuntimeLogger::RSPEC_2
example = double(group: example)

logger.example_group_started example
logger.example_group_finished example
Expand Down
Loading