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 120 121 122 123 124
|
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 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
"""
@spawn
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 -q`
Then the stderr should not contain anything
And it should fail with exactly:
"""
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
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 -q`
Then it should pass with exactly:
"""
.
1 scenario (1 passed)
1 step (1 passed)
"""
@spawn
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 -q`
Then it should fail with exactly:
"""
F
(::) failed steps (::)
I wanted things to be different for us (Cucumber::Wire::Exception)
features/wired.feature:3:in `Given we're all wired'
Failing Scenarios:
cucumber features/wired.feature:2
1 scenario (1 failed)
1 step (1 failed)
"""
@spawn
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 -q`
And it should fail with exactly:
"""
F
(::) failed steps (::)
Tables were not identical:
| (-) a | (+) b |
(Cucumber::MultilineArgument::DataTable::Different)
features/wired.feature:3:in `Given we're all wired'
Failing Scenarios:
cucumber features/wired.feature:2
1 scenario (1 failed)
1 step (1 failed)
"""
|