Skip to content

Commit

Permalink
Revert "fix bug with certain filters not working properly. Now if the…
Browse files Browse the repository at this point in the history
…re is a scenario with an included tag and an excluded tag it will get excluded."

CI did not pass

This reverts commit 3395860.
  • Loading branch information
David West committed Oct 24, 2018
1 parent 3395860 commit 6bfd838
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
10 changes: 5 additions & 5 deletions lib/cuke_slicer/helpers/filter_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def filter_excluded_tags(elements, filters)
end

def filter_included_tags(elements, filters)
if filters && filters != []
filters = [filters] unless filters.is_a?(Array)
if filters
filters = [filters] unless filters.is_a?(Array)

elements.keep_if do |element|
matching_tag?(element, filters)
end
elements.keep_if do |element|
matching_tag?(element, filters)
end
end
end

Expand Down
16 changes: 9 additions & 7 deletions lib/cuke_slicer/helpers/matching_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ module CukeSlicer
module MatchingHelpers

def matching_tag?(element, filters)
if filters.is_a?(Array)
filter_match = or_filter_match(element, filters)
else
filters.each do |filter|
filters.each do |filter|
if filter.is_a?(Array)
filter_match = or_filter_match(element, filter)
else
filter_match = and_filter_match(element, filter)
end

return false unless filter_match
end
!!filter_match

true
end

def and_filter_match(element, filter)
Expand All @@ -25,10 +27,10 @@ def or_filter_match(element, filters)

def filter_match(element, filter)
tag_values = element.all_tags
tag_values = tag_values.collect {|tag| tag.name} if Gem.loaded_specs['cuke_modeler'].version.version[/^1/]
tag_values = tag_values.collect { |tag| tag.name } if Gem.loaded_specs['cuke_modeler'].version.version[/^1/]

if filter.is_a?(Regexp)
tag_values.any? {|tag| tag =~ filter}
tag_values.any? { |tag| tag =~ filter }
else
tag_values.include?(filter)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cuke_slicer/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CukeSlicer
# The current version for the gem.
VERSION = "2.0.3"
VERSION = "2.0.2"
end
14 changes: 1 addition & 13 deletions spec/slicer_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
@tag
Scenario: Test scenario
* some step
@wip
Scenario: Test scenario2
* some step
@slow @tag
Scenario: Test scenario3
* some step" }

before(:each) do
Expand Down Expand Up @@ -240,12 +232,8 @@
expected_tests << "#{test_file}:4"


# Filters
filters = {included_tags: ['@tag'],
excluded_tags: ['@wip', '@slow']}

# No problems, no missed files
expect { @slice_output = slicer.slice(root_directory, filters, :file_line) }.to_not raise_error
expect { @slice_output = slicer.slice(root_directory, :file_line) }.to_not raise_error
expect(@slice_output).to match_array(expected_tests)
end

Expand Down

0 comments on commit 6bfd838

Please sign in to comment.