cuke_modeler 1.2.0 → 1.2.1

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
  SHA1:
3
- metadata.gz: ae2a37ad321f1cf9ea164210a52981ed565a2f5c
4
- data.tar.gz: 2eaf5c8db10ddfba8c9ff2a0a0b61198929d98f7
3
+ metadata.gz: 4779a73d0414df470da374597d5a5db928e9f1fd
4
+ data.tar.gz: fd1e0ab88380b774e1301789d50a89cce58716e8
5
5
  SHA512:
6
- metadata.gz: 9e43d4812d7bb826cc7fabc0a957c6ffd7f8a0b54f518c9ecdea9ebd24e7dd96f63ffb565ecbf58c487eb4c55d5c3953edbcaec7e2a8dce276a88e7bd2b23dd7
7
- data.tar.gz: 738a51078b7c0b4551f5a31670f7c42ec5dece16a8d23ac272d2e25d16bd06244926cfb385f25abf4636b1b371c426ba941bd8009aab9b07438bb179208fbb14
6
+ metadata.gz: '029706fe40a199ddb8b12c90de6c61b61576afab23c29603b43524f22b88c6d4373b52aa059f34f2a495c11f8f787956785684a5145ed5ac0f3dc2ff0bc994a8'
7
+ data.tar.gz: 3e41b0e4310907be62af428dcdc4e511ee783aa82e4aae93f5ec4977cc7724400ba83911b0b2ca5af65a2716e1391750c86e17d2cdda1f2b305a42247112a91a
data/.travis.yml CHANGED
@@ -1,3 +1,7 @@
1
+ os:
2
+ - linux
3
+ - osx
4
+
1
5
  language: ruby
2
6
  rvm:
3
7
  - 1.8.7
@@ -5,19 +9,26 @@ rvm:
5
9
  - 2.0.0
6
10
  - 2.1.6
7
11
  - 2.2.2
12
+ - 2.3.3
13
+ - 2.4.0
14
+ - jruby-9.1.7.0
8
15
 
9
16
  gemfile:
10
17
  - testing/gemfiles/gherkin2.gemfile
11
18
  - testing/gemfiles/gherkin3.gemfile
12
19
  - testing/gemfiles/gherkin4.gemfile
13
20
 
14
-
15
21
  matrix:
16
22
  exclude:
23
+ # gherkin 3.x does not work with Ruby 1.8.x
17
24
  - rvm: 1.8.7
18
25
  gemfile: testing/gemfiles/gherkin3.gemfile
26
+ # gherkin 4.x does not work with Ruby 1.8.x
19
27
  - rvm: 1.8.7
20
28
  gemfile: testing/gemfiles/gherkin4.gemfile
29
+ # Travis does not provide 1.8.7 on OSX
30
+ - rvm: 1.8.7
31
+ os: osx
21
32
 
22
33
  # todo - Remove this once TravisCI fixes their bundler issue (https://github.com/alphagov/govuk_template/pull/186)
23
34
  before_install:
data/Gemfile CHANGED
@@ -4,24 +4,25 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
- if RUBY_VERSION =~ /^1\.8/
8
- gem 'cucumber', '<1.3.0'
9
- gem 'gherkin', '<2.12.0'
10
- gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
11
- elsif RUBY_VERSION =~ /^1\./
12
- gem 'cucumber', '<2.0.0'
13
- end
14
7
 
15
8
  if RUBY_VERSION =~ /^1\./
9
+
16
10
  gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
17
11
  gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
18
12
  gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
19
- end
20
13
 
21
- if RUBY_VERSION =~ /^2\./
14
+ if RUBY_VERSION =~ /^1\.8/
15
+ gem 'cucumber', '~> 1.0' # Ruby 1.8.x support dropped after this version
16
+ gem 'gherkin', '< 2.12.1' # Ruby 1.8.x support dropped after this version
17
+ gem 'rake', '< 11.0' # Ruby 1.8.x support dropped after this version
18
+ end
19
+
20
+ elsif RUBY_VERSION =~ /^2\./
21
+
22
+ if RUBY_VERSION =~ /^2\.[23456789]/
23
+ gem 'test-unit'
24
+ end
25
+
22
26
  gem 'gherkin', '~> 4.0'
23
- end
24
27
 
25
- if RUBY_VERSION =~ /^2\.[23456789]/
26
- gem 'test-unit'
27
28
  end
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### Version 1.2.1 / 2017-04-25
2
+
3
+ * Now officially compatible with Rake 12.x.
4
+
5
+
1
6
  ### Version 1.2.0 / 2016-11-23
2
7
 
3
8
  * The comments in a feature file are now a modeled element.
@@ -139,7 +144,7 @@
139
144
  being populated if the instance was given a diretory to model.
140
145
 
141
146
  * Bug fix - Fixed a bug that occurred if a Directory object was asked for its
142
- #name when it was created as 'abstract' instead of modeling an existing
147
+ \#name when it was created as 'abstract' instead of modeling an existing
143
148
  directory.
144
149
 
145
150
 
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Eric Kessler
1
+ Copyright (c) 2014-2017 Eric Kessler, et al
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/cuke_modeler.svg)](https://rubygems.org/gems/cuke_modeler)
2
- [![Build Status](https://travis-ci.org/enkessler/cuke_modeler.svg?branch=dev)](https://travis-ci.org/enkessler/cuke_modeler)
3
2
  [![Dependency Status](https://gemnasium.com/enkessler/cuke_modeler.svg)](https://gemnasium.com/enkessler/cuke_modeler)
4
-
3
+ [![Build Status](https://travis-ci.org/enkessler/cuke_modeler.svg?branch=dev)](https://travis-ci.org/enkessler/cuke_modeler)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/is8xqvoqn3pjh9l0/branch/dev?svg=true)](https://ci.appveyor.com/project/enkessler/cuke-modeler/branch/dev)
5
+ [![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_modeler/badge.svg?branch=dev)](https://coveralls.io/github/enkessler/cuke_modeler?branch=dev)
6
+ [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
5
7
 
6
8
 
7
9
  # CukeModeler
data/appveyor.yml ADDED
@@ -0,0 +1,47 @@
1
+ version: '1.0.{build}'
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 187-x64
6
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
7
+ - RUBY_VERSION: 193-x64
8
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
9
+ - RUBY_VERSION: 200-x64
10
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
11
+ - RUBY_VERSION: 21-x64
12
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
13
+ - RUBY_VERSION: 22-x64
14
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
15
+
16
+ - RUBY_VERSION: 193-x64
17
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
18
+ - RUBY_VERSION: 200-x64
19
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
20
+ - RUBY_VERSION: 21-x64
21
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
22
+ - RUBY_VERSION: 22-x64
23
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
24
+
25
+ - RUBY_VERSION: 193-x64
26
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
27
+ - RUBY_VERSION: 200-x64
28
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
29
+ - RUBY_VERSION: 21-x64
30
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
31
+ - RUBY_VERSION: 22-x64
32
+ BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
33
+
34
+
35
+ install:
36
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
37
+ - bundle install
38
+
39
+ build: off
40
+
41
+ before_test:
42
+ - ruby -v
43
+ - gem -v
44
+ - bundle -v
45
+
46
+ test_script:
47
+ - bundle exec rake
data/cuke_modeler.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency('multi_json', '~> 1.0')
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.5"
26
- spec.add_development_dependency "rake", '< 12.0.0'
26
+ spec.add_development_dependency "rake", '< 13.0.0'
27
27
  spec.add_development_dependency 'cucumber', '< 3.0.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'simplecov', '< 1.0.0'
@@ -263,7 +263,7 @@ module CukeModeler
263
263
  when 'scenario_outline'
264
264
  adapt_outline!(element, gathered_comments)
265
265
  else
266
- raise("Unknown element type: #{element['type']}")
266
+ raise(ArgumentError, "Unknown element type: #{element['type']}")
267
267
  end
268
268
  end
269
269
  end
@@ -75,12 +75,6 @@ module CukeModeler
75
75
  populate_source_line(table_object, parsed_table_data)
76
76
  end
77
77
 
78
- def populate_tablerow(row_object, parsed_row_data)
79
- populate_source_line(row_object, parsed_row_data)
80
- populate_row_cells(row_object, parsed_row_data)
81
- populate_parsing_data(row_object, parsed_row_data)
82
- end
83
-
84
78
  def populate_cell(cell_object, parsed_cell_data)
85
79
  populate_cell_value(cell_object, parsed_cell_data)
86
80
  populate_source_line(cell_object, parsed_cell_data)
@@ -18,8 +18,8 @@ module CukeModeler
18
18
  # The *gherkin* gem loads differently and has different grammar rules across major versions. Parsing
19
19
  # will be done with an 'adapter' appropriate to the version of the *gherkin* gem that has been activated.
20
20
 
21
- case
22
- when Gem.loaded_specs['gherkin'].version.version[/^4/]
21
+ case Gem.loaded_specs['gherkin'].version.version
22
+ when /^4\./
23
23
  require 'gherkin/parser'
24
24
  require 'cuke_modeler/adapters/gherkin_4_adapter'
25
25
 
@@ -33,7 +33,7 @@ module CukeModeler
33
33
  CukeModeler::Gherkin4Adapter
34
34
  end
35
35
 
36
- when Gem.loaded_specs['gherkin'].version.version[/^3/]
36
+ when /^3\./
37
37
  require 'gherkin/parser'
38
38
  require 'cuke_modeler/adapters/gherkin_3_adapter'
39
39
 
@@ -85,7 +85,7 @@ module CukeModeler
85
85
  # The dialects currently known by the gherkin gem
86
86
  def dialects
87
87
  unless @dialects
88
- @dialects = Gem.loaded_specs['gherkin'].version.version[/^2/] ? Gherkin::I18n::LANGUAGES : Gherkin::DIALECTS
88
+ @dialects = Gem.loaded_specs['gherkin'].version.version[/^2\./] ? Gherkin::I18n::LANGUAGES : Gherkin::DIALECTS
89
89
  end
90
90
 
91
91
  @dialects
@@ -1,4 +1,4 @@
1
1
  module CukeModeler
2
2
  # The gem version
3
- VERSION = "1.2.0"
3
+ VERSION = '1.2.1'
4
4
  end
@@ -1,22 +1,25 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec :path => "../../"
4
- gem "gherkin", "< 3.0.0"
4
+ gem "gherkin", "~> 2.0"
5
5
 
6
6
  # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
- if RUBY_VERSION =~ /^1\.8/
8
- gem 'cucumber', '<1.3.0'
9
- gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
10
- elsif RUBY_VERSION =~ /^1\./
11
- gem 'cucumber', '>=1.0.0', '<2.0.0'
12
- end
13
7
 
14
8
  if RUBY_VERSION =~ /^1\./
9
+
15
10
  gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
16
11
  gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
17
12
  gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
18
- end
19
13
 
20
- if RUBY_VERSION =~ /^2\.[23456789]/
21
- gem 'test-unit'
14
+ if RUBY_VERSION =~ /^1\.8/
15
+ gem 'cucumber', '~> 1.0' # Ruby 1.8.x support dropped after this version
16
+ gem 'rake', '< 11.0' # Ruby 1.8.x support dropped after this version
17
+ end
18
+
19
+ elsif RUBY_VERSION =~ /^2\./
20
+
21
+ if RUBY_VERSION =~ /^2\.[23456789]/
22
+ gem 'test-unit'
23
+ end
24
+
22
25
  end
@@ -4,17 +4,17 @@ gemspec :path => "../../"
4
4
  gem "gherkin", "~> 3.0"
5
5
 
6
6
  # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
- if RUBY_VERSION =~ /^1\.8/
8
- gem 'cucumber', '<1.3.0'
9
- gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
10
- end
11
7
 
12
8
  if RUBY_VERSION =~ /^1\./
9
+
13
10
  gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
14
11
  gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
15
12
  gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
16
- end
17
13
 
18
- if RUBY_VERSION =~ /^2\.[23456789]/
19
- gem 'test-unit'
14
+ elsif RUBY_VERSION =~ /^2\./
15
+
16
+ if RUBY_VERSION =~ /^2\.[23456789]/
17
+ gem 'test-unit'
18
+ end
19
+
20
20
  end
@@ -4,17 +4,17 @@ gemspec :path => "../../"
4
4
  gem "gherkin", "~> 4.0"
5
5
 
6
6
  # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
- if RUBY_VERSION =~ /^1\.8/
8
- gem 'cucumber', '<1.3.0'
9
- gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
10
- end
11
7
 
12
8
  if RUBY_VERSION =~ /^1\./
9
+
13
10
  gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
14
11
  gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
15
12
  gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
16
- end
17
13
 
18
- if RUBY_VERSION =~ /^2\.[23456789]/
19
- gem 'test-unit'
14
+ elsif RUBY_VERSION =~ /^2\./
15
+
16
+ if RUBY_VERSION =~ /^2\.[23456789]/
17
+ gem 'test-unit'
18
+ end
19
+
20
20
  end
@@ -169,7 +169,7 @@ describe 'FeatureFile, Integration' do
169
169
  '# row comment']
170
170
 
171
171
  # gherkin 2.x 'loses' comments that are not followed by some element
172
- expected_comments << '# final comment' unless Gem.loaded_specs['gherkin'].version.version[/^2/]
172
+ expected_comments << '# final comment' unless Gem.loaded_specs['gherkin'].version.version[/^2\./]
173
173
 
174
174
 
175
175
  expect(comments).to match_array(expected_comments)
@@ -599,4 +599,43 @@ describe 'Feature, Integration' do
599
599
 
600
600
  end
601
601
 
602
+
603
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
604
+
605
+ it 'provides a useful explosion message if it encounters an entirely new type of feature child' do
606
+ begin
607
+ $old_method = CukeModeler::Parsing.method(:parse_text)
608
+
609
+
610
+ # Monkey patch the parsing method to mimic what would essentially be Gherkin creating new types of language objects
611
+ module CukeModeler
612
+ module Parsing
613
+ class << self
614
+ def parse_text(source_text, filename)
615
+ result = $old_method.call(source_text, filename)
616
+
617
+ result.first['feature']['elements'].first['type'] = :some_unknown_type
618
+
619
+ result
620
+ end
621
+ end
622
+ end
623
+ end
624
+
625
+
626
+ expect { clazz.new("#{@feature_keyword}:\n#{@scenario_keyword}:\n#{@step_keyword} foo") }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
627
+ ensure
628
+ # Making sure that our changes don't escape a test and ruin the rest of the suite
629
+ module CukeModeler
630
+ module Parsing
631
+ class << self
632
+ define_method(:parse_text, $old_method)
633
+ end
634
+ end
635
+ end
636
+ end
637
+ end
638
+
639
+ end
640
+
602
641
  end
@@ -3,6 +3,8 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
3
3
 
4
4
  describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
5
5
 
6
+ let(:clazz) { CukeModeler::Gherkin2Adapter }
7
+ let(:adapter) { clazz.new }
6
8
  let(:source_text) { "# feature comment
7
9
  @tag1 @tag2 @tag3
8
10
  #{@feature_keyword}: A feature with everything it could have
@@ -66,9 +68,9 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
66
68
  | value |
67
69
  # final comment" }
68
70
  let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
69
- File.open(path, "w") { |file| file.puts source_text }
71
+ File.open(path, "w") { |file| file.puts source_text }
70
72
 
71
- CukeModeler::FeatureFile.new(path) }
73
+ CukeModeler::FeatureFile.new(path) }
72
74
  let(:feature) { feature_file.feature }
73
75
 
74
76
 
@@ -152,4 +154,15 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
152
154
  expect(model.parsing_data['cells']).to be_nil
153
155
  end
154
156
 
157
+
158
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
159
+
160
+ it 'provides a useful explosion message if it encounters an entirely new type of test' do
161
+ partial_feature_ast = {"elements" => [{"type" => "some_unknown_type"}]}
162
+
163
+ expect { adapter.adapt_feature!(partial_feature_ast, []) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
164
+ end
165
+
166
+ end
167
+
155
168
  end
@@ -3,6 +3,8 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
3
3
 
4
4
  describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
5
5
 
6
+ let(:clazz) { CukeModeler::Gherkin3Adapter }
7
+ let(:adapter) { clazz.new }
6
8
  let(:source_text) { "# feature comment
7
9
  @tag1 @tag2 @tag3
8
10
  #{@feature_keyword}: A feature with everything it could have
@@ -66,9 +68,9 @@ describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
66
68
  | value |
67
69
  # final comment" }
68
70
  let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
69
- File.open(path, "w") { |file| file.puts source_text }
71
+ File.open(path, "w") { |file| file.puts source_text }
70
72
 
71
- CukeModeler::FeatureFile.new(path) }
73
+ CukeModeler::FeatureFile.new(path) }
72
74
  let(:feature) { feature_file.feature }
73
75
 
74
76
 
@@ -146,4 +148,21 @@ describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
146
148
  expect(model.parsing_data[:cells]).to be_nil
147
149
  end
148
150
 
151
+
152
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
153
+
154
+ it 'provides a useful explosion message if it encounters an entirely new type of test' do
155
+ partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :scenarioDefinitions => [{:type => :some_unknown_type}]}
156
+
157
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
158
+ end
159
+
160
+ it 'provides a useful explosion message if it encounters an entirely new type of step block' do
161
+ partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :scenarioDefinitions => [{:type => :Scenario, :tags => [], :location => {:line => 1, :column => 1}, :steps => [{:type => :Step, :location => {:line => 1, :column => 1}, :argument => {:type => :some_unknown_type, :location => {:line => 1, :column => 1}, :content => ""}}]}]}
162
+
163
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
164
+ end
165
+
166
+ end
167
+
149
168
  end
@@ -3,6 +3,8 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
3
3
 
4
4
  describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
5
5
 
6
+ let(:clazz) { CukeModeler::Gherkin4Adapter }
7
+ let(:adapter) { clazz.new }
6
8
  let(:source_text) { "# feature comment
7
9
  @tag1 @tag2 @tag3
8
10
  #{@feature_keyword}: A feature with everything it could have
@@ -66,9 +68,9 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
66
68
  | value |
67
69
  # final comment" }
68
70
  let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
69
- File.open(path, "w") { |file| file.puts source_text }
71
+ File.open(path, "w") { |file| file.puts source_text }
70
72
 
71
- CukeModeler::FeatureFile.new(path) }
73
+ CukeModeler::FeatureFile.new(path) }
72
74
  let(:feature) { feature_file.feature }
73
75
 
74
76
 
@@ -145,4 +147,21 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
145
147
  expect(model.parsing_data[:cells]).to be_nil
146
148
  end
147
149
 
150
+
151
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
152
+
153
+ it 'provides a useful explosion message if it encounters an entirely new type of test' do
154
+ partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:type => :some_unknown_type}]}
155
+
156
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
157
+ end
158
+
159
+ it 'provides a useful explosion message if it encounters an entirely new type of step block' do
160
+ partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:type => :Scenario, :tags => [], :location => {:line => 1, :column => 1}, :steps => [{:type => :Step, :location => {:line => 1, :column => 1}, :argument => {:type => :some_unknown_type, :location => {:line => 1, :column => 1}, :content => ""}}]}]}
161
+
162
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
163
+ end
164
+
165
+ end
166
+
148
167
  end
@@ -43,7 +43,7 @@ describe 'Parsing, Integration' do
43
43
  end
44
44
 
45
45
  it 'includes the type of object provided when raising an non-string exception' do
46
- expect { nodule.parse_text(5) }.to raise_error(ArgumentError, /Fixnum/)
46
+ expect { nodule.parse_text(:not_a_string) }.to raise_error(ArgumentError, /Symbol/)
47
47
  end
48
48
 
49
49
  # todo - Stop doing this. Just return a feature file rooted AST.
@@ -62,44 +62,35 @@ describe 'Parsing, Integration' do
62
62
 
63
63
  it 'includes the underlying error message in the error that it raises' do
64
64
  begin
65
+ $old_method = CukeModeler::Parsing.method(:parsing_method)
66
+
65
67
  # Custom error type in order to ensure that we are throwing the correct thing
66
68
  module CukeModeler
67
69
  class TestError < StandardError
68
70
  end
69
71
  end
70
72
 
71
- # Monkey patch Gherkin to throw the error that we need for testing
72
- if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
73
- old_method = Gherkin::Parser.instance_method(:parse)
74
-
75
- module Gherkin
76
- class Parser
77
- def parse(*args)
73
+ # Monkey patch the parsing method to throw the error that we need for testing
74
+ module CukeModeler
75
+ module Parsing
76
+ class << self
77
+ def parsing_method(*args)
78
78
  raise(CukeModeler::TestError, 'something went wrong')
