turnip 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a59580b87380af8ed65f28bbf63b84171876664c96ffc1e81009a3033d1f32e7
4
- data.tar.gz: d568dbc64bca7044c98afb479134a5244c06e80474c6066ebb09ddcd0207ca2f
3
+ metadata.gz: 4140426c0b56837adcc9a4e2e9535fcbfd265aa53067be71f74475a03c06eafb
4
+ data.tar.gz: bd0e23b3d6f26c8755345147fdd2c455f09302ac645a0bafcd17e38ad2e713d1
5
5
  SHA512:
6
- metadata.gz: eb67ee8bdabf25f05038ad6462b8db8251981f703ab75517878ae182453a839eae215ad51072cc5aae3af98ea848fad22917dfa7d91866eb663fe8bfa2fa4b94
7
- data.tar.gz: 276b89661b54b1c960bf34bf239dddd53fea4a6fd1625d1c793eb25fefb730ece59047728081174f75fb5681befba78447ecd7256653ffe00a836ee6972cea9f
6
+ metadata.gz: 7a98529bd8e3e2021baeadf51a4a2b94164b34127953612e4010b4fd0e937f5afbc664b881d458e143dcd74a38d290ead78159cc8d017fcb34282bc33cc21bee
7
+ data.tar.gz: 687d9f88818ddb37c2143a9b97165104fd612fd8a35d1783df834c45727a55df64ae31748fe085e8b7f2ec7954d41e5012fe70553f8fa5f9223982ec9d31332d
data/README.md CHANGED
@@ -425,6 +425,17 @@ step "there are the following monsters:" do |table|
425
425
  end
426
426
  ```
427
427
 
428
+ or the equivalent:
429
+
430
+ ``` ruby
431
+ step "there are the following monsters:" do |table|
432
+ @monsters = {}
433
+ table.rows.each do |(name, hp)|
434
+ @monsters[name] = hp.to_i
435
+ end
436
+ end
437
+ ```
438
+
428
439
  ## Unimplemented steps
429
440
  Turnip mark a scenario as pending when steps in the scenario is not implemented.
430
441
  If you sets `raise_error_for_unimplemented_steps` as `true`, turnip will mark a scenario as fail.
@@ -1,11 +1,16 @@
1
- require "gherkin/gherkin"
1
+ require "gherkin"
2
2
  require 'turnip/node/feature'
3
3
 
4
4
  module Turnip
5
5
  class Builder
6
6
  def self.build(feature_file)
7
- messages = Gherkin::Gherkin.from_paths([feature_file], include_source: false, include_pickles: false)
8
- result = messages.first&.gherkinDocument&.to_hash
7
+ messages = Gherkin.from_paths(
8
+ [feature_file],
9
+ include_source: false,
10
+ include_gherkin_document: true,
11
+ include_pickles: false
12
+ )
13
+ result = messages.first&.gherkin_document&.to_hash
9
14
 
10
15
  return nil if result.nil? || result[:feature].nil?
11
16
  Node::Feature.new(result[:feature])
@@ -33,7 +33,7 @@ module Turnip
33
33
  end
34
34
 
35
35
  unless child[:scenario].nil?
36
- klass = child[:scenario][:examples].empty? ? Scenario : ScenarioOutline
36
+ klass = child.dig(:scenario, :examples).nil? ? Scenario : ScenarioOutline
37
37
  next klass.new(child[:scenario])
38
38
  end
39
39
 
@@ -22,7 +22,7 @@ module Turnip
22
22
  end
23
23
 
24
24
  unless child[:scenario].nil?
25
- klass = child[:scenario][:examples].empty? ? Scenario : ScenarioOutline
25
+ klass = child.dig(:scenario, :examples).nil? ? Scenario : ScenarioOutline
26
26
  next klass.new(child[:scenario])
27
27
  end
28
28
  end.compact
@@ -22,7 +22,7 @@ module Turnip
22
22
  # @return [Array] Array of Tag
23
23
  #
24
24
  def tags
25
- @tags ||= @raw[:tags].map do |tag|
25
+ @tags ||= @raw.fetch(:tags, []).map do |tag|
26
26
  Tag.new(tag)
27
27
  end
28
28
  end
@@ -4,6 +4,11 @@ module Turnip
4
4
 
5
5
  class << self
6
6
  def add(name, &block)
7
+ if placeholders.key?(name)
8
+ location = caller_locations.detect { |l| l.to_s !~ /lib\/turnip\/dsl\.rb/ }
9
+ warn "Placeholder :#{name} was replaced at #{location}."
10
+ end
11
+
7
12
  placeholders[name] = Placeholder.new(name, &block)
8
13
  end
9
14
 
@@ -1,3 +1,3 @@
1
1
  module Turnip
2
- VERSION = '4.0.1'
2
+ VERSION = '4.1.0'
3
3
  end
@@ -9,6 +9,8 @@ describe Turnip::Placeholder do
9
9
  end
10
10
  end
11
11
 
12
+ after { Turnip::Placeholder.send(:placeholders).clear }
13
+
12
14
  it 'returns a regexp for the given placeholder' do
13
15
  resolved = described_class.resolve(:test)
14
16
 
@@ -150,4 +152,19 @@ describe Turnip::Placeholder do
150
152
  end
151
153
  end
152
154
  end
155
+
156
+ describe 'replacing placeholders' do
157
+ before do
158
+ described_class.add(:test) do
159
+ match(/foo/)
160
+ end
161
+ end
162
+
163
+ it 'issues a warning' do
164
+ expect(described_class).to receive(:warn).with(/Placeholder :test was replaced/)
165
+ described_class.add(:test) do
166
+ match(/bar/)
167
+ end
168
+ end
169
+ end
153
170
  end
@@ -3,6 +3,8 @@ require "spec_helper"
3
3
  describe Turnip::StepDefinition do
4
4
  let(:all_steps) { [] }
5
5
 
6
+ after { Turnip::Placeholder.send(:placeholders).clear }
7
+
6
8
  describe "#match" do
7
9
  it "matches a simple step" do
8
10
  step = Turnip::StepDefinition.new("there are monsters") {}
@@ -13,15 +13,13 @@ Gem::Specification.new do |s|
13
13
  s.summary = %q{Gherkin extension for RSpec}
14
14
  s.description = %q{Provides the ability to define steps and run Gherkin files from with RSpec}
15
15
 
16
- s.rubyforge_project = "turnip"
17
-
18
16
  s.files = `git ls-files`.split("\n")
19
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
19
  s.require_paths = ["lib"]
22
20
 
23
21
  s.add_runtime_dependency "rspec", [">=3.0", "<4.0"]
24
- s.add_runtime_dependency "gherkin", "~> 6.0.17"
22
+ s.add_runtime_dependency "cucumber-gherkin", "~> 10.0"
25
23
  s.add_development_dependency "rake"
26
24
  s.add_development_dependency "pry"
27
25
  s.add_development_dependency "pry-byebug"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turnip
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2020-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -31,19 +31,19 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
33
33
  - !ruby/object:Gem::Dependency
34
- name: gherkin
34
+ name: cucumber-gherkin
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 6.0.17
39
+ version: '10.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 6.0.17
46
+ version: '10.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -182,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  requirements: []
185
- rubyforge_project: turnip
186
- rubygems_version: 2.7.3
185
+ rubygems_version: 3.0.3
187
186
  signing_key:
188
187
  specification_version: 4
189
188
  summary: Gherkin extension for RSpec