cucumber-wire 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -6
- data/lib/cucumber/wire/add_hooks_filter.rb +2 -2
- data/lib/cucumber/wire/connections.rb +1 -1
- data/lib/cucumber/wire/protocol/requests.rb +1 -1
- data/lib/cucumber/wire/version +1 -1
- metadata +53 -50
- data/.rspec +0 -1
- data/.travis.yml +0 -22
- data/Gemfile +0 -20
- data/Rakefile +0 -13
- data/cucumber-wire.gemspec +0 -31
- data/features/docstring.feature +0 -39
- data/features/erb_configuration.feature +0 -54
- data/features/handle_unexpected_response.feature +0 -29
- data/features/invoke_message.feature +0 -210
- data/features/readme.md +0 -26
- data/features/snippets_message.feature +0 -47
- data/features/step_definitions/aruba_steps.rb +0 -1
- data/features/step_definitions/wire_steps.rb +0 -58
- data/features/step_matches_message.feature +0 -79
- data/features/support/fake_wire_server.rb +0 -80
- data/features/table_diffing.feature +0 -124
- data/features/tags.feature +0 -86
- data/features/timeouts.feature +0 -63
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 462ca912391ac19f173a610a18056c7c2dd3ddc42d6ab7b11aeaef6986d60201
|
|
4
|
+
data.tar.gz: ba3040346ba690ce5471b5af2e97b9a5e383001933684c79c553e9603f9fdd98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 620e604bec618f31fbb554079297f4c55f956e8bccad13deaa760c2ddbc902e8fb0371336584a3d8c122c4ccdf1298860a763865f1a1c319035bdc27d8805a0c
|
|
7
|
+
data.tar.gz: 6e3ff7030d0770fe50d3010db7a21e55811dc78c369de8725175680666738d642b93fba2354f9dd076233fa6f26ed1d1eb44d6ea46156124be696074ff7f9cd5
|
data/CHANGELOG.md
CHANGED
|
@@ -10,15 +10,12 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
|
|
|
10
10
|
|
|
11
11
|
----
|
|
12
12
|
|
|
13
|
-
## [
|
|
14
|
-
|
|
15
|
-
### Removed
|
|
16
|
-
|
|
17
|
-
### Added
|
|
13
|
+
## [1.1.0](https://github.com/cucumber/cucumber-ruby-wire/compare/v1.0.0...v1.1.0)
|
|
18
14
|
|
|
19
15
|
### Changed
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
* Update to cucumber-expressions 8.0.2
|
|
18
|
+
* Update to cucumber 4.0.0
|
|
22
19
|
|
|
23
20
|
## [1.0.0](https://github.com/cucumber/cucumber-ruby-wire/compare/v0.0.1...v1.0.0)
|
|
24
21
|
|
|
@@ -9,8 +9,8 @@ module Cucumber
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def before_hook(test_case)
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# TODO: is this dependency on Cucumber::Hooks OK? Feels a bit internal..
|
|
13
|
+
# TODO: how do we express the location of the hook? Should we create one hook per connection so we can use the host:port of the connection?
|
|
14
14
|
Cucumber::Hooks.before_hook(Core::Test::Location.new('TODO:wire')) do
|
|
15
15
|
connections.begin_scenario(test_case)
|
|
16
16
|
end
|
|
@@ -69,7 +69,7 @@ module Cucumber
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def handle_diff!(tables)
|
|
72
|
-
#
|
|
72
|
+
# TODO: figure out if / how we could get a location for a table from the wire (or make a null location)
|
|
73
73
|
location = Core::Test::Location.new(__FILE__, __LINE__)
|
|
74
74
|
table1 = table(tables[0], location)
|
|
75
75
|
table2 = table(tables[1], location)
|
data/lib/cucumber/wire/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.1.0
|
metadata
CHANGED
|
@@ -1,141 +1,145 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cucumber-wire
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Wynne
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cucumber-core
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 5.0.0
|
|
17
20
|
- - "~>"
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
22
|
+
version: '5.0'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 5.0.0
|
|
24
30
|
- - "~>"
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
32
|
+
version: '5.0'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: cucumber-expressions
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
39
|
+
version: '8.0'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 8.0.2
|
|
34
43
|
type: :runtime
|
|
35
44
|
prerelease: false
|
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
46
|
requirements:
|
|
38
47
|
- - "~>"
|
|
39
48
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
49
|
+
version: '8.0'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 8.0.2
|
|
41
53
|
- !ruby/object:Gem::Dependency
|
|
42
54
|
name: cucumber
|
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
|
44
56
|
requirements:
|
|
45
57
|
- - "~>"
|
|
46
58
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '4.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: bundler
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
+
version: '3.1'
|
|
59
60
|
- - ">="
|
|
60
61
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.
|
|
62
|
+
version: 3.1.2
|
|
62
63
|
type: :development
|
|
63
64
|
prerelease: false
|
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
66
|
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '3.1'
|
|
66
70
|
- - ">="
|
|
67
71
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 1.
|
|
72
|
+
version: 3.1.2
|
|
69
73
|
- !ruby/object:Gem::Dependency
|
|
70
74
|
name: rake
|
|
71
75
|
requirement: !ruby/object:Gem::Requirement
|
|
72
76
|
requirements:
|
|
77
|
+
- - "~>"
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '12.3'
|
|
73
80
|
- - ">="
|
|
74
81
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
82
|
+
version: 12.3.3
|
|
76
83
|
type: :development
|
|
77
84
|
prerelease: false
|
|
78
85
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
86
|
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '12.3'
|
|
80
90
|
- - ">="
|
|
81
91
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
92
|
+
version: 12.3.3
|
|
83
93
|
- !ruby/object:Gem::Dependency
|
|
84
94
|
name: rspec
|
|
85
95
|
requirement: !ruby/object:Gem::Requirement
|
|
86
96
|
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: 3.8.0
|
|
87
100
|
- - "~>"
|
|
88
101
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '3'
|
|
102
|
+
version: '3.8'
|
|
90
103
|
type: :development
|
|
91
104
|
prerelease: false
|
|
92
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
106
|
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 3.8.0
|
|
94
110
|
- - "~>"
|
|
95
111
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '3'
|
|
112
|
+
version: '3.8'
|
|
97
113
|
- !ruby/object:Gem::Dependency
|
|
98
114
|
name: aruba
|
|
99
115
|
requirement: !ruby/object:Gem::Requirement
|
|
100
116
|
requirements:
|
|
101
117
|
- - "~>"
|
|
102
118
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
119
|
+
version: '0.14'
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: 0.14.11
|
|
104
123
|
type: :development
|
|
105
124
|
prerelease: false
|
|
106
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
126
|
requirements:
|
|
108
127
|
- - "~>"
|
|
109
128
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
129
|
+
version: '0.14'
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: 0.14.11
|
|
111
133
|
description: Wire protocol for Cucumber
|
|
112
134
|
email: cukes@googlegroups.com
|
|
113
135
|
executables: []
|
|
114
136
|
extensions: []
|
|
115
137
|
extra_rdoc_files: []
|
|
116
138
|
files:
|
|
117
|
-
- ".rspec"
|
|
118
|
-
- ".travis.yml"
|
|
119
139
|
- CHANGELOG.md
|
|
120
140
|
- CONTRIBUTING.md
|
|
121
|
-
- Gemfile
|
|
122
141
|
- LICENSE
|
|
123
142
|
- README.md
|
|
124
|
-
- Rakefile
|
|
125
|
-
- cucumber-wire.gemspec
|
|
126
|
-
- features/docstring.feature
|
|
127
|
-
- features/erb_configuration.feature
|
|
128
|
-
- features/handle_unexpected_response.feature
|
|
129
|
-
- features/invoke_message.feature
|
|
130
|
-
- features/readme.md
|
|
131
|
-
- features/snippets_message.feature
|
|
132
|
-
- features/step_definitions/aruba_steps.rb
|
|
133
|
-
- features/step_definitions/wire_steps.rb
|
|
134
|
-
- features/step_matches_message.feature
|
|
135
|
-
- features/support/fake_wire_server.rb
|
|
136
|
-
- features/table_diffing.feature
|
|
137
|
-
- features/tags.feature
|
|
138
|
-
- features/timeouts.feature
|
|
139
143
|
- lib/cucumber/wire.rb
|
|
140
144
|
- lib/cucumber/wire/add_hooks_filter.rb
|
|
141
145
|
- lib/cucumber/wire/configuration.rb
|
|
@@ -169,21 +173,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
169
173
|
requirements:
|
|
170
174
|
- - ">="
|
|
171
175
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '2.
|
|
176
|
+
version: '2.3'
|
|
173
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
178
|
requirements:
|
|
175
179
|
- - ">="
|
|
176
180
|
- !ruby/object:Gem::Version
|
|
177
181
|
version: '0'
|
|
178
182
|
requirements: []
|
|
179
|
-
|
|
180
|
-
rubygems_version: 2.7.4
|
|
183
|
+
rubygems_version: 3.0.3
|
|
181
184
|
signing_key:
|
|
182
185
|
specification_version: 4
|
|
183
|
-
summary: cucumber-wire-1.
|
|
186
|
+
summary: cucumber-wire-1.1.0
|
|
184
187
|
test_files:
|
|
188
|
+
- spec/cucumber/wire/data_packet_spec.rb
|
|
185
189
|
- spec/cucumber/wire/configuration_spec.rb
|
|
186
|
-
- spec/cucumber/wire/connection_spec.rb
|
|
187
190
|
- spec/cucumber/wire/connections_spec.rb
|
|
188
|
-
- spec/cucumber/wire/data_packet_spec.rb
|
|
189
191
|
- spec/cucumber/wire/exception_spec.rb
|
|
192
|
+
- spec/cucumber/wire/connection_spec.rb
|
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--color
|
data/.travis.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
rvm:
|
|
2
|
-
- ruby-head
|
|
3
|
-
- 2.4.0
|
|
4
|
-
- 2.3.3
|
|
5
|
-
- 2.2
|
|
6
|
-
|
|
7
|
-
matrix:
|
|
8
|
-
allow_failures:
|
|
9
|
-
- rvm: ruby-head
|
|
10
|
-
fast_finish: true
|
|
11
|
-
|
|
12
|
-
# whitelist
|
|
13
|
-
branches:
|
|
14
|
-
only:
|
|
15
|
-
- master
|
|
16
|
-
|
|
17
|
-
notifications:
|
|
18
|
-
email:
|
|
19
|
-
- cukes-devs@googlegroups.com
|
|
20
|
-
webhooks:
|
|
21
|
-
urls: # gitter
|
|
22
|
-
- https://webhooks.gitter.im/e/dc010332f9d40fcc21c4
|
data/Gemfile
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
gemspec
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
unless ENV['CUCUMBER_USE_RELEASED_GEMS']
|
|
5
|
-
# cucumber gem
|
|
6
|
-
cucumber_path = File.expand_path("../../cucumber-ruby", __FILE__)
|
|
7
|
-
if File.exist?(cucumber_path) && !ENV['CUCUMBER_USE_GIT']
|
|
8
|
-
gem "cucumber", path: cucumber_path
|
|
9
|
-
else
|
|
10
|
-
gem "cucumber", :git => "git://github.com/cucumber/cucumber-ruby.git"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# cucumber-core gem
|
|
14
|
-
core_path = File.expand_path("../../cucumber-ruby-core", __FILE__)
|
|
15
|
-
if File.exist?(core_path) && !ENV['CUCUMBER_USE_GIT_CORE']
|
|
16
|
-
gem "cucumber-core", path: core_path
|
|
17
|
-
else
|
|
18
|
-
gem 'cucumber-core', :git => "git://github.com/cucumber/cucumber-ruby-core.git"
|
|
19
|
-
end
|
|
20
|
-
end
|
data/Rakefile
DELETED
data/cucumber-wire.gemspec
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |s|
|
|
5
|
-
s.name = 'cucumber-wire'
|
|
6
|
-
s.version = File.read(File.dirname(__FILE__) + "/lib/cucumber/wire/version")
|
|
7
|
-
s.authors = ["Matt Wynne"]
|
|
8
|
-
s.description = "Wire protocol for Cucumber"
|
|
9
|
-
s.summary = "cucumber-wire-#{s.version}"
|
|
10
|
-
s.email = 'cukes@googlegroups.com'
|
|
11
|
-
s.homepage = "http://cucumber.io"
|
|
12
|
-
s.platform = Gem::Platform::RUBY
|
|
13
|
-
s.license = "MIT"
|
|
14
|
-
s.required_ruby_version = ">= 2.2"
|
|
15
|
-
|
|
16
|
-
s.add_dependency 'cucumber-core', '~> 4.0'
|
|
17
|
-
s.add_dependency 'cucumber-expressions', '~> 6.0'
|
|
18
|
-
|
|
19
|
-
s.add_development_dependency 'cucumber', '~> 4.0'
|
|
20
|
-
|
|
21
|
-
s.add_development_dependency 'bundler', '>= 1.3.5'
|
|
22
|
-
s.add_development_dependency 'rake', '>= 0.9.2'
|
|
23
|
-
s.add_development_dependency 'rspec', '~> 3'
|
|
24
|
-
s.add_development_dependency 'aruba', '~> 0'
|
|
25
|
-
|
|
26
|
-
s.rubygems_version = ">= 1.6.1"
|
|
27
|
-
s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
|
|
28
|
-
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
29
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
30
|
-
s.require_path = "lib"
|
|
31
|
-
end
|
data/features/docstring.feature
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
Feature: Wire protocol docstrings
|
|
2
|
-
|
|
3
|
-
In order to use docstrings as arguments to step definitions, we send them as
|
|
4
|
-
an additional argument after the arguments extracted by the wire server.
|
|
5
|
-
|
|
6
|
-
Background:
|
|
7
|
-
Given a file named "features/step_definitions/some_remote_place.wire" with:
|
|
8
|
-
"""
|
|
9
|
-
host: localhost
|
|
10
|
-
port: 54321
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
Scenario: Run a scenario
|
|
15
|
-
Given a file named "features/wired.feature" with:
|
|
16
|
-
"""
|
|
17
|
-
Feature: High strung
|
|
18
|
-
Scenario: Wired
|
|
19
|
-
Given we're all wired
|
|
20
|
-
\"\"\"
|
|
21
|
-
to want more
|
|
22
|
-
\"\"\"
|
|
23
|
-
"""
|
|
24
|
-
And there is a wire server running on port 54321 which understands the following protocol:
|
|
25
|
-
| request | response |
|
|
26
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
27
|
-
| ["begin_scenario"] | ["success"] |
|
|
28
|
-
| ["invoke",{"id":"1","args":["to want more"]}] | ["success"] |
|
|
29
|
-
| ["end_scenario"] | ["success"] |
|
|
30
|
-
When I run `cucumber -f progress`
|
|
31
|
-
Then the stderr should not contain anything
|
|
32
|
-
And it should pass with:
|
|
33
|
-
"""
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
1 scenario (1 passed)
|
|
37
|
-
1 step (1 passed)
|
|
38
|
-
|
|
39
|
-
"""
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
Feature: ERB configuration
|
|
2
|
-
|
|
3
|
-
As a developer on server with multiple users
|
|
4
|
-
I want to be able to configure which port my wire server runs on
|
|
5
|
-
So that I can avoid port conflicts
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "features/wired.feature" with:
|
|
9
|
-
"""
|
|
10
|
-
Feature: High strung
|
|
11
|
-
Scenario: Wired
|
|
12
|
-
Given we're all wired
|
|
13
|
-
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
Scenario: ERB is used in the wire file which references an environment variable that is not set
|
|
17
|
-
Given a file named "features/step_definitions/server.wire" with:
|
|
18
|
-
"""
|
|
19
|
-
host: localhost
|
|
20
|
-
port: <%= ENV['PORT'] || 12345 %>
|
|
21
|
-
"""
|
|
22
|
-
And there is a wire server running on port 12345 which understands the following protocol:
|
|
23
|
-
| request | response |
|
|
24
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
|
|
25
|
-
When I run `cucumber --dry-run --no-snippets -f progress`
|
|
26
|
-
Then it should pass with:
|
|
27
|
-
"""
|
|
28
|
-
U
|
|
29
|
-
|
|
30
|
-
1 scenario (1 undefined)
|
|
31
|
-
1 step (1 undefined)
|
|
32
|
-
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Scenario: ERB is used in the wire file which references an environment variable
|
|
37
|
-
Given I have environment variable PORT set to "16816"
|
|
38
|
-
And a file named "features/step_definitions/server.wire" with:
|
|
39
|
-
"""
|
|
40
|
-
host: localhost
|
|
41
|
-
port: <%= ENV['PORT'] || 12345 %>
|
|
42
|
-
"""
|
|
43
|
-
And there is a wire server running on port 16816 which understands the following protocol:
|
|
44
|
-
| request | response |
|
|
45
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
|
|
46
|
-
When I run `cucumber --dry-run --no-snippets -f progress`
|
|
47
|
-
Then it should pass with:
|
|
48
|
-
"""
|
|
49
|
-
U
|
|
50
|
-
|
|
51
|
-
1 scenario (1 undefined)
|
|
52
|
-
1 step (1 undefined)
|
|
53
|
-
|
|
54
|
-
"""
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Feature: Handle unexpected response
|
|
2
|
-
|
|
3
|
-
When the server sends us back a message we don't understand, this is how Cucumber will behave.
|
|
4
|
-
|
|
5
|
-
Background:
|
|
6
|
-
Given a file named "features/wired.feature" with:
|
|
7
|
-
"""
|
|
8
|
-
Feature: High strung
|
|
9
|
-
Scenario: Wired
|
|
10
|
-
Given we're all wired
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
14
|
-
"""
|
|
15
|
-
host: localhost
|
|
16
|
-
port: 54321
|
|
17
|
-
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
Scenario: Unexpected response
|
|
21
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
22
|
-
| request | response |
|
|
23
|
-
| ["begin_scenario"] | ["yikes"] |
|
|
24
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
25
|
-
When I run `cucumber -f pretty`
|
|
26
|
-
Then the output should contain:
|
|
27
|
-
"""
|
|
28
|
-
undefined method `handle_yikes'
|
|
29
|
-
"""
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
Feature: Invoke message
|
|
2
|
-
|
|
3
|
-
Assuming a StepMatch was returned for a given step name, when it's time to
|
|
4
|
-
invoke that step definition, Cucumber will send an invoke message.
|
|
5
|
-
|
|
6
|
-
The invoke message contains the ID of the step definition, as returned by
|
|
7
|
-
the wire server in response to the the step_matches call, along with the
|
|
8
|
-
arguments that were parsed from the step name during the same step_matches
|
|
9
|
-
call.
|
|
10
|
-
|
|
11
|
-
The wire server will normally reply one of the following:
|
|
12
|
-
|
|
13
|
-
* `success`
|
|
14
|
-
* `fail`
|
|
15
|
-
* `pending` - optionally takes a message argument
|
|
16
|
-
|
|
17
|
-
This isn't quite the whole story: see also table_diffing.feature
|
|
18
|
-
|
|
19
|
-
Background:
|
|
20
|
-
Given a file named "features/wired.feature" with:
|
|
21
|
-
"""
|
|
22
|
-
Feature: High strung
|
|
23
|
-
Scenario: Wired
|
|
24
|
-
Given we're all wired
|
|
25
|
-
|
|
26
|
-
"""
|
|
27
|
-
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
28
|
-
"""
|
|
29
|
-
host: localhost
|
|
30
|
-
port: 54321
|
|
31
|
-
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@spawn
|
|
36
|
-
Scenario: Invoke a step definition which is pending
|
|
37
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
38
|
-
| request | response |
|
|
39
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
40
|
-
| ["begin_scenario"] | ["success"] |
|
|
41
|
-
| ["invoke",{"id":"1","args":[]}] | ["pending", "I'll do it later"] |
|
|
42
|
-
| ["end_scenario"] | ["success"] |
|
|
43
|
-
When I run `cucumber -f pretty -q`
|
|
44
|
-
And it should pass with exactly:
|
|
45
|
-
"""
|
|
46
|
-
Feature: High strung
|
|
47
|
-
|
|
48
|
-
Scenario: Wired
|
|
49
|
-
Given we're all wired
|
|
50
|
-
|
|
51
|
-
1 scenario (1 pending)
|
|
52
|
-
1 step (1 pending)
|
|
53
|
-
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
Scenario: Invoke a step definition which passes
|
|
57
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
58
|
-
| request | response |
|
|
59
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
60
|
-
| ["begin_scenario"] | ["success"] |
|
|
61
|
-
| ["invoke",{"id":"1","args":[]}] | ["success"] |
|
|
62
|
-
| ["end_scenario"] | ["success"] |
|
|
63
|
-
When I run `cucumber -f progress`
|
|
64
|
-
And it should pass with:
|
|
65
|
-
"""
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
1 scenario (1 passed)
|
|
69
|
-
1 step (1 passed)
|
|
70
|
-
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
@spawn
|
|
74
|
-
Scenario: Invoke a step definition which fails
|
|
75
|
-
|
|
76
|
-
If an invoked step definition fails, it can return details of the exception
|
|
77
|
-
in the reply to invoke. This causes a Cucumber::WireSupport::WireException to be
|
|
78
|
-
raised.
|
|
79
|
-
|
|
80
|
-
Valid arguments are:
|
|
81
|
-
|
|
82
|
-
- `message` (mandatory)
|
|
83
|
-
- `exception`
|
|
84
|
-
- `backtrace`
|
|
85
|
-
|
|
86
|
-
See the specs for Cucumber::WireSupport::WireException for more details
|
|
87
|
-
|
|
88
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
89
|
-
| request | response |
|
|
90
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
91
|
-
| ["begin_scenario"] | ["success"] |
|
|
92
|
-
| ["invoke",{"id":"1","args":[]}] | ["fail",{"message":"The wires are down", "exception":"Some.Foreign.ExceptionType"}] |
|
|
93
|
-
| ["end_scenario"] | ["success"] |
|
|
94
|
-
When I run `cucumber -f progress`
|
|
95
|
-
Then the stderr should not contain anything
|
|
96
|
-
And it should fail with:
|
|
97
|
-
"""
|
|
98
|
-
F
|
|
99
|
-
|
|
100
|
-
(::) failed steps (::)
|
|
101
|
-
|
|
102
|
-
The wires are down (Some.Foreign.ExceptionType from localhost:54321)
|
|
103
|
-
features/wired.feature:3:in `we're all wired'
|
|
104
|
-
|
|
105
|
-
Failing Scenarios:
|
|
106
|
-
cucumber features/wired.feature:2 # Scenario: Wired
|
|
107
|
-
|
|
108
|
-
1 scenario (1 failed)
|
|
109
|
-
1 step (1 failed)
|
|
110
|
-
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
|
-
Scenario: Invoke a step definition which takes string arguments (and passes)
|
|
114
|
-
|
|
115
|
-
If the step definition at the end of the wire captures arguments, these are
|
|
116
|
-
communicated back to Cucumber in the `step_matches` message.
|
|
117
|
-
|
|
118
|
-
Cucumber expects these StepArguments to be returned in the StepMatch. The keys
|
|
119
|
-
have the following meanings:
|
|
120
|
-
|
|
121
|
-
- `val` - the value of the string captured for that argument from the step
|
|
122
|
-
name passed in step_matches
|
|
123
|
-
- `pos` - the position within the step name that the argument was matched
|
|
124
|
-
(used for formatter highlighting)
|
|
125
|
-
|
|
126
|
-
The argument values are then sent back by Cucumber in the `invoke` message.
|
|
127
|
-
|
|
128
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
129
|
-
| request | response |
|
|
130
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]] |
|
|
131
|
-
| ["begin_scenario"] | ["success"] |
|
|
132
|
-
| ["invoke",{"id":"1","args":["wired"]}] | ["success"] |
|
|
133
|
-
| ["end_scenario"] | ["success"] |
|
|
134
|
-
When I run `cucumber -f progress`
|
|
135
|
-
Then the stderr should not contain anything
|
|
136
|
-
And it should pass with:
|
|
137
|
-
"""
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
1 scenario (1 passed)
|
|
141
|
-
1 step (1 passed)
|
|
142
|
-
|
|
143
|
-
"""
|
|
144
|
-
|
|
145
|
-
Scenario: Invoke a step definition which takes regular and table arguments (and passes)
|
|
146
|
-
|
|
147
|
-
If the step has a multiline table argument, it will be passed with the
|
|
148
|
-
invoke message as an array of array of strings.
|
|
149
|
-
|
|
150
|
-
In this scenario our step definition takes two arguments - one
|
|
151
|
-
captures the "we're" and the other takes the table.
|
|
152
|
-
|
|
153
|
-
Given a file named "features/wired_on_tables.feature" with:
|
|
154
|
-
"""
|
|
155
|
-
Feature: High strung
|
|
156
|
-
Scenario: Wired and more
|
|
157
|
-
Given we're all:
|
|
158
|
-
| wired |
|
|
159
|
-
| high |
|
|
160
|
-
| happy |
|
|
161
|
-
"""
|
|
162
|
-
And there is a wire server running on port 54321 which understands the following protocol:
|
|
163
|
-
| request | response |
|
|
164
|
-
| ["step_matches",{"name_to_match":"we're all:"}] | ["success",[{"id":"1", "args":[{"val":"we're", "pos":0}]}]] |
|
|
165
|
-
| ["begin_scenario"] | ["success"] |
|
|
166
|
-
| ["invoke",{"id":"1","args":["we're",[["wired"],["high"],["happy"]]]}] | ["success"] |
|
|
167
|
-
| ["end_scenario"] | ["success"] |
|
|
168
|
-
When I run `cucumber -f progress features/wired_on_tables.feature`
|
|
169
|
-
Then the stderr should not contain anything
|
|
170
|
-
And it should pass with:
|
|
171
|
-
"""
|
|
172
|
-
.
|
|
173
|
-
|
|
174
|
-
1 scenario (1 passed)
|
|
175
|
-
1 step (1 passed)
|
|
176
|
-
|
|
177
|
-
"""
|
|
178
|
-
|
|
179
|
-
Scenario: Invoke a scenario outline step
|
|
180
|
-
Given a file named "features/wired_in_an_outline.feature" with:
|
|
181
|
-
"""
|
|
182
|
-
Feature:
|
|
183
|
-
Scenario Outline:
|
|
184
|
-
Given we're all <arg>
|
|
185
|
-
|
|
186
|
-
Examples:
|
|
187
|
-
| arg |
|
|
188
|
-
| wired |
|
|
189
|
-
"""
|
|
190
|
-
And there is a wire server running on port 54321 which understands the following protocol:
|
|
191
|
-
| request | response |
|
|
192
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
193
|
-
| ["begin_scenario"] | ["success"] |
|
|
194
|
-
| ["invoke",{"id":"1","args":[]}] | ["success"] |
|
|
195
|
-
| ["end_scenario"] | ["success"] |
|
|
196
|
-
When I run `cucumber -f progress features/wired_in_an_outline.feature`
|
|
197
|
-
Then the stderr should not contain anything
|
|
198
|
-
And it should pass with:
|
|
199
|
-
"""
|
|
200
|
-
.
|
|
201
|
-
|
|
202
|
-
1 scenario (1 passed)
|
|
203
|
-
1 step (1 passed)
|
|
204
|
-
|
|
205
|
-
"""
|
|
206
|
-
And the wire server should have received the following messages:
|
|
207
|
-
| step_matches |
|
|
208
|
-
| begin_scenario |
|
|
209
|
-
| invoke |
|
|
210
|
-
| end_scenario |
|
data/features/readme.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Cucumber's wire protocol allows step definitions to be
|
|
2
|
-
implemented and invoked on any platform.
|
|
3
|
-
|
|
4
|
-
Communication is over a TCP socket, which Cucumber connects to when it finds
|
|
5
|
-
a definition file with the .wire extension in the step_definitions folder
|
|
6
|
-
(or other load path). Note that these files are rendered with ERB when loaded.
|
|
7
|
-
|
|
8
|
-
A `Wire::DataPacket` flowing in either direction is formatted as a JSON-encoded
|
|
9
|
-
string, with a newline character signaling the end of a packet. See the
|
|
10
|
-
specs for `Cucumber::Wire::DataPacket` for more details.
|
|
11
|
-
|
|
12
|
-
Cucumber sends the following request messages out over the wire:
|
|
13
|
-
|
|
14
|
-
* `step_matches` - Find out whether the wire server has a definition for a step
|
|
15
|
-
* `invoke` - Ask for a step definition to be invoked
|
|
16
|
-
* `begin_scenario` - signals that cucumber is about to execute a scenario
|
|
17
|
-
* `end_scenario` - signals that cucumber has finished executing a scenario
|
|
18
|
-
* `snippet_text` - requests a snippet for an undefined step
|
|
19
|
-
|
|
20
|
-
Every message supports two standard responses:
|
|
21
|
-
|
|
22
|
-
* `success` - expects different arguments (sometimes none at all) depending
|
|
23
|
-
on the request that was sent.
|
|
24
|
-
* `fail` - causes a Cucumber::Wire::Exception to be raised.
|
|
25
|
-
|
|
26
|
-
Some messages support more responses - see individual scenarios for details.
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Feature: Snippets message
|
|
2
|
-
|
|
3
|
-
If a step doesn't match, Cucumber will ask the wire server to return a snippet of code for a
|
|
4
|
-
step definition.
|
|
5
|
-
|
|
6
|
-
Background:
|
|
7
|
-
Given a file named "features/wired.feature" with:
|
|
8
|
-
"""
|
|
9
|
-
Feature: High strung
|
|
10
|
-
Scenario: Wired
|
|
11
|
-
Given we're all wired
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
15
|
-
"""
|
|
16
|
-
host: localhost
|
|
17
|
-
port: 54321
|
|
18
|
-
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
@spawn
|
|
22
|
-
Scenario: Wire server returns snippets for a step that didn't match
|
|
23
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
24
|
-
| request | response |
|
|
25
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
|
|
26
|
-
| ["snippet_text",{"step_keyword":"Given","multiline_arg_class":"","step_name":"we're all wired"}] | ["success","foo()\n bar;\nbaz"] |
|
|
27
|
-
| ["begin_scenario"] | ["success"] |
|
|
28
|
-
| ["end_scenario"] | ["success"] |
|
|
29
|
-
When I run `cucumber -f pretty`
|
|
30
|
-
Then the stderr should not contain anything
|
|
31
|
-
And it should pass with:
|
|
32
|
-
"""
|
|
33
|
-
Feature: High strung
|
|
34
|
-
|
|
35
|
-
Scenario: Wired # features/wired.feature:2
|
|
36
|
-
Given we're all wired # features/wired.feature:3
|
|
37
|
-
|
|
38
|
-
1 scenario (1 undefined)
|
|
39
|
-
1 step (1 undefined)
|
|
40
|
-
"""
|
|
41
|
-
And the output should contain:
|
|
42
|
-
"""
|
|
43
|
-
foo()
|
|
44
|
-
bar;
|
|
45
|
-
baz
|
|
46
|
-
|
|
47
|
-
"""
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require "aruba/cucumber"
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
Given /^there is a wire server (running |)on port (\d+) which understands the following protocol:$/ do |running, port, table|
|
|
2
|
-
protocol = table.hashes.map do |table_hash|
|
|
3
|
-
table_hash['response'] = table_hash['response'].gsub(/\n/, '\n')
|
|
4
|
-
table_hash
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
@server = FakeWireServer.new(port.to_i, protocol)
|
|
8
|
-
start_wire_server if running.strip == "running"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
Given /^the wire server takes (.*) seconds to respond to the invoke message$/ do |timeout|
|
|
12
|
-
@server.delay_response(:invoke, timeout.to_f)
|
|
13
|
-
start_wire_server
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Given /^I have environment variable (\w+) set to "([^"]*)"$/ do |variable, value|
|
|
17
|
-
set_env(variable, value)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
Then(/^the wire server should have received the following messages:$/) do |expected_messages|
|
|
21
|
-
expect(messages_received).to eq expected_messages.raw.flatten
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
module WireHelper
|
|
25
|
-
attr_reader :messages_received
|
|
26
|
-
|
|
27
|
-
def start_wire_server
|
|
28
|
-
@messages_received = []
|
|
29
|
-
reader, writer = IO.pipe
|
|
30
|
-
@wire_pid = fork {
|
|
31
|
-
reader.close
|
|
32
|
-
@server.run(writer)
|
|
33
|
-
}
|
|
34
|
-
writer.close
|
|
35
|
-
Thread.new do
|
|
36
|
-
while message = reader.gets
|
|
37
|
-
@messages_received << message.strip
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
at_exit { stop_wire_server }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def stop_wire_server
|
|
44
|
-
return unless @wire_pid
|
|
45
|
-
Process.kill('KILL', @wire_pid)
|
|
46
|
-
Process.wait(@wire_pid)
|
|
47
|
-
rescue Errno::ESRCH
|
|
48
|
-
# No such process - wire server has already been stopped by the After hook
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Before do
|
|
53
|
-
extend(WireHelper)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
After do
|
|
57
|
-
stop_wire_server
|
|
58
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
Feature: Step matches message
|
|
2
|
-
|
|
3
|
-
When the features have been parsed, Cucumber will send a `step_matches`
|
|
4
|
-
message to ask the wire server if it can match a step name. This happens for
|
|
5
|
-
each of the steps in each of the features.
|
|
6
|
-
|
|
7
|
-
The wire server replies with an array of StepMatch objects.
|
|
8
|
-
|
|
9
|
-
When each StepMatch is returned, it contains the following data:
|
|
10
|
-
|
|
11
|
-
* `id` - identifier for the step definition to be used later when if it
|
|
12
|
-
needs to be invoked. The identifier can be any string value and
|
|
13
|
-
is simply used for the wire server's own reference.
|
|
14
|
-
* `args` - any argument values as captured by the wire end's own regular
|
|
15
|
-
expression (or other argument matching) process.
|
|
16
|
-
|
|
17
|
-
Background:
|
|
18
|
-
Given a file named "features/wired.feature" with:
|
|
19
|
-
"""
|
|
20
|
-
Feature: High strung
|
|
21
|
-
Scenario: Wired
|
|
22
|
-
Given we're all wired
|
|
23
|
-
|
|
24
|
-
"""
|
|
25
|
-
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
26
|
-
"""
|
|
27
|
-
host: localhost
|
|
28
|
-
port: 54321
|
|
29
|
-
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
Scenario: Dry run finds no step match
|
|
33
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
34
|
-
| request | response |
|
|
35
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
|
|
36
|
-
When I run `cucumber --dry-run --no-snippets -f progress`
|
|
37
|
-
And it should pass with:
|
|
38
|
-
"""
|
|
39
|
-
U
|
|
40
|
-
|
|
41
|
-
1 scenario (1 undefined)
|
|
42
|
-
1 step (1 undefined)
|
|
43
|
-
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
Scenario: Dry run finds a step match
|
|
47
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
48
|
-
| request | response |
|
|
49
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
50
|
-
When I run `cucumber --dry-run -f progress`
|
|
51
|
-
And it should pass with:
|
|
52
|
-
"""
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
1 scenario (1 skipped)
|
|
56
|
-
1 step (1 skipped)
|
|
57
|
-
|
|
58
|
-
"""
|
|
59
|
-
|
|
60
|
-
Scenario: Step matches returns details about the remote step definition
|
|
61
|
-
|
|
62
|
-
Optionally, the StepMatch can also contain a source reference, and a native
|
|
63
|
-
regexp string which will be used by some formatters.
|
|
64
|
-
|
|
65
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
66
|
-
| request | response |
|
|
67
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[], "source":"MyApp.MyClass:123", "regexp":"we.*"}]] |
|
|
68
|
-
When I run `cucumber -f stepdefs --dry-run`
|
|
69
|
-
Then it should pass with:
|
|
70
|
-
"""
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
"we.*" # MyApp.MyClass:123
|
|
74
|
-
|
|
75
|
-
1 scenario (1 skipped)
|
|
76
|
-
1 step (1 skipped)
|
|
77
|
-
|
|
78
|
-
"""
|
|
79
|
-
And the stderr should not contain anything
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require 'multi_json'
|
|
2
|
-
require 'socket'
|
|
3
|
-
|
|
4
|
-
class FakeWireServer
|
|
5
|
-
def initialize(port, protocol_table)
|
|
6
|
-
@port, @protocol_table = port, protocol_table
|
|
7
|
-
@delays = {}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def run(io)
|
|
11
|
-
@server = TCPServer.open(@port)
|
|
12
|
-
loop { handle_connections(io) }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def delay_response(message, delay)
|
|
16
|
-
@delays[message] = delay
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def handle_connections(io)
|
|
22
|
-
Thread.start(@server.accept) { |socket| open_session_on socket, io }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def open_session_on(socket, io)
|
|
26
|
-
begin
|
|
27
|
-
on_message = lambda { |message| io.puts message }
|
|
28
|
-
SocketSession.new(socket, @protocol_table, @delays, on_message).start
|
|
29
|
-
rescue Exception => e
|
|
30
|
-
raise e
|
|
31
|
-
ensure
|
|
32
|
-
socket.close
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class SocketSession
|
|
37
|
-
def initialize(socket, protocol, delays, on_message)
|
|
38
|
-
@socket = socket
|
|
39
|
-
@protocol = protocol
|
|
40
|
-
@delays = delays
|
|
41
|
-
@on_message = on_message
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def start
|
|
45
|
-
while message = @socket.gets
|
|
46
|
-
handle(message)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def handle(data)
|
|
53
|
-
if protocol_entry = response_to(data.strip)
|
|
54
|
-
sleep delay(data)
|
|
55
|
-
@on_message.call(MultiJson.load(protocol_entry['request'])[0])
|
|
56
|
-
send_response(protocol_entry['response'])
|
|
57
|
-
else
|
|
58
|
-
serialized_exception = { :message => "Not understood: #{data}", :backtrace => [] }
|
|
59
|
-
send_response(['fail', serialized_exception ].to_json)
|
|
60
|
-
end
|
|
61
|
-
rescue => e
|
|
62
|
-
send_response(['fail', { :message => e.message, :backtrace => e.backtrace, :exception => e.class } ].to_json)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def response_to(data)
|
|
66
|
-
@protocol.detect do |entry|
|
|
67
|
-
MultiJson.load(entry['request']) == MultiJson.load(data)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def send_response(response)
|
|
72
|
-
@socket.puts response + "\n"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def delay(data)
|
|
76
|
-
message = MultiJson.load(data.strip)[0]
|
|
77
|
-
@delays[message.to_sym] || 0
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
Feature: Wire protocol table diffing
|
|
2
|
-
|
|
3
|
-
In order to use the amazing functionality in the Cucumber table object
|
|
4
|
-
As a wire server
|
|
5
|
-
I want to be able to ask for a table diff during a step definition invocation
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "features/wired.feature" with:
|
|
9
|
-
"""
|
|
10
|
-
Feature: Hello
|
|
11
|
-
Scenario: Wired
|
|
12
|
-
Given we're all wired
|
|
13
|
-
|
|
14
|
-
"""
|
|
15
|
-
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
16
|
-
"""
|
|
17
|
-
host: localhost
|
|
18
|
-
port: 54321
|
|
19
|
-
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
@spawn
|
|
23
|
-
Scenario: Invoke a step definition tries to diff the table and fails
|
|
24
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
25
|
-
| request | response |
|
|
26
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
27
|
-
| ["begin_scenario"] | ["success"] |
|
|
28
|
-
| ["invoke",{"id":"1","args":[]}] | ["diff",[[["a","b"],["c","d"]],[["x","y"],["z","z"]]]] |
|
|
29
|
-
| ["diff_failed"] | ["fail",{"message":"Not same", "exception":"DifferentException", "backtrace":["a.cs:12","b.cs:34"]}] |
|
|
30
|
-
| ["end_scenario"] | ["success"] |
|
|
31
|
-
When I run `cucumber -f progress --backtrace -q`
|
|
32
|
-
Then the stderr should not contain anything
|
|
33
|
-
And it should fail with exactly:
|
|
34
|
-
"""
|
|
35
|
-
F
|
|
36
|
-
|
|
37
|
-
(::) failed steps (::)
|
|
38
|
-
|
|
39
|
-
Not same (DifferentException from localhost:54321)
|
|
40
|
-
a.cs:12
|
|
41
|
-
b.cs:34
|
|
42
|
-
features/wired.feature:3:in `we're all wired'
|
|
43
|
-
|
|
44
|
-
Failing Scenarios:
|
|
45
|
-
cucumber features/wired.feature:2
|
|
46
|
-
|
|
47
|
-
1 scenario (1 failed)
|
|
48
|
-
1 step (1 failed)
|
|
49
|
-
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
Scenario: Invoke a step definition tries to diff the table and passes
|
|
53
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
54
|
-
| request | response |
|
|
55
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
56
|
-
| ["begin_scenario"] | ["success"] |
|
|
57
|
-
| ["invoke",{"id":"1","args":[]}] | ["diff",[[["a"],["b"]],[["a"],["b"]]]] |
|
|
58
|
-
| ["diff_ok"] | ["success"] |
|
|
59
|
-
| ["end_scenario"] | ["success"] |
|
|
60
|
-
When I run `cucumber -f progress -q`
|
|
61
|
-
Then it should pass with exactly:
|
|
62
|
-
"""
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
1 scenario (1 passed)
|
|
66
|
-
1 step (1 passed)
|
|
67
|
-
|
|
68
|
-
"""
|
|
69
|
-
|
|
70
|
-
@spawn
|
|
71
|
-
Scenario: Invoke a step definition which successfully diffs a table but then fails
|
|
72
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
73
|
-
| request | response |
|
|
74
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
75
|
-
| ["begin_scenario"] | ["success"] |
|
|
76
|
-
| ["invoke",{"id":"1","args":[]}] | ["diff",[[["a"],["b"]],[["a"],["b"]]]] |
|
|
77
|
-
| ["diff_ok"] | ["fail",{"message":"I wanted things to be different for us"}] |
|
|
78
|
-
| ["end_scenario"] | ["success"] |
|
|
79
|
-
When I run `cucumber -f progress -q`
|
|
80
|
-
Then it should fail with exactly:
|
|
81
|
-
"""
|
|
82
|
-
F
|
|
83
|
-
|
|
84
|
-
(::) failed steps (::)
|
|
85
|
-
|
|
86
|
-
I wanted things to be different for us (Cucumber::Wire::Exception)
|
|
87
|
-
features/wired.feature:3:in `we're all wired'
|
|
88
|
-
|
|
89
|
-
Failing Scenarios:
|
|
90
|
-
cucumber features/wired.feature:2
|
|
91
|
-
|
|
92
|
-
1 scenario (1 failed)
|
|
93
|
-
1 step (1 failed)
|
|
94
|
-
|
|
95
|
-
"""
|
|
96
|
-
|
|
97
|
-
@spawn
|
|
98
|
-
Scenario: Invoke a step definition which asks for an immediate diff that fails
|
|
99
|
-
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
100
|
-
| request | response |
|
|
101
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
102
|
-
| ["begin_scenario"] | ["success"] |
|
|
103
|
-
| ["invoke",{"id":"1","args":[]}] | ["diff!",[[["a"]],[["b"]]]] |
|
|
104
|
-
| ["end_scenario"] | ["success"] |
|
|
105
|
-
When I run `cucumber -f progress -q`
|
|
106
|
-
And it should fail with exactly:
|
|
107
|
-
"""
|
|
108
|
-
F
|
|
109
|
-
|
|
110
|
-
(::) failed steps (::)
|
|
111
|
-
|
|
112
|
-
Tables were not identical:
|
|
113
|
-
|
|
114
|
-
| (-) a | (+) b |
|
|
115
|
-
(Cucumber::MultilineArgument::DataTable::Different)
|
|
116
|
-
features/wired.feature:3:in `we're all wired'
|
|
117
|
-
|
|
118
|
-
Failing Scenarios:
|
|
119
|
-
cucumber features/wired.feature:2
|
|
120
|
-
|
|
121
|
-
1 scenario (1 failed)
|
|
122
|
-
1 step (1 failed)
|
|
123
|
-
|
|
124
|
-
"""
|
data/features/tags.feature
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
Feature: Wire protocol tags
|
|
2
|
-
|
|
3
|
-
In order to use Before and After hooks in a wire server, we send tags with the
|
|
4
|
-
scenario in the begin_scenario and end_scenario messages
|
|
5
|
-
|
|
6
|
-
Background:
|
|
7
|
-
Given a file named "features/step_definitions/some_remote_place.wire" with:
|
|
8
|
-
"""
|
|
9
|
-
host: localhost
|
|
10
|
-
port: 54321
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
Scenario: Run a scenario
|
|
15
|
-
Given a file named "features/wired.feature" with:
|
|
16
|
-
"""
|
|
17
|
-
@foo @bar
|
|
18
|
-
Feature: Wired
|
|
19
|
-
|
|
20
|
-
@baz
|
|
21
|
-
Scenario: Everybody's Wired
|
|
22
|
-
Given we're all wired
|
|
23
|
-
|
|
24
|
-
"""
|
|
25
|
-
And there is a wire server running on port 54321 which understands the following protocol:
|
|
26
|
-
| request | response |
|
|
27
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
28
|
-
| ["begin_scenario", {"tags":["bar","baz","foo"]}] | ["success"] |
|
|
29
|
-
| ["invoke",{"id":"1","args":[]}] | ["success"] |
|
|
30
|
-
| ["end_scenario", {"tags":["bar","baz","foo"]}] | ["success"] |
|
|
31
|
-
When I run `cucumber -f pretty -q`
|
|
32
|
-
Then the stderr should not contain anything
|
|
33
|
-
And it should pass with:
|
|
34
|
-
"""
|
|
35
|
-
@foo @bar
|
|
36
|
-
Feature: Wired
|
|
37
|
-
|
|
38
|
-
@baz
|
|
39
|
-
Scenario: Everybody's Wired
|
|
40
|
-
Given we're all wired
|
|
41
|
-
|
|
42
|
-
1 scenario (1 passed)
|
|
43
|
-
1 step (1 passed)
|
|
44
|
-
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
Scenario: Run a scenario outline example
|
|
48
|
-
Given a file named "features/wired.feature" with:
|
|
49
|
-
"""
|
|
50
|
-
@foo @bar
|
|
51
|
-
Feature: Wired
|
|
52
|
-
|
|
53
|
-
@baz
|
|
54
|
-
Scenario Outline: Everybody's Wired
|
|
55
|
-
Given we're all <something>
|
|
56
|
-
|
|
57
|
-
Examples:
|
|
58
|
-
| something |
|
|
59
|
-
| wired |
|
|
60
|
-
|
|
61
|
-
"""
|
|
62
|
-
And there is a wire server running on port 54321 which understands the following protocol:
|
|
63
|
-
| request | response |
|
|
64
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
65
|
-
| ["begin_scenario", {"tags":["bar","baz","foo"]}] | ["success"] |
|
|
66
|
-
| ["invoke",{"id":"1","args":[]}] | ["success"] |
|
|
67
|
-
| ["end_scenario", {"tags":["bar","baz","foo"]}] | ["success"] |
|
|
68
|
-
When I run `cucumber -f pretty -q`
|
|
69
|
-
Then the stderr should not contain anything
|
|
70
|
-
And it should pass with exactly:
|
|
71
|
-
"""
|
|
72
|
-
@foo @bar
|
|
73
|
-
Feature: Wired
|
|
74
|
-
|
|
75
|
-
@baz
|
|
76
|
-
Scenario Outline: Everybody's Wired
|
|
77
|
-
Given we're all <something>
|
|
78
|
-
|
|
79
|
-
Examples:
|
|
80
|
-
| something |
|
|
81
|
-
| wired |
|
|
82
|
-
|
|
83
|
-
1 scenario (1 passed)
|
|
84
|
-
1 step (1 passed)
|
|
85
|
-
|
|
86
|
-
"""
|
data/features/timeouts.feature
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
Feature: Wire protocol timeouts
|
|
2
|
-
|
|
3
|
-
We don't want Cucumber to hang forever on a wire server that's not even there,
|
|
4
|
-
but equally we need to give the user the flexibility to allow step definitions
|
|
5
|
-
to take a while to execute, if that's what they need.
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "features/wired.feature" with:
|
|
9
|
-
"""
|
|
10
|
-
Feature: Telegraphy
|
|
11
|
-
Scenario: Wired
|
|
12
|
-
Given we're all wired
|
|
13
|
-
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
Scenario: Try to talk to a server that's not there
|
|
17
|
-
Given a file named "features/step_definitions/some_remote_place.wire" with:
|
|
18
|
-
"""
|
|
19
|
-
host: localhost
|
|
20
|
-
port: 54321
|
|
21
|
-
|
|
22
|
-
"""
|
|
23
|
-
When I run `cucumber -f progress`
|
|
24
|
-
Then the stderr should contain:
|
|
25
|
-
"""
|
|
26
|
-
Unable to contact the wire server at localhost:54321
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
@spawn
|
|
30
|
-
Scenario: Invoke a step definition that takes longer than its timeout
|
|
31
|
-
Given a file named "features/step_definitions/some_remote_place.wire" with:
|
|
32
|
-
"""
|
|
33
|
-
host: localhost
|
|
34
|
-
port: 54321
|
|
35
|
-
timeout:
|
|
36
|
-
invoke: 0.1
|
|
37
|
-
|
|
38
|
-
"""
|
|
39
|
-
And there is a wire server on port 54321 which understands the following protocol:
|
|
40
|
-
| request | response |
|
|
41
|
-
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]] |
|
|
42
|
-
| ["begin_scenario"] | ["success"] |
|
|
43
|
-
| ["invoke",{"id":"1","args":["wired"]}] | ["success"] |
|
|
44
|
-
| ["end_scenario"] | ["success"] |
|
|
45
|
-
And the wire server takes 0.2 seconds to respond to the invoke message
|
|
46
|
-
When I run `cucumber -f pretty -q`
|
|
47
|
-
Then the stderr should not contain anything
|
|
48
|
-
And it should fail with exactly:
|
|
49
|
-
"""
|
|
50
|
-
Feature: Telegraphy
|
|
51
|
-
|
|
52
|
-
Scenario: Wired
|
|
53
|
-
Given we're all wired
|
|
54
|
-
Timed out calling wire server with message 'invoke' (Timeout::Error)
|
|
55
|
-
features/wired.feature:3:in `we're all wired'
|
|
56
|
-
|
|
57
|
-
Failing Scenarios:
|
|
58
|
-
cucumber features/wired.feature:2
|
|
59
|
-
|
|
60
|
-
1 scenario (1 failed)
|
|
61
|
-
1 step (1 failed)
|
|
62
|
-
|
|
63
|
-
"""
|