File: after_step_hooks.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 (53 lines) | stat: -rw-r--r-- 1,459 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
Feature: AfterStep Hooks
  AfterStep hooks can be used to further inspect the Step object of the step
  that has just run, or to simply check the step's result.

  Background:
    Given the standard step definitions
    And a file named "features/sample.feature" with:
      """
      Feature: Sample

        Scenario: Success
          Given this step passes
      """

  Scenario: Access Test Step object in AfterStep Block
    Given a file named "features/support/env.rb" with:
      """
      AfterStep do |result, test_step|
        expect(test_step).to be_a(Cucumber::Core::Test::Step)
      end
      """
    When I run `cucumber features`
    Then it should pass with:
      """
      Feature: Sample

        Scenario: Success        # features/sample.feature:3
          Given this step passes # features/step_definitions/steps.rb:1

      1 scenario (1 passed)
      1 step (1 passed)

      """

  Scenario: An AfterStep with one named argument receives only the result
    Given a file named "features/support/env.rb" with:
      """
      AfterStep do |result|
        expect(result).to be_a(Cucumber::Core::Test::Result::Passed)
      end
      """
    When I run `cucumber features`
    Then it should pass with:
      """
      Feature: Sample

        Scenario: Success        # features/sample.feature:3
          Given this step passes # features/step_definitions/steps.rb:1

      1 scenario (1 passed)
      1 step (1 passed)

      """