79
79
  end
80
80
  end
81
81
  end
82
- else
83
- old_method = Gherkin::Parser::Parser.instance_method(:parse)
84
-
85
- module Gherkin
86
- module Parser
87
- class Parser
88
- def parse(*args)
89
- raise(CukeModeler::TestError, 'something went wrong')
90
- end
91
- end
92
- end
93
- end
94
82
  end
95
83
 
84
+
96
85
  expect { nodule.parse_text('bad file') }.to raise_error(/CukeModeler::TestError.*something went wrong/)
97
86
  ensure
98
87
  # Making sure that our changes don't escape a test and ruin the rest of the suite
99
- if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
100
- Gherkin::Parser.send(:define_method, :parse, old_method)
101
- else
102
- Gherkin::Parser::Parser.send(:define_method, :parse, old_method)
88
+ module CukeModeler
89
+ module Parsing
90
+ class << self
91
+ define_method(:parsing_method, $old_method)
92
+ end
93
+ end
103
94
  end
104
95
  end
105
96
 
@@ -28,7 +28,7 @@ require "#{this_dir}/../../dialect_helper"
28
28
 
29
29
  # Use a fake dialect for testing in order to avoid hard coded language assumptions in the
30
30
  # implementation. Only possible with newer versions of Gherkin.
