File: output_stream.feature

package info (click to toggle)
ruby-rspec 3.12.0c0e1m1s0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,752 kB
  • sloc: ruby: 69,818; sh: 1,861; makefile: 99
file content (27 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Feature: Custom output stream

  Define a custom output stream (default `$stdout`).  Aliases: `:output`,
  `:out`.

  ```ruby
  RSpec.configure { |c| c.output_stream = File.open('saved_output', 'w') }
  ```

  Background:
    Given a file named "spec/spec_helper.rb" with:
      """ruby
      RSpec.configure { |c| c.output_stream = File.open('saved_output', 'w') }
      """

  Scenario: Redirecting output
    Given a file named "spec/example_spec.rb" with:
      """ruby
      require 'spec_helper'
      RSpec.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"