Asides

Dynamically Configuring RSpec for JUnit

Using continuous integration? Using RSpec? Selectively configuring RSpec to output JUnit with RspecJunitFormatter but finding your output file to be empty?

You need to configure your output file before you set your formatter(s).

Allons-y:

RSpec.configure do |config|

  # ...

  # Use JUnit output for CI
  if ENV["BAMBOO_INSTALL"]
    config.output_stream = 'rspec.xml'
    config.formatter = RspecJunitFormatter
  end
end