31
- if Gem.loaded_specs['gherkin'].version.version[/^2/]
31
+ if Gem.loaded_specs['gherkin'].version.version[/^2\./]
32
32
  CukeModeler::DialectHelper.set_dialect(Gherkin::I18n::LANGUAGES['en'])
33
33
  CukeModeler::Parsing.dialect = 'en'
34
34
  else
@@ -58,12 +58,12 @@ end
58
58
 
59
59
 
60
60
  RSpec.configure do |config|
61
- case
62
- when Gem.loaded_specs['gherkin'].version.version[/^4/]
61
+ case Gem.loaded_specs['gherkin'].version.version
62
+ when /^4\./
63
63
  config.filter_run_excluding :gherkin2 => true,
64
64
  :gherkin3 => true,
65
65
  :gherkin4 => false
66
- when Gem.loaded_specs['gherkin'].version.version[/^3/]
66
+ when /^3\./
67
67
  config.filter_run_excluding :gherkin2 => true,
68
68
  :gherkin3 => false,
69
69
  :gherkin4 => true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke_modeler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2017-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "<"
80
80
  - !ruby/object:Gem::Version
81
- version: 12.0.0
81
+ version: 13.0.0
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 12.0.0
88
+ version: 13.0.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: cucumber
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +176,7 @@ files:
176
176
  - LICENSE.txt
177
177
  - README.md
178
178
  - Rakefile
179
+ - appveyor.yml
179
180
  - cuke_modeler.gemspec
180
181
  - lib/cuke_modeler.rb
181
182
  - lib/cuke_modeler/adapters/gherkin_2_adapter.rb
@@ -335,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
336
  version: '0'
336
337
  requirements: []
337
338
  rubyforge_project:
338
- rubygems_version: 2.6.7
339
+ rubygems_version: 2.5.2
339
340
  signing_key:
340
341
  specification_version: 4
341
342
  summary: A gem providing functionality to model Gherkin based test suites.