RSpec / RSpec Core / Docs / Configuration
This page comes from RSpec Core 2.99.2. It is not part of the 3.12.1 docs. See the latest RSpec Core docs.
output_stream
Define a custom output stream (default $stdout). Aliases: :output, :out.
RSpec.configure { |c| c.output_stream = File.open('saved_output', 'w') }
Background:
- Given a file named "
spec/spec_helper.rb" with:rubyRSpec.configure {|c| c.output_stream = File.open('saved_output', 'w') }
Scenario: redirecting output
- Given a file named "
spec/example_spec.rb" with:rubyrequire 'spec_helper' describe "an example" do it "passes" do true end end - When I run `rspec spec/example_spec.rb`
- Then the file "
saved_output" should contain "1 example, 0 failures"
Source: features/configuration/output_stream.feature at v2.99.2, RSpec Core (MIT license).