Skip to content

Conversation

@JuanitoFatas
Copy link
Member

@JuanitoFatas JuanitoFatas commented Apr 22, 2021

Paired with @matthewd.

@matthewd and I had this originally inside the before(:suite) block:

config.before(:suite) do
  if config.formatters.empty?
    config.add_formatter config.default_formatter
  end
  config.add_formatter RSpec::Buildkite::Insights::Reporter
end

but actually I found that in before(:suite), there are always config.formatters, so it is not necessary to add the default_formatter (those 3 if lines).

The problem of adding our reporter before the before(:suite) is that it is too early. The RSpec.config.formatters will be:

[RSpec::Buildkite::Insights::Reporter, RSpec::Core::Formatters::DeprecationFormatter, RSpec::Core::Formatters::FallbackMessageFormatter]

and RSpec does not do the magic of adding a doc formatter because it sees we already got a RSpec::Buildkite::Insights::Reporter and think it can report output.

While adding our reporter inside the before(:suite). The RSpec.config.formatters will be:

[RSpec::Core::Formatters::DocumentationFormatter, RSpec::Core::Formatters::DeprecationFormatter, RSpec::Buildkite::Insights::Reporter]

Because the spec_helper.rb from people’s app already done, config.formatters that is capable of reporting output should already exist. Adding our reporter then put us in the formatters array to report results, but the documentation formatter (or other user-sepecified formatter) will handle the output to Terminal for us 😉

@JuanitoFatas JuanitoFatas changed the title Add our reporter when other formatters added Add our reporter after other formatters added Apr 22, 2021
@JuanitoFatas JuanitoFatas merged commit 78519b9 into main Apr 22, 2021
@JuanitoFatas JuanitoFatas deleted the fix-reporter-swallo-people-output branch April 22, 2021 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants