Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cucumber/cucumber-ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Dana Scheider committed Sep 21, 2017
2 parents 6f536e1 + 77e7120 commit b3b7da5
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ matrix:
os: linux
- rvm: 2.1
os: osx
- rvm: jruby-9.1.12.0
- rvm: jruby-9.1.13.0
os: linux
env:
# Travis by default also have "-Dcext.enabled=false" set in
Expand All @@ -35,7 +35,7 @@ matrix:
- LC_ALL=en_US.UTF-8
- LANG=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
- rvm: jruby-9.1.12.0
- rvm: jruby-9.1.13.0
os: osx
env:
# Travis by default also have "-Dcext.enabled=false" set in
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo

### Breaking changes

None so far...

### Added

* Handle selective strict options. ([#1169](https://github.com/cucumber/cucumber-ruby/pull/1169), [#1160](https://github.com/cucumber/cucumber-ruby/issues/1160) @brasmusson)
Expand Down
36 changes: 4 additions & 32 deletions features/docs/extending_cucumber/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Feature: Custom Formatter
"""

Scenario: Custom config
Scenario: Pass custom config to your formatter from the CLI
Given a file named "features/support/custom_formatter.rb" with:
"""
module MyCustom
Expand All @@ -61,7 +61,7 @@ Feature: Custom Formatter
{"foo"=>"bar", "one"=>"two"}
"""

Scenario: Use the legacy API
Scenario: Use the legacy API
This is deprecated and should no longer be used.

Given a file named "features/support/custom_legacy_formatter.rb" with:
Expand All @@ -85,38 +85,10 @@ Feature: Custom Formatter
When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
Then it should pass with exactly:
"""
I'LL USE MY OWN
JUST PRINT ME
"""
WARNING: The formatter MyCustom::LegacyFormatter is using the deprecated formatter API which will be removed in v4.0 of Cucumber.
Scenario: Use both old and new
You can both APIs at once, for now

Given a file named "features/support/custom_mixed_formatter.rb" with:
"""
module MyCustom
class MixedFormatter
def initialize(runtime, io, options)
@io = io
end
def before_test_case(test_case)
feature = test_case.source.first
@io.puts feature.short_name.upcase
end
def scenario_name(keyword, name, file_colon_line, source_indent)
@io.puts " #{name.upcase}"
end
end
end
"""
When I run `cucumber features/f.feature --format MyCustom::MixedFormatter`
Then it should pass with exactly:
"""
I'LL USE MY OWN
JUST PRINT ME
"""

44 changes: 0 additions & 44 deletions features/docs/formatters/formatter_step_file_colon_line.feature

This file was deleted.

7 changes: 1 addition & 6 deletions features/docs/writing_support_code/parameter_types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ Feature: Parameter Types
ParameterType(
name: 'person',
regexp: /[A-Z]\w+/,
type: Person,
transformer: lambda do |name|
Person.new(name)
end,
use_for_snippets: true,
prefer_for_regexp_match: false
transformer: -> (name) { Person.new(name) }
)
"""
When I run `cucumber features/foo.feature`
Expand Down
5 changes: 1 addition & 4 deletions features/lib/support/parameter_types.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
ParameterType(
name: 'list',
regexp: /.*/,
type: Array,
transformer: ->(s) { s.split(/,\s+/)},
use_for_snippets: false,
prefer_for_regexp_match: false
transformer: ->(s) { s.split(/,\s+/)}
)
2 changes: 1 addition & 1 deletion lib/cucumber/events/test_case_finished.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestCaseFinished < Core::Events::TestCaseFinished
# @return [Cucumber::Core::Test::Case] that was executed
attr_reader :test_case

# @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Step}
# @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Case}
attr_reader :result

end
Expand Down
16 changes: 16 additions & 0 deletions lib/cucumber/formatter/legacy_api/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module LegacyApi

def initialize(*)
super
emit_deprecation_warning

@matches = collect_matches
config.on_event(:test_case_started) do |event|
formatter.before_test_case(event.test_case)
Expand Down Expand Up @@ -50,6 +52,20 @@ def puts(*messages)

private

def emit_deprecation_warning
parent_name = formatter_class_name =~ /::[^:]+\Z/ ? $`.freeze : nil
return if parent_name == 'Cucumber::Formatter'
return if !config.out_stream # some unit tests don't set it
config.out_stream.puts "WARNING: The formatter #{formatter.class.name} is using the deprecated formatter API which will be removed in v4.0 of Cucumber."
config.out_stream.puts
end

def formatter_class_name
formatter.class.name
rescue NoMethodError # when we use the Fanout, things get gnarly
formatter.class[0].class.name
end

def printer
@printer ||= FeaturesPrinter.new(formatter, results, config, @matches).before
end
Expand Down
12 changes: 8 additions & 4 deletions lib/cucumber/glue/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def Transform(regexp, &proc)
Cucumber.deprecate(
'Use ParameterType(...) instead',
'Transform',
'2.6.0'
'3.0'
)
parameter_type = CucumberExpressions::ParameterType.new(
regexp.to_s,
Expand All @@ -109,13 +109,17 @@ def Transform(regexp, &proc)
end

def ParameterType(options)
type = options[:type] || Object
use_for_snippets = true if options[:use_for_snippets].nil?
prefer_for_regexp_match = false if options[:prefer_for_regexp_match].nil?

parameter_type = CucumberExpressions::ParameterType.new(
options[:name],
options[:regexp],
options[:type],
type,
options[:transformer],
options[:use_for_snippets],
options[:prefer_for_regexp_match]
use_for_snippets,
prefer_for_regexp_match
)
Dsl.define_parameter_type(parameter_type)
end
Expand Down
6 changes: 4 additions & 2 deletions lib/cucumber/multiline_argument/data_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ def hashes
# [{:foo => '2', :bar => '3', :foo_bar => '5'}, {:foo => '7', :bar => '9', :foo_bar => '16'}]
#
def symbolic_hashes
@header_conversion_proc = lambda { |h| symbolize_key(h) }
@symbolic_hashes ||= build_hashes
@symbolic_hashes ||=
self.hashes.map do |string_hash|
Hash[string_hash.map{ |a,b| [symbolize_key(a), b] }]
end
end

# Converts this table into a Hash where the first column is
Expand Down
4 changes: 2 additions & 2 deletions spec/cucumber/glue/snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ def unindented(s)
'veg',
/(cuke|banana)s?/,
Object,
->(s) { s},
->(s) { s },
true,
false
))
@registry.define_parameter_type(CucumberExpressions::ParameterType.new(
'cucumis',
/(bella|cuke)s?/,
Object,
->(s) { s},
->(s) { s },
true,
false
))
Expand Down
5 changes: 5 additions & 0 deletions spec/cucumber/multiline_argument/data_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ module MultilineArgument
expect{@table.symbolic_hashes}.to_not raise_error
end

it 'should not interfere with use of #hashes' do
@table.symbolic_hashes
expect{@table.hashes}.to_not raise_error
end

end

describe '#map_column!' do
Expand Down

0 comments on commit b3b7da5

Please sign in to comment.