File: wire_protocol_table_diffing.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 (119 lines) | stat: -rw-r--r-- 5,547 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@wire
Feature: Wire protocol table diffing
  In order to use the amazing functionality in the Cucumber table object
  As a wire server
  I want to be able to ask for a table diff during a step definition invocation

  Background:
    Given a standard Cucumber project directory structure
    And a file named "features/wired.feature" with:
      """
      Feature: Hello
        Scenario: Wired
          Given we're all wired

      """
    And a file named "features/step_definitions/some_remote_place.wire" with:
      """
      host: localhost
      port: 54321

      """

  Scenario: Invoke a step definition tries to diff the table and fails
    Given there is a wire server running on port 54321 which understands the following protocol:
      | request                                              | response                                                                                             |
      | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]]                                                                  |
      | ["begin_scenario"]                                   | ["success"]                                                                                          |
      | ["invoke",{"id":"1","args":[]}]                      | ["diff",[[["a","b"],["c","d"]],[["x","y"],["z","z"]]]]                                               |
      | ["diff_failed"]                                      | ["fail",{"message":"Not same", "exception":"DifferentException", "backtrace":["a.cs:12","b.cs:34"]}] |
      | ["end_scenario"]                                     | ["success"]                                                                                          |
    When I run cucumber -f progress --backtrace
    Then STDERR should be empty
    And it should fail with
      """
      F

      (::) failed steps (::)

      Not same (DifferentException from localhost:54321)
      a.cs:12
      b.cs:34
      features/wired.feature:3:in `Given we're all wired'

      Failing Scenarios:
      cucumber features/wired.feature:2 # Scenario: Wired

      1 scenario (1 failed)
      1 step (1 failed)

      """

  Scenario: Invoke a step definition tries to diff the table and passes
    Given there is a wire server running on port 54321 which understands the following protocol:
      | request                                              | response                               |
      | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]]    |
      | ["begin_scenario"]                                   | ["success"]                            |
      | ["invoke",{"id":"1","args":[]}]                      | ["diff",[[["a"],["b"]],[["a"],["b"]]]] |
      | ["diff_ok"]                                          | ["success"]                            |
      | ["end_scenario"]                                     | ["success"]                            |
    When I run cucumber -f progress
    And it should pass with
      """
      .

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

      """

  Scenario: Invoke a step definition which successfully diffs a table but then fails
    Given there is a wire server running on port 54321 which understands the following protocol:
      | request                                              | response                                                      |
      | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]]                           |
      | ["begin_scenario"]                                   | ["success"]                                                   |
      | ["invoke",{"id":"1","args":[]}]                      | ["diff",[[["a"],["b"]],[["a"],["b"]]]]                        |
      | ["diff_ok"]                                          | ["fail",{"message":"I wanted things to be different for us"}] |
      | ["end_scenario"]                                     | ["success"]                                                   |
    When I run cucumber -f progress
    And it should fail with
      """
      F

      (::) failed steps (::)

      I wanted things to be different for us (Cucumber::WireSupport::WireException)
      features/wired.feature:3:in `Given we're all wired'

      Failing Scenarios:
      cucumber features/wired.feature:2 # Scenario: Wired

      1 scenario (1 failed)
      1 step (1 failed)

      """

  Scenario: Invoke a step definition which asks for an immediate diff that fails
    Given there is a wire server running on port 54321 which understands the following protocol:
      | request                                              | response                            |
      | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
      | ["begin_scenario"]                                   | ["success"]                         |
      | ["invoke",{"id":"1","args":[]}]                      | ["diff!",[[["a"]],[["b"]]]]         |
      | ["end_scenario"]                                     | ["success"]                         |
    When I run cucumber -f progress
    And it should fail with
      """
      F

      (::) failed steps (::)

      Tables were not identical (Cucumber::Ast::Table::Different)
      features/wired.feature:3:in `Given we're all wired'

      Failing Scenarios:
      cucumber features/wired.feature:2 # Scenario: Wired

      1 scenario (1 failed)
      1 step (1 failed)

      """