Skip to content

Commit 8b2c16f

Browse files
committed
Merge #14 'Adapt to the move of Location to Cucumber::Core::Test'
Also update Changelog.md, cucumber-wire.gemspec and .travis.yml.
2 parents 6395397 + 51ff015 commit 8b2c16f

16 files changed

+68
-34
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ rvm:
33
- 2.4.0
44
- 2.3.3
55
- 2.2
6-
- 2.1
7-
- 2.0
86

97
matrix:
108
allow_failures:

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
1010

1111
----
1212

13-
## [Unreleased] - In Git
13+
## [In Git (targeting 1.0.0)](https://github.com/cucumber/cucumber-ruby-wire/compare/v0.0.1...master)
1414

1515
### Removed
1616

@@ -20,11 +20,15 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
2020

2121
### Changed
2222

23+
* Changes to work with a modern Cucumber-Ruby ([#14](https://github.com/cucumber/cucumber-ruby-wire/pull/14) [brasmusson](https://github.com/brasmusson))
24+
* Adapt to the move of Location to Cucumber::Core::Test ([#14](https://github.com/cucumber/cucumber-ruby-wire/pull/14) [brasmusson](https://github.com/brasmusson))
25+
2326
### Fixed
2427

2528
<!-- Releases -->
2629

2730
<!-- Contributors -->
31+
[brasmusson]: https://github.com/brasmusson
2832
[jaysonesmith]: https://github.com/jaysonesmith
2933
[junaruga]: https://github.com/junaruga
3034
[mattwynne]: https://github.com/mattwynne

cucumber-wire.gemspec

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ Gem::Specification.new do |s|
1111
s.homepage = "http://cucumber.io"
1212
s.platform = Gem::Platform::RUBY
1313
s.license = "MIT"
14-
s.required_ruby_version = ">= 1.9.3"
14+
s.required_ruby_version = ">= 2.2"
1515

16-
s.add_development_dependency 'cucumber', '~> 2.1.0'
16+
s.add_dependency 'cucumber-core', '~> 3.2'
17+
s.add_dependency 'cucumber-expressions', '~> 6.0'
18+
19+
s.add_development_dependency 'cucumber', '~> 3.1'
1720

1821
s.add_development_dependency 'bundler', '>= 1.3.5'
1922
s.add_development_dependency 'rake', '>= 0.9.2'

features/invoke_message.feature

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ Feature: Invoke message
4747
4848
Scenario: Wired
4949
Given we're all wired
50-
I'll do it later (Cucumber::Pending)
51-
features/wired.feature:3:in `Given we're all wired'
5250
5351
1 scenario (1 pending)
5452
1 step (1 pending)
@@ -102,7 +100,7 @@ Feature: Invoke message
102100
(::) failed steps (::)
103101
104102
The wires are down (Some.Foreign.ExceptionType from localhost:54321)
105-
features/wired.feature:3:in `Given we're all wired'
103+
features/wired.feature:3:in `we're all wired'
106104
107105
Failing Scenarios:
108106
cucumber features/wired.feature:2 # Scenario: Wired

features/step_matches_message.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Feature: Step matches message
7070
"""
7171
-
7272
73-
we.* # MyApp.MyClass:123
73+
"we.*" # MyApp.MyClass:123
7474
7575
1 scenario (1 skipped)
7676
1 step (1 skipped)

features/table_diffing.feature

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Feature: Wire protocol table diffing
3939
Not same (DifferentException from localhost:54321)
4040
a.cs:12
4141
b.cs:34
42-
features/wired.feature:3:in `Given we're all wired'
42+
features/wired.feature:3:in `we're all wired'
4343
4444
Failing Scenarios:
4545
cucumber features/wired.feature:2
@@ -84,7 +84,7 @@ Feature: Wire protocol table diffing
8484
(::) failed steps (::)
8585
8686
I wanted things to be different for us (Cucumber::Wire::Exception)
87-
features/wired.feature:3:in `Given we're all wired'
87+
features/wired.feature:3:in `we're all wired'
8888
8989
Failing Scenarios:
9090
cucumber features/wired.feature:2
@@ -113,7 +113,7 @@ Feature: Wire protocol table diffing
113113
114114
| (-) a | (+) b |
115115
(Cucumber::MultilineArgument::DataTable::Different)
116-
features/wired.feature:3:in `Given we're all wired'
116+
features/wired.feature:3:in `we're all wired'
117117
118118
Failing Scenarios:
119119
cucumber features/wired.feature:2

features/timeouts.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Feature: Wire protocol timeouts
5252
Scenario: Wired
5353
Given we're all wired
5454
Timed out calling wire server with message 'invoke' (Timeout::Error)
55-
features/wired.feature:3:in `Given we're all wired'
55+
features/wired.feature:3:in `we're all wired'
5656
5757
Failing Scenarios:
5858
cucumber features/wired.feature:2

lib/cucumber/wire/add_hooks_filter.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# coding: utf-8
12
module Cucumber
23
module Wire
34
class AddHooksFilter < Core::Filter.new(:connections)
@@ -10,13 +11,13 @@ def test_case(test_case)
1011
def before_hook(test_case)
1112
# TODO: is this dependency on Cucumber::Hooks OK? Feels a bit internal..
1213
# 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?
13-
Cucumber::Hooks.before_hook(test_case.source, Core::Ast::Location.new('TODO:wire')) do
14+
Cucumber::Hooks.before_hook(Core::Test::Location.new('TODO:wire')) do
1415
connections.begin_scenario(test_case)
1516
end
1617
end
1718

1819
def after_hook(test_case)
19-
Cucumber::Hooks.after_hook(test_case.source, Core::Ast::Location.new('TODO:wire')) do
20+
Cucumber::Hooks.after_hook(Core::Test::Location.new('TODO:wire')) do
2021
connections.end_scenario(test_case)
2122
end
2223
end

lib/cucumber/wire/connections.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class Connections
1616
attr_reader :connections
1717
private :connections
1818

19-
def initialize(connections, configuration)
19+
def initialize(connections, configuration, registry)
2020
raise ArgumentError unless connections
2121
@connections = connections
2222
@configuration = configuration
23+
@registry = registry
2324
end
2425

2526
def find_match(test_step)
@@ -30,7 +31,7 @@ def find_match(test_step)
3031
end
3132

3233
def step_matches(step_name)
33-
connections.map{ |c| c.step_matches(step_name)}.flatten
34+
connections.map{ |c| c.step_matches(step_name, @registry)}.flatten
3435
end
3536

3637
def begin_scenario(test_case)

lib/cucumber/wire/plugin.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
module Cucumber
66
module Wire
77
class Plugin
8-
attr_reader :config
9-
private :config
8+
attr_reader :config, :registry
9+
private :config, :registry
1010

11-
def initialize(config)
11+
def initialize(config, registry)
1212
@config = config
13+
@registry = registry
1314
end
1415

1516
def install
16-
connections = Connections.new(wire_files.map { |f| create_connection(f) }, @config)
17+
connections = Connections.new(wire_files.map { |f| create_connection(f) }, config, registry)
1718
config.filters << Filters::ActivateSteps.new(StepMatchSearch.new(connections.method(:step_matches), @config), @config)
1819
config.filters << AddHooksFilter.new(connections) unless @config.dry_run?
1920
config.register_snippet_generator Snippet::Generator.new(connections)

lib/cucumber/wire/protocol.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
module Cucumber
44
module Wire
55
module Protocol
6-
def step_matches(name_to_match)
7-
handler = Requests::StepMatches.new(self)
6+
def step_matches(name_to_match, registry)
7+
handler = Requests::StepMatches.new(self, registry)
88
handler.execute(name_to_match)
99
end
1010

lib/cucumber/wire/protocol/requests.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# coding: utf-8
12
require 'cucumber/wire/request_handler'
2-
require 'cucumber/step_argument'
3+
require 'cucumber/wire/step_argument'
34

45
module Cucumber
56
module Wire
@@ -25,7 +26,7 @@ def handle_success(params)
2526
private
2627

2728
def create_step_match(raw_step_match)
28-
step_definition = StepDefinition.new(@connection, raw_step_match)
29+
step_definition = StepDefinition.new(@connection, raw_step_match, @registry)
2930
step_args = raw_step_match['args'].map do |raw_arg|
3031
StepArgument.new(raw_arg['pos'], raw_arg['val'])
3132
end
@@ -69,7 +70,7 @@ def handle_pending(message)
6970

7071
def handle_diff!(tables)
7172
# TODO: figure out if / how we could get a location for a table from the wire (or make a null location)
72-
location = Core::Ast::Location.new(__FILE__, __LINE__)
73+
location = Core::Test::Location.new(__FILE__, __LINE__)
7374
table1 = table(tables[0], location)
7475
table2 = table(tables[1], location)
7576
table1.diff!(table2)
@@ -89,7 +90,7 @@ def handle_diff(tables)
8990
private
9091

9192
def table(data, location)
92-
Cucumber::MultilineArgument.from_core(Core::Ast::DataTable.new(data, location))
93+
Cucumber::MultilineArgument.from_core(Core::Test::DataTable.new(data, location))
9394
end
9495
end
9596

lib/cucumber/wire/request_handler.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module Cucumber
22
module Wire
33
class RequestHandler
4-
def initialize(connection)
4+
def initialize(connection, registry = nil)
55
@connection = connection
66
@message = underscore(self.class.name.split('::').last)
7+
@registry = registry
78
end
89

910
def execute(request_params = nil)

lib/cucumber/wire/step_argument.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
require 'cucumber/cucumber_expressions/group'
3+
4+
module Cucumber
5+
module Wire
6+
# Defines the location and value of a captured argument from the step
7+
# text
8+
class StepArgument
9+
attr_reader :offset
10+
11+
def initialize(offset, val)
12+
@offset, @value = offset, val
13+
end
14+
15+
def value(_current_world)
16+
@value
17+
end
18+
19+
def group
20+
CucumberExpressions::Group.new(@value, @offset, @offset + @value.length, [])
21+
end
22+
end
23+
end
24+
end

lib/cucumber/wire/step_definition.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
require 'cucumber/core/ast/location'
1+
require 'cucumber/core/test/location'
22

33
module Cucumber
44
module Wire
55
class StepDefinition
6-
attr_reader :regexp_source, :location
6+
attr_reader :regexp_source, :location, :registry, :expression
77

8-
def initialize(connection, data)
8+
def initialize(connection, data, registry)
99
@connection = connection
10+
@registry = registry
1011
@id = data['id']
1112
@regexp_source = data['regexp'] || "Unknown"
12-
@location = Core::Ast::Location.from_file_colon_line(data['source'] || "unknown:0")
13+
@expression = registry.create_expression(@regexp_source)
14+
@location = Core::Test::Location.from_file_colon_line(data['source'] || "unknown:0")
1315
end
1416

1517
def invoke(args)

spec/cucumber/wire/connections_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ module Wire
99
connection1 = double(step_matches: [:a, :b])
1010
connection2 = double(step_matches: [:c])
1111

12-
connections = Connections.new([connection1, connection2], double)
12+
connections = Connections.new([connection1, connection2], double, double)
1313
expect(connections.step_matches('')).to eq [:a, :b, :c]
1414
end
1515

1616
it "copes with no connections" do
17-
connections = Connections.new([], double)
17+
connections = Connections.new([], double, double)
1818
expect(connections.step_matches('')).to eq []
1919
end
2020
end

0 commit comments

Comments
 (0)