File: before_hook.feature

package info (click to toggle)
cucumber 1.3.17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,296 kB
  • ctags: 1,812
  • sloc: ruby: 13,576; python: 28; sh: 10; makefile: 10; tcl: 3
file content (43 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
Feature: Before Hook

  Scenario: Examine names of elements
    Given a file named "features/foo.feature" with:
      """
      Feature: Feature name

        Scenario: Scenario name
          Given a step

        Scenario Outline: Scenario Outline name
          Given a <placeholder>

          Examples: Examples Table name
            | <placeholder> |
            | step          |
      """
    And a file named "features/support/hook.rb" with:
      """
      names = []
      Before do |scenario|
        unless scenario.respond_to?(:scenario_outline)
          names << scenario.feature.name.split("\n").first
          names << scenario.name.split("\n").first
        else
          names << scenario.scenario_outline.feature.name.split("\n").first
          names << scenario.scenario_outline.name.split("\n").first
        end
        if(names.size == 4)
          raise "NAMES:\n" + names.join("\n") + "\n"
        end
      end
      """
    When I run `cucumber`
    Then the output should contain:
      """
            NAMES:
            Feature name
            Scenario name
            Feature name
            Scenario Outline name
      """