cucumber_priority 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 242720f5b4e64c6f0ac18ed2dfb6088352b2da43
4
- data.tar.gz: e34150747914d626ab20c323728331302b0fdcf2
2
+ SHA256:
3
+ metadata.gz: '08253bd452fab3691947f47e32a8dd918b40dc1d87984383f11ec07d41662b7f'
4
+ data.tar.gz: 5fbc94f014fc42891fcad6737aa78297f2f12485f92230615af538d400cdbd06
5
5
  SHA512:
6
- metadata.gz: 207cedc8544e1584f1cb38daea7d2355728990918aa9296e41d90214e36d03a8df7c933cb9862e4bcb8f42d23989ae3a5aa25d559f664c77235a0216288376c4
7
- data.tar.gz: a1b91d31ccb4339e7cb785e200aa3fb60bfd21fc8c6a74b0d68d35f0b8b060f6847823e1b05584d1fa1545817a8d7e30846933f0ff6cbe30b76c5793c63c35dd
6
+ metadata.gz: 901cc83b57973c9c6b2bdad8590be51bd7092b6ae46d50bec50506c67141b39803d6472991a28d43265c55621b60d6f79ef12460944c99c0fe147f5bc2fc558c
7
+ data.tar.gz: 8c5a6341e332a6e42c277bcec38242d2ff682059ec23eb837ddcba771cbbeec0293f920cda80a424c6463693b1f00cf5856ed2ed6b0f4dc00ca81540b0f7a546
data/.travis.yml CHANGED
@@ -1,29 +1,34 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 2.1.10
4
- - 2.3.3
4
+ - 2.5.0
5
5
 
6
6
  gemfile:
7
7
  - gemfiles/Gemfile.cucumber-1.3
8
8
  - gemfiles/Gemfile.cucumber-2.4
9
9
  - gemfiles/Gemfile.cucumber-3.0
10
+ - gemfiles/Gemfile.cucumber-3.1
10
11
 
11
12
  matrix:
12
13
  exclude:
13
- - gemfile: gemfiles/Gemfile.cucumber-3.0
14
- rvm: 2.1.10
14
+ - gemfile: gemfiles/Gemfile.cucumber-3.1
15
+ rvm: 1.8.7
16
+ - gemfile: gemfiles/Gemfile.cucumber-3.1
17
+ rvm: 2.1.10 # cucumber 3 wants ruby >= 2.2
15
18
  - gemfile: gemfiles/Gemfile.cucumber-3.0
16
19
  rvm: 1.8.7
20
+ - gemfile: gemfiles/Gemfile.cucumber-3.0
21
+ rvm: 2.1.10 # cucumber 3 wants ruby >= 2.2
17
22
  - gemfile: gemfiles/Gemfile.cucumber-2.4
18
23
  rvm: 1.8.7
19
24
  - gemfile: gemfiles/Gemfile.cucumber-1.3
20
- rvm: 2.3.3 # doesn't work with old RSpec
25
+ rvm: 2.5.0 # doesn't work with old RSpec
21
26
 
22
27
  install:
23
- # Old Travis CI bundler explodes when lockfile version doesn't match recently bumped version
24
- - gem install bundler --version='=1.12.5'
25
- # This is the default Travis CI install step
26
- - bundle install --jobs=3 --retry=3 --deployment --path=${BUNDLE_PATH:-vendor/bundle}
28
+ # Replace default Travis CI bundler script with a version that doesn't
29
+ # explode when lockfile doesn't match recently bumped version
30
+ - gem update --system
31
+ - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
27
32
 
28
33
  script: bundle exec rake current_rspec
29
34
 
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ ./gemfiles/Gemfile.cucumber-2.4
data/Gemfile.lock ADDED
@@ -0,0 +1 @@
1
+ ./gemfiles/Gemfile.cucumber-2.4.lock
data/README.md CHANGED
@@ -16,17 +16,21 @@ Examples
16
16
 
17
17
  To mark a step definition as overridable, call `#overridable` on the definition object:
18
18
 
19
- Given /^there is a movie with a (.*?) tone$/ do
20
- ...
21
- end.overridable
19
+ ```ruby
20
+ Given /^there is a movie with a (.*?) tone$/ do
21
+ ...
22
+ end.overridable
22
23
 
23
- Given there is a movie with a funny tone do
24
- ...
25
- end
24
+ Given /^there is a movie with a funny tone$/ do
25
+ ...
26
+ end
27
+ ```
26
28
 
