Sha256: f7192b788912c8b38883e7aece0e824ea84f935b76614c16dc8c2fe0b8d55634

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
cucumber-3.0.1 features/docs/formatters/api_methods.feature
cucumber-2.99.0 features/docs/formatters/api_methods.feature
cucumber-3.0.0 features/docs/formatters/api_methods.feature
cucumber-3.0.0.pre.2 features/docs/formatters/api_methods.feature
mobiusloop-0.1.5 features/docs/formatters/api_methods.feature
cucumber-3.0.0.pre.1 features/docs/formatters/api_methods.feature
cucumber-2.4.0 features/docs/formatters/api_methods.feature
mobiusloop-0.1.3 features/docs/formatters/api_methods.feature
mobiusloop-0.1.2 features/docs/formatters/api_methods.feature
cucumber-2.3.3 features/docs/formatters/api_methods.feature
cucumber-2.3.2 features/docs/formatters/api_methods.feature
cucumber-2.3.1 features/docs/formatters/api_methods.feature
cucumber-2.3.0 features/docs/formatters/api_methods.feature