File: api_methods.feature

package info (click to toggle)
cucumber 2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,076 kB
  • sloc: ruby: 17,016; javascript: 4,641; makefile: 12; sh: 10; tcl: 3
file content (37 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
33
34
35
36
37
Feature: Formatter API methods

  Some utility methods are provided to make it easier to write your own formatters.

  Here are some examples.

  Scenario: A formatter that uses `Cucumber::Formatter::Io#ensure_file`

    The ensure_file method is a little helper function that some formatters use,
    normally when given a CLI argument with `--out` to check that the file passed
    by the user actually exists.

    The second argument is the name of the formatter, used to print a useful
    error message if the file can't be created for some reason.

    Given a file named "features/f.feature" with:
      """
      Feature: Test
        Scenario: Test
      """
    And a directory named "my/special"
    And a file named "features/support/custom_formatter.rb" with:
      """
      require 'cucumber/formatter/io'
      module Cucumber
        module Formatter
          class Test
            include Io
            def initialize(runtime, path_or_io, options)
              ensure_file("my/special/output.file", "custom formatter")
            end
          end
        end
      end
      """
    When I run `cucumber features/f.feature --format Cucumber::Formatter::Test`
    Then it should pass