PageRenderTime 30ms CodeModel.GetById 14ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/features/formatters/custom_formatter.feature

https://github.com/delowong/logstash
Gherkin Specification | 36 lines | 31 code | 5 blank | 0 comment | 3 complexity | 829ab76bbd08407c8df2ebe9787f6f46 MD5 | raw file
 1Feature: custom formatters
 2
 3  RSpec ships with general purpose output formatters. You can tell RSpec which
 4  one to use using the [`--format` command line
 5  option]('../command_line/format_option').
 6
 7  When RSpec's built-in output formatters don't, however, give you everything
 8  you need, you can write your own custom formatter and tell RSpec to use that
 9  one instead.  The simplest way is to subclass RSpec's `BaseTextFormatter`,
10  and then override just the methods that you want to modify.
11
12  Scenario: custom formatter
13    Given a file named "custom_formatter.rb" with:
14      """ruby
15      require "rspec/core/formatters/base_text_formatter"
16
17      class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
18        def initialize(output)
19          super(output)
20        end
21
22        def example_started(proxy)
23          output << "example: " << proxy.description
24        end
25      end
26      """
27    And a file named "example_spec.rb" with:
28      """ruby
29      describe "my group" do
30        specify "my example" do
31        end
32      end
33      """
34    When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
35    Then the output should contain "example: my example"
36    And  the exit status should be 0