27
29
  The following step will now **no longer raise `Cucumber::Ambiguous`**:
28
30
 
29
- Given there is a movie with a funny tone
31
+ ```cucumber
32
+ Given there is a movie with a funny tone
33
+ ```
30
34
 
31
35
  If a step matches more than one non-overridable steps, Cucumber will still raise `Cucumber::Ambiguous`.
32
36
 
@@ -35,13 +39,15 @@ If a step matches more than one non-overridable steps, Cucumber will still raise
35
39
 
36
40
  You can define priorities for overridable steps by passing an numeric `:priority` option to `#overridable:`
37
41
 
38
- Given /^there is a movie with a (.*?) tone$/ do
39
- ...
40
- end.overridable(priority: 1)
42
+ ```ruby
43
+ Given /^there is a movie with a (.*?) tone$/ do
44
+ ...
45
+ end.overridable(priority: 1)
41
46
 
42
- Given /^there is a movie with a (sad|upbeat|disturbing) tone$/ do
43
- ...
44
- end.overridable(priority: 5)
47
+ Given /^there is a movie with a (sad|upbeat|disturbing) tone$/ do
48
+ ...
49
+ end.overridable(priority: 5)
50
+ ```
45
51
 
46
52
  A higher priority wins the match.
47
53
 
@@ -51,7 +57,7 @@ A non-overridable step will always win over an overridable step regardless of it
51
57
  Supported Cucumber versions
52
58
  ----------------------------
53
59
 
54
- cucumber_priority is tested against Cucumber 1.3, 2.4 and 3.0.
60
+ cucumber_priority is tested against Cucumber 1.3, 2.4, 3.0 and 3.1.
55
61
 
56
62
 
57
63
  Installation
@@ -59,7 +65,9 @@ Installation
59
65
 
60
66
  In your `Gemfile` say:
61
67
 
62
- gem 'cucumber_priority'
68
+ ```ruby
69
+ gem 'cucumber_priority'
70
+ ```
63
71
 
64
72
  Now run `bundle install` and restart your server.
65
73
 
@@ -69,7 +77,7 @@ Development
69
77
 
70
78
  There are tests in `spec`. We only accept PRs with tests. To run tests:
71
79
 
72
- - Install Ruby 2.3.3
80
+ - Install Ruby 2.5.0
73
81
  - Install development dependencies using `bundle install`
74
82
  - Run tests using `bundle exec rspec`
75
83
 
@@ -92,4 +100,5 @@ I'm very eager to keep this gem leightweight and on topic. If you're unsure whet
92
100
  Credits
93
101
  -------
94
102
 
