File: before_hook.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 (65 lines) | stat: -rw-r--r-- 1,757 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Feature: Before Hook

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

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

      """

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

        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|
        names << scenario.scenario_outline.feature.name.split("\n").first
        names << scenario.scenario_outline.name.split("\n").first
        names << scenario.name.split("\n").first
        if(names.size == 3)
          raise "NAMES:\n" + names.join("\n") + "\n"
        end
      end
      """
    When I run `cucumber`
    Then the output should contain:
      """
            NAMES:
            Feature name
            Scenario Outline name, Examples Table name (#1)
            Scenario Outline name, Examples Table name (#1)

      """