Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParameterType transformer runs in World #1213

Merged
merged 2 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
cucumber (3.0.2)
builder (>= 2.1.2)
cucumber-core (~> 3.0.0)
cucumber-expressions (~> 4.0.3)
cucumber-expressions (~> 5.0.3)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 4.0)
Expand All @@ -25,7 +25,7 @@ GEM
bcat (0.6.2)
rack (~> 1.0)
builder (3.2.3)
capybara (2.15.4)
capybara (2.16.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
Expand All @@ -39,7 +39,7 @@ GEM
backports (>= 3.8.0)
cucumber-tag_expressions (>= 1.0.1)
gherkin (>= 4.1.3)
cucumber-expressions (4.0.4)
cucumber-expressions (5.0.3)
cucumber-tag_expressions (1.0.1)
cucumber-wire (0.0.1)
diff-lcs (1.3)
Expand All @@ -64,18 +64,18 @@ GEM
parser (2.4.0.2)
ast (~> 2.3)
powerpack (0.1.1)
pry (0.11.2)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.1)
rack (1.6.8)
rack-protection (1.5.3)
rack
rack-test (0.7.0)
rack-test (0.8.2)
rack (>= 1.0, < 3)
rainbow (2.2.2)
rake
rake (12.2.1)
rake (12.3.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
Expand Down
2 changes: 1 addition & 1 deletion cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.add_dependency 'multi_json', '>= 1.7.5', '< 2.0'
s.add_dependency 'multi_test', '>= 0.1.2'
s.add_dependency 'cucumber-wire', '~> 0.0.1'
s.add_dependency 'cucumber-expressions', '~> 4.0.3'
s.add_dependency 'cucumber-expressions', '~> 5.0.3'

s.add_development_dependency 'bundler', '~> 1.16.0'
s.add_development_dependency 'aruba', '~> 0.6.1'
Expand Down
3 changes: 0 additions & 3 deletions features/bugs/1238.feature

This file was deleted.

16 changes: 11 additions & 5 deletions features/docs/writing_support_code/parameter_types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ Feature: Parameter Types
When I run `cucumber features/foo.feature`
Then it should pass

Scenario: Parameter type defined with ParameterType method
If your parameter type's `regexp` is very general, you can tell
Cucumber not to suggest its use in snippets:

Scenario: Parameter type delegating to World
Given a file named "features/support/parameter_types.rb" with:
"""
ParameterType(
name: 'person',
regexp: /[A-Z]\w+/,
transformer: -> (name) { Person.new(name) },
transformer: -> (name) { make_person(name) },
use_for_snippets: false
)
"""
Given a file named "features/support/world.rb" with:
"""
module MyWorld
def make_person(name)
Person.new(name)
end
end
World(MyWorld)
"""
When I run `cucumber features/foo.feature`
Then it should pass
2 changes: 1 addition & 1 deletion lib/cucumber/glue/step_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def parse_target_proc_from(options)
end
end

attr_reader :expression
attr_reader :expression, :registry

def initialize(registry, expression, proc)
raise 'No regexp' if expression.is_a?(Regexp)
Expand Down
5 changes: 4 additions & 1 deletion lib/cucumber/step_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def initialize(step_definition, step_name, step_arguments)
end

def args
@step_arguments.map(&:value)
current_world = @step_definition.registry.current_world
@step_arguments.map do |arg|
arg.value(current_world)
end
end

def activate(test_step)
Expand Down