95
- Henning Koch from [makandra](http://www.makandra.com/)
103
+ Henning Koch from [makandra](https://makandra.com/)
104
+
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Runtime dependencies
4
4
  gem 'cucumber', '~> 1.3.20'
5
- gem 'activesupport', '~> 2.3.0'
6
5
 
7
6
  # Development dependencies
8
7
  gem 'rspec', '~> 1.0'
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cucumber_priority (0.1.2)
4
+ cucumber_priority (0.2.0)
5
5
  cucumber
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (2.3.18)
11
10
  builder (3.2.2)
12
11
  cucumber (1.3.20)
13
12
  builder (>= 2.1.2)
@@ -28,7 +27,6 @@ PLATFORMS
28
27
  ruby
29
28
 
30
29
  DEPENDENCIES
31
- activesupport (~> 2.3.0)
32
30
  cucumber (~> 1.3.20)
33
31
  cucumber_priority!
34
32
  gemika
@@ -36,4 +34,4 @@ DEPENDENCIES
36
34
  rspec (~> 1.0)
37
35
 
38
36
  BUNDLED WITH
39
- 1.13.7
37
+ 1.16.1
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Runtime dependencies
4
4
  gem 'cucumber', '~> 2.4.0'
5
- gem 'activesupport', '~> 4.2.0'
6
5
 
7
6
  # Development dependencies
8
7
  gem 'rspec', '~> 3.0'
@@ -1,19 +1,13 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cucumber_priority (0.1.2)
4
+ cucumber_priority (0.2.0)
5
5
  cucumber
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (4.2.5.1)
11
- i18n (~> 0.7)
12
- json (~> 1.7, >= 1.7.7)
13
- minitest (~> 5.1)
14
- thread_safe (~> 0.3, >= 0.3.4)
15
- tzinfo (~> 1.1)
16
- builder (3.2.2)
10
+ builder (3.2.3)
17
11
  cucumber (2.4.0)
18
12
  builder (>= 2.1.2)
19
13
  cucumber-core (~> 1.5.0)
@@ -25,13 +19,10 @@ GEM
25
19
  cucumber-core (1.5.0)
26
20
  gherkin (~> 4.0)
27
21
  cucumber-wire (0.0.1)
28
- diff-lcs (1.2.5)
22
+ diff-lcs (1.3)
29
23
  gemika (0.3.2)
30
- gherkin (4.0.0)
31
- i18n (0.7.0)
32
- json (1.8.3)
33
- minitest (5.8.4)
34
- multi_json (1.12.1)
24
+ gherkin (4.1.3)
25
+ multi_json (1.13.1)
35
26
  multi_test (0.1.2)
36
27
  rake (10.1.0)
37
28
  rspec (3.4.0)
@@ -47,15 +38,11 @@ GEM
47
38
  diff-lcs (>= 1.2.0, < 2.0)
48
39
  rspec-support (~> 3.4.0)
49
40
  rspec-support (3.4.1)
50
- thread_safe (0.3.5)
51
- tzinfo (1.2.2)
52
- thread_safe (~> 0.1)
53
41
 
54
42
  PLATFORMS
55
43
  ruby
56
44
 
57
45
  DEPENDENCIES
58
- activesupport (~> 4.2.0)
59
46
  cucumber (~> 2.4.0)
60
47
  cucumber_priority!
61
48
  gemika
@@ -63,4 +50,4 @@ DEPENDENCIES
63
50
  rspec (~> 3.0)
64
51
 
65
52
  BUNDLED WITH
66
- 1.13.7
53
+ 1.16.1
@@ -1,8 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Runtime dependencies
4
- gem 'cucumber', '~> 3.0.0.pre.1'
5
- gem 'activesupport', '~> 5.0.0'
4
+ gem 'cucumber', '~> 3.0.0'
6
5
 
7
6
  # Development dependencies
8
7
  gem 'rspec', '~> 3.0'
@@ -6,30 +6,34 @@ GEM
6
6
  i18n (~> 0.7)
7
7
  minitest (~> 5.1)
8
8
  tzinfo (~> 1.1)
9
- backports (3.6.8)
10
- builder (3.2.2)
9
+ backports (3.11.1)
10
+ builder (3.2.3)
11
11
  concurrent-ruby (1.0.3)
12
- cucumber (3.0.0.pre.1)
12
+ cucumber (3.0.2)
13
13
  builder (>= 2.1.2)
14
- cucumber-core (~> 2.0)
14
+ cucumber-core (~> 3.0.0)
15
+ cucumber-expressions (~> 4.0.3)
15
16
  cucumber-wire (~> 0.0.1)
16
- diff-lcs (>= 1.1.3)
17
+ diff-lcs (~> 1.3)
17
18
  gherkin (~> 4.0)
18
19
  multi_json (>= 1.7.5, < 2.0)
19
20
  multi_test (>= 0.1.2)
20
- cucumber-core (2.0.0)
21
- backports (~> 3.6)
22
- gherkin (~> 4.0)
21
+ cucumber-core (3.0.0)
22
+ backports (>= 3.8.0)
23
+ cucumber-tag_expressions (>= 1.0.1)
24
+ gherkin (>= 4.1.3)
25
+ cucumber-expressions (4.0.4)
26
+ cucumber-tag_expressions (1.1.1)
23
27
  cucumber-wire (0.0.1)
24
28
  cucumber_priority (0.1.2)
25
29
  activesupport
26
30
  cucumber
27
- diff-lcs (1.2.5)
31
+ diff-lcs (1.3)
28
32
  gemika (0.3.2)
29
- gherkin (4.0.0)
33
+ gherkin (4.1.3)
30
34
  i18n (0.7.0)
31
35
  minitest (5.10.1)
32
- multi_json (1.12.1)
36
+ multi_json (1.13.1)
33
37
  multi_test (0.1.2)
34
38
  rake (10.4.2)
35
39
  rspec (3.5.0)
@@ -53,12 +57,11 @@ PLATFORMS
53
57
  ruby
54
58
 
55
59
  DEPENDENCIES
56
- activesupport (~> 5.0.0)
57
- cucumber (~> 3.0.0.pre.1)
60
+ cucumber (~> 3.0.0)
58
61
  cucumber_priority
59
62
  gemika
60
63
  rake
61
64
  rspec (~> 3.0)
62
65
 
63
66
  BUNDLED WITH
64
- 1.13.7
67
+ 1.16.1
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Runtime dependencies
4
+ gem 'cucumber', '~> 3.1.0'
5
+
6
+ # Development dependencies
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'gemika'
9
+ gem 'rake'
10
+
11
+ # Gem under test
12
+ gem 'cucumber_priority'
@@ -0,0 +1,67 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (5.0.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (~> 0.7)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ backports (3.11.1)
10
+ builder (3.2.3)
11
+ concurrent-ruby (1.0.3)
12
+ cucumber (3.1.0)
13
+ builder (>= 2.1.2)
14
+ cucumber-core (~> 3.1.0)
15
+ cucumber-expressions (~> 5.0.4)
16
+ cucumber-wire (~> 0.0.1)
17
+ diff-lcs (~> 1.3)
18
+ gherkin (~> 5.0)
19
+ multi_json (>= 1.7.5, < 2.0)
20
+ multi_test (>= 0.1.2)
21
+ cucumber-core (3.1.0)
22
+ backports (>= 3.8.0)
23
+ cucumber-tag_expressions (~> 1.1.0)
24
+ gherkin (>= 5.0.0)
25
+ cucumber-expressions (5.0.13)
26
+ cucumber-tag_expressions (1.1.1)
27
+ cucumber-wire (0.0.1)
28
+ cucumber_priority (0.1.2)
29
+ activesupport
30
+ cucumber
31
+ diff-lcs (1.3)
32
+ gemika (0.3.2)
33
+ gherkin (5.0.0)
34
+ i18n (0.7.0)
35
+ minitest (5.10.1)
36
+ multi_json (1.13.1)
37
+ multi_test (0.1.2)
38
+ rake (10.4.2)
39
+ rspec (3.5.0)
40
+ rspec-core (~> 3.5.0)
41
+ rspec-expectations (~> 3.5.0)
42
+ rspec-mocks (~> 3.5.0)
43
+ rspec-core (3.5.4)
44
+ rspec-support (~> 3.5.0)
45
+ rspec-expectations (3.5.0)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.5.0)
48
+ rspec-mocks (3.5.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.5.0)
51
+ rspec-support (3.5.0)
52
+ thread_safe (0.3.5)
53
+ tzinfo (1.2.2)
54
+ thread_safe (~> 0.1)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ cucumber (~> 3.1.0)
61
+ cucumber_priority
62
+ gemika
63
+ rake
64
+ rspec (~> 3.0)
65
+
66
+ BUNDLED WITH
67
+ 1.16.1
@@ -1,8 +1,5 @@
1
- require 'cucumber'
2
- require 'cucumber/rb_support/rb_language'
3
-
1
+ require 'cucumber_priority/require_cucumber'
4
2
  require 'cucumber_priority/util'
5
3
  require 'cucumber_priority/ambiguous_error_ext'
6
- require 'cucumber_priority/rb_step_definition_ext'
7
- require 'cucumber_priority/support_code_ext'
8
-
4
+ require 'cucumber_priority/step_definition_ext'
5
+ require 'cucumber_priority/resolve_ambiguous_error'
@@ -0,0 +1,8 @@
1
+ require 'cucumber'
2
+
3
+ if Cucumber::VERSION >= '3'
4
+ require 'cucumber/glue/registry_and_more'
5
+ else
6
+ require 'cucumber/rb_support/rb_language'
7
+ end
8
+
@@ -0,0 +1,92 @@
1
+ module CucumberPriority
2
+ class Resolver
3
+
4
+ def self.resolve_ambiguity_through_priority(e)
5
+ overridable, overriding = e.matches.partition { |match|
6
+ match.step_definition.overridable?
7
+ }
8
+ if overriding.size > 1
9
+ # If we have more than one overriding step definitions,
10
+ # this is an ambiguity error
11
+ raise e
12
+ elsif overriding.size == 1
13
+ # If our ambiguity is due to another overridable step,
14
+ # we can use the overriding step
15
+ overriding
16
+ elsif overriding.size == 0
17
+ # If we have multiple overridable steps, we use the one
18
+ # with the highest priority.
19
+ overridable.sort_by { |match|
20
+ - match.step_definition.priority
21
+ }
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+
28
+ if Cucumber::VERSION >= '3'
29
+
30
+ module Cucumber
31
+ module StepMatchSearch
32
+ class AssertUnambiguousMatch
33
+
34
+ def call_with_priority(*args)
35
+ call_without_priority(*args)
36
+ rescue Ambiguous => e
37
+ CucumberPriority::Resolver.resolve_ambiguity_through_priority(e)
38
+ end
39
+
40
+ CucumberPriority::Util.alias_chain self, :call, :priority
41
+ end
42
+ end
43
+ end
44
+
45
+ elsif Cucumber::VERSION >= '2.3'
46
+
47
+ module Cucumber
48
+ class Runtime
49
+ class SupportCode
50
+
51
+ # Cucumber 2.3 or higher has a single method #step_matches which returns an
52
+ # array of Cucumber::StepMatch objects.
53
+ # This method raises Cucumber::Ambiguous if the array has more than one element.
54
+ def step_matches_with_priority(*args)
55
+ step_matches_without_priority(*args)
56
+ rescue Ambiguous => e
57
+ CucumberPriority::Resolver.resolve_ambiguity_through_priority(e)
58
+ end
59
+
60
+ CucumberPriority::Util.alias_chain self, :step_matches, :priority
61
+ end
62
+ end
63
+ end
64
+
65
+ else
66
+
67
+ module Cucumber
68
+ class Runtime
69
+ class SupportCode
70
+
71
+ # Cucumber 2.1 or lower has a single method #step_match which returns a
72
+ # single Cucumber::StepMatch.
73
+ # This method raises Cucumber::Ambigiuous if there are two or more matches.
74
+ def step_match_with_priority(*args)
75
+ step_match_without_priority(*args)
76
+ rescue Ambiguous => e
77
+ CucumberPriority::Resolver.resolve_ambiguity_through_priority(e).first
78
+ end
79
+
80
+ CucumberPriority::Util.alias_chain self, :step_match, :priority
81
+
82
+ # This method doesn't exist in old Cucumbers.
83
+ # We define it so our specs have a unified API to match steps.
84
+ def step_matches(*args)
85
+ [step_match(*args)]
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,19 @@
1
+ step_definition_class = Cucumber::VERSION >= '3' ? Cucumber::Glue::StepDefinition : Cucumber::RbSupport::RbStepDefinition
2
+
3
+ step_definition_class.class_eval do
4
+
5
+ def overridable(options = {})
6
+ @overridable = true
7
+ @priority = options[:priority]
8
+ self
9
+ end
10
+
11
+ def overridable?
12
+ !!@overridable
13
+ end
14
+
15
+ def priority
16
+ @priority ||= 0
17
+ end
18
+
19
+ end
@@ -1,3 +1,3 @@
1
1
  module CucumberPriority
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -1,22 +1,25 @@
1
1
  def prepare_cucumber_example
2
- @runtime = Cucumber::Runtime.new
3
- language = load_ruby_language
4
- scenario = double('scenario', :language => 'en', :accept_hook? => true)
5
- language.send(:begin_scenario, scenario)
6
- @world = language.current_world
7
- @main = Object.new
8
- @main.extend(Cucumber::RbSupport::RbDsl)
9
- # @runtime.before(scenario)
10
- end
11
-
12
- def load_ruby_language
13
- language = support_code.ruby if support_code.respond_to?(:ruby)
14
- language ||= support_code.load_programming_language('rb')
15
- language
2
+ if Cucumber::VERSION >= '3'
3
+ @runtime = Cucumber::Runtime.new
4
+ scenario = double('scenario', :language => 'en', :accept_hook? => true)
5
+ @runtime.send(:begin_scenario, scenario)
6
+ @main = Object.new
7
+ @main.extend(Cucumber::Glue::Dsl)
8
+ else
9
+ @runtime = Cucumber::Runtime.new
10
+ language = support_code.ruby if support_code.respond_to?(:ruby)
11
+ language ||= support_code.load_programming_language('rb')
12
+ language
13
+ scenario = double('scenario', :language => 'en', :accept_hook? => true)
14
+ language.send(:begin_scenario, scenario)
15
+ @world = language.current_world
16
+ @main = Object.new
17
+ @main.extend(Cucumber::RbSupport::RbDsl)
18
+ end
16
19
  end
17
20
 
18
21
  def invoke_cucumber_step(step)
19
- support_code.step_match(step).invoke(nil) # nil means no multiline args
22
+ first_step_match(step).invoke(nil) # nil means no multiline args
20
23
  end
21
24
 
22
25
  def support_code
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber_priority
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-28 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -36,6 +36,8 @@ files:
36
36
  - ".rspec"
37
37
  - ".ruby-version"
38
38
  - ".travis.yml"
39
+ - Gemfile
40
+ - Gemfile.lock
39
41
  - LICENSE
40
42
  - README.md
41
43
  - Rakefile
@@ -46,10 +48,13 @@ files:
46
48
  - gemfiles/Gemfile.cucumber-2.4.lock
47
49
  - gemfiles/Gemfile.cucumber-3.0
48
50
  - gemfiles/Gemfile.cucumber-3.0.lock
51
+ - gemfiles/Gemfile.cucumber-3.1
52
+ - gemfiles/Gemfile.cucumber-3.1.lock
49
53
  - lib/cucumber_priority.rb
50
54
  - lib/cucumber_priority/ambiguous_error_ext.rb
51
- - lib/cucumber_priority/rb_step_definition_ext.rb
52
- - lib/cucumber_priority/support_code_ext.rb
55
+ - lib/cucumber_priority/require_cucumber.rb
56
+ - lib/cucumber_priority/resolve_ambiguous_error.rb
57
+ - lib/cucumber_priority/step_definition_ext.rb
53
58
  - lib/cucumber_priority/util.rb
54
59
  - lib/cucumber_priority/version.rb
55
60
  - spec/cucumber_priority/support_code_ext_spec.rb
@@ -76,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
81
  version: '0'
77
82
  requirements: []
78
83
  rubyforge_project:
79
- rubygems_version: 2.5.2
84
+ rubygems_version: 2.7.3
80
85
  signing_key:
81
86
  specification_version: 4
82
87
  summary: Overridable step definitions for Cucumber
@@ -1,21 +0,0 @@
1
- module Cucumber
2
- module RbSupport
3
- class RbStepDefinition
4
-
5
- def overridable(options = {})
6
- @overridable = true
7
- @priority = options[:priority]
8
- self
9
- end
10
-
11
- def overridable?
12
- !!@overridable
13
- end
14
-
15
- def priority
16
- @priority ||= 0
17
- end
18
-
19
- end
20
- end
21
- end
@@ -1,64 +0,0 @@
1
- module Cucumber
2
- class Runtime
3
- class SupportCode
4
-
5
- if method_defined?(:step_matches) || private_method_defined?(:step_matches)
6
- # Cucumber 2.3 or higher has a single method #step_matches which returns an
7
- # array of Cucumber::StepMatch objects.
8
- # This method raises Cucumber::Ambiguous if the array has more than one element.
9
-
10
- def step_matches_with_priority(*args)
11
- step_matches_without_priority(*args)
12
- rescue Ambiguous => e
13
- resolve_ambiguity_through_priority(e)
14
- end
15
-
16
- CucumberPriority::Util.alias_chain self, :step_matches, :priority
17
-
18
- else
19
- # Cucumber 2.1 or lower has a single method #step_match which returns a
20
- # single Cucumber::StepMatch.
21
- # This method raises Cucumber::Ambigiuous if there are two or more matches.
22
-
23
- def step_match_with_priority(*args)
24
- step_match_without_priority(*args)
25
- rescue Ambiguous => e
26
- resolve_ambiguity_through_priority(e).first
27
- end
28
-
29
- CucumberPriority::Util.alias_chain self, :step_match, :priority
30
-
31
- # This method doesn't exist in old Cucumbers.
32
- # We define it so our specs have a unified API to match steps.
33
- def step_matches(*args)
34
- [step_match(*args)]
35
- end
36
-
37
- end
38
-
39
- private
40
-
41
- def resolve_ambiguity_through_priority(e)
42
- overridable, overriding = e.matches.partition { |match|
43
- match.step_definition.overridable?
44
- }
45
- if overriding.size > 1
46
- # If we have more than one overriding step definitions,
47
- # this is an ambiguity error
48
- raise e
49
- elsif overriding.size == 1
50
- # If our ambiguity is due to another overridable step,
51
- # we can use the overriding step
52
- overriding
53
- elsif overriding.size == 0
54
- # If we have multiple overridable steps, we use the one
55
- # with the highest priority.
56
- overridable.sort_by { |match|
57
- - match.step_definition.priority
58
- }
59
- end
60
- end
61
-
62
- end
63
- end
64
- end