diff --git a/lib/rspec/github/formatter.rb b/lib/rspec/github/formatter.rb index 15c17c7..2db31f9 100644 --- a/lib/rspec/github/formatter.rb +++ b/lib/rspec/github/formatter.rb @@ -7,7 +7,7 @@ module RSpec module Github class Formatter < RSpec::Core::Formatters::BaseFormatter - RSpec::Core::Formatters.register self, :example_failed, :example_pending + RSpec::Core::Formatters.register self, :example_failed, :example_pending, :seed def example_failed(failure) notification = NotificationDecorator.new(failure) @@ -20,6 +20,12 @@ def example_pending(pending) output.puts "\n::warning file=#{notification.path},line=#{notification.line}::#{notification.annotation}" end + + def seed(notification) + return unless notification.seed_used? + + output.puts notification.fully_formatted + end end end end diff --git a/spec/rspec/github/formatter_spec.rb b/spec/rspec/github/formatter_spec.rb index f2c372a..d4928c5 100644 --- a/spec/rspec/github/formatter_spec.rb +++ b/spec/rspec/github/formatter_spec.rb @@ -137,4 +137,26 @@ end end end + + describe '#seed' do + before { formatter.seed(notification) } + + context 'when seed used' do + let(:notification) do + RSpec::Core::Notifications::SeedNotification.new(4242, true) + end + + it 'outputs the fully formatted seed notification' do + is_expected.to eq "\nRandomized with seed 4242\n" + end + end + + context 'when seed not used' do + let(:notification) do + RSpec::Core::Notifications::SeedNotification.new(nil, false) + end + + it { is_expected.to be_empty } + end + end end