Skip to content

Commit

Permalink
Merge #1314 'Remove the support of old style tag expressions'
Browse files Browse the repository at this point in the history
Also update Changelog.md.
  • Loading branch information
brasmusson committed Aug 5, 2018
2 parents efcee2e + 5c2a854 commit 47cac29
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo

### Removed

* Remove the support of old style tag expressions.
([#1314](https://github.com/cucumber/cucumber-ruby/pull/1314),
[brasmusson](https://github.com/brasmusson))
* Remove the Legacy API for Formatters.
([#1230](https://github.com/cucumber/cucumber-ruby/pull/1230),
[#839](https://github.com/cucumber/cucumber-ruby/issues/839)
Expand Down
2 changes: 1 addition & 1 deletion cucumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ std_opts << " --tags 'not @wip-jruby'" if defined?(JRUBY_VERSION)
wip_opts = "--color -r features".dup
wip_opts << " --tags @wip" if !defined?(JRUBY_VERSION)
wip_opts << " --tags @wip,@wip-jruby" if defined?(JRUBY_VERSION)
wip_opts << " --tags '@wip or @wip-jruby'" if defined?(JRUBY_VERSION)
%>
default: <%= std_opts %> --tags "not @jruby"
jruby: <%= std_opts %> --tags "not @wire"
Expand Down
8 changes: 4 additions & 4 deletions features/docs/cli/randomize.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Feature: Randomize
Given a file named "features/bad_practice_part_1.feature" with:
"""
Feature: Bad practice, part 1
Scenario: Set state
Given I set some state
Scenario: Depend on state from a preceding scenario
When I depend on the state
"""
Expand Down Expand Up @@ -89,7 +89,7 @@ Feature: Randomize
Scenario: Set state
Given I set some state
Failing Scenarios:
cucumber features/bad_practice_part_1.feature:6
cucumber features/bad_practice_part_2.feature:3
Expand All @@ -103,7 +103,7 @@ Feature: Randomize

@spawn @todo-windows
Scenario: Run scenarios randomized with some skipped
When I run `cucumber --tags ~@skipme --order random:41544 -q`
When I run `cucumber --tags 'not @skipme' --order random:41544 -q`
Then it should fail
And the stdout should contain exactly:
"""
Expand Down
4 changes: 2 additions & 2 deletions features/docs/writing_support_code/around_hooks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ Feature: Around hooks
block.call
end
Around('@one,@two') do |scenario, block|
Around('@one or @two') do |scenario, block|
$hooks_called ||= []
$hooks_called << 'one or two'
block.call
end
Around('@one', '@two') do |scenario, block|
Around('@one and @two') do |scenario, block|
$hooks_called ||= []
$hooks_called << 'one and two'
block.call
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ def add_option(option, value)
end

def add_tag(value)
warn("Deprecated: Found tags option '#{value}'. Support for '~@tag' will be removed from the next release of Cucumber. Please use 'not @tag' instead.") if value.include?('~')
warn("Deprecated: Found tags option '#{value}'. Support for '@tag1,@tag2' will be removed from the next release of Cucumber. Please use '@tag or @tag2' instead.") if value.include?(',')
raise("Found tags option '#{value}'. '~@tag' is no longer supported, use 'not @tag' instead.") if value.include?('~')
raise("Found tags option '#{value}'. '@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.") if value.include?(',')
@options[:tag_expressions] << value.gsub(/(@\w+)(:\d+)?/, '\1')
add_tag_limits(value)
end
Expand Down
23 changes: 13 additions & 10 deletions lib/cucumber/glue/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Hook

def initialize(registry, tag_expressions, proc)
@registry = registry
@tag_expressions = tag_expressions
@tag_expressions = sanitize_tag_expressions(tag_expressions)
@proc = proc
@location = Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
warn_for_old_style_tag_expressions(tag_expressions)
fail_for_old_style_tag_expressions(@tag_expressions)
end

def invoke(pseudo_method, arguments, &block)
Expand All @@ -29,18 +29,21 @@ def invoke(pseudo_method, arguments, &block)

private

def warn_for_old_style_tag_expressions(tag_expressions)
def sanitize_tag_expressions(tag_expressions)
# TODO: remove when '~@no-clobber' has been changed to 'not @no-clobber' in aruba
tag_expressions.map { |tag_expression| tag_expression == '~@no-clobber' ? 'not @no-clobber' : tag_expression }
end

def fail_for_old_style_tag_expressions(tag_expressions)
tag_expressions.each do |tag_expression|
if tag_expression.include?('~') && tag_expression != '~@no-clobber' # ~@no-clobber is used in aruba
warn("Deprecated: Found tagged hook with '#{tag_expression}'." \
"Support for '~@tag' will be removed from the next release of Cucumber. " \
"Please use 'not @tag' instead.")
if tag_expression.include?('~')
raise("Found tagged hook with '#{tag_expression}'." \
"'~@tag' is no longer supported, use 'not @tag' instead.")
end

next unless tag_expression.include?(',')
warn("Deprecated: Found tagged hook with '#{tag_expression}'." \
"Support for '@tag1,@tag2' will be removed from the next release " \
"of Cucumber. Please use '@tag or @tag2' instead.")
warn("Found tagged hook with '#{tag_expression}'." \
"'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
end
end
end
Expand Down

0 comments on commit 47cac29

Please sign in to comment.