Debian Codegraph @

rspec-core/features/command_line/require_option.feature

raw
1 Feature: `--require` option
2
3 Use the `--require` (or `-r`) option to specify a file to require before
4 running specs.
5
6 Scenario: Using the `--require` option
7 Given a file named "logging_formatter.rb" with:
8 """ruby
9 require "rspec/core/formatters/base_text_formatter"
10 require 'delegate'
11
12 class LoggingFormatter < RSpec::Core::Formatters::BaseTextFormatter
13 RSpec::Core::Formatters.register self, :dump_summary
14
15 def initialize(output)
16 super LoggingIO.new(output)
17 end
18
19 class LoggingIO < SimpleDelegator
20 def initialize(output)
21 @file = File.new('rspec.log', 'w')
22 super
23 end
24
25 def puts(*args)
26 [@file, __getobj__].each { |out| out.puts(*args) }
27 end
28
29 def close
30 @file.close
31 end
32 end
33 end
34 """
35 And a file named "spec/example_spec.rb" with:
36 """ruby
37 RSpec.describe "an embarrassing situation" do
38 it "happens to everyone" do
39 end
40 end
41 """
42 When I run `rspec --require ./logging_formatter.rb --format LoggingFormatter`
43 Then the output should contain "1 example, 0 failures"
44 And the file "rspec.log" should contain "1 example, 0 failures"
45 And the exit status should be 0