cuke_modeler 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +51 -33
  3. data/CHANGELOG.md +13 -2
  4. data/Gemfile +9 -2
  5. data/appveyor.yml +29 -2
  6. data/cuke_modeler.gemspec +1 -1
  7. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +1 -1
  8. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +307 -0
  10. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +12 -0
  11. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +12 -0
  12. data/lib/cuke_modeler/parsing.rb +116 -108
  13. data/lib/cuke_modeler/version.rb +1 -1
  14. data/testing/gemfiles/gherkin7.gemfile +9 -0
  15. data/testing/gemfiles/gherkin8.gemfile +9 -0
  16. data/testing/gemfiles/gherkin9.gemfile +9 -0
  17. data/testing/helper_methods.rb +23 -0
  18. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +1 -1
  19. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +1 -1
  20. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +1 -1
  21. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +165 -0
  22. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +1 -8
  23. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +162 -0
  24. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +162 -0
  25. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +162 -0
  26. data/testing/rspec/spec/integration/models/background_integration_spec.rb +19 -23
  27. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +27 -24
  28. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +26 -23
  29. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +19 -23
  30. data/testing/rspec/spec/integration/models/example_integration_spec.rb +50 -38
  31. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +32 -28
  32. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +28 -23
  33. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +39 -44
  34. data/testing/rspec/spec/integration/models/row_integration_spec.rb +35 -23
  35. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +19 -23
  36. data/testing/rspec/spec/integration/models/step_integration_spec.rb +51 -47
  37. data/testing/rspec/spec/integration/models/table_integration_spec.rb +19 -23
  38. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +35 -23
  39. data/testing/rspec/spec/integration/parsing_integration_spec.rb +27 -6
  40. data/testing/rspec/spec/spec_helper.rb +39 -46
  41. metadata +16 -4
@@ -21,36 +21,32 @@ describe 'Table, Integration' do
21
21
  expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_table\.feature'/)
22
22
  end
23
23
 
24
- it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
25
- table = clazz.new("| a table |")
26
- data = table.parsing_data
24
+ describe 'parsing data' do
27
25
 
28
- expect(data.keys).to match_array([:location, :rows])
29
- expect(data[:location][:line]).to eq(5)
30
- end
26
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
27
+ table = clazz.new("| a table |")
28
+ data = table.parsing_data
31
29
 
32
- it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
33
- table = clazz.new("| a table |")
34
- data = table.parsing_data
30
+ expect(data.keys).to match_array([:location, :rows])
31
+ expect(data[:location][:line]).to eq(5)
32
+ end
35
33
 
36
- expect(data.keys).to match_array([:type, :location, :rows])
37
- expect(data[:type]).to eq(:DataTable)
38
- end
34
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(3, 4, 5) do
35
+ table = clazz.new("| a table |")
36
+ data = table.parsing_data
39
37
 
40
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
41
- table = clazz.new("| a table |")
42
- data = table.parsing_data
38
+ expect(data.keys).to match_array([:type, :location, :rows])
39
+ expect(data[:type]).to eq(:DataTable)
40
+ end
43
41
 
44
- expect(data.keys).to match_array([:type, :location, :rows])
45
- expect(data[:type]).to eq(:DataTable)
46
- end
42
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
43
+ table = clazz.new("| a table |")
44
+ data = table.parsing_data
47
45
 
48
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
49
- table = clazz.new("| a table |")
50
- data = table.parsing_data
46
+ # There is no parsing data for the table itself, only its rows
47
+ expect(data).to match_array([])
48
+ end
51
49
 
52
- # There is no parsing data for the table itself, only its rows
53
- expect(data).to match_array([])
54
50
  end
55
51
 
56
52
  it 'can be instantiated with the minimum viable Gherkin' do
@@ -43,36 +43,48 @@ describe 'Tag, Integration' do
43
43
  expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_tag\.feature'/)
44
44
  end
45
45
 
46
- it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
47
- tag = clazz.new('@a_tag')
48
- data = tag.parsing_data
46
+ describe 'parsing data' do
49
47
 
50
- expect(data.keys).to match_array([:location, :name])
51
- expect(data[:name]).to eq('@a_tag')
52
- end
48
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(8, 9) do
49
+ tag = clazz.new('@a_tag')
50
+ data = tag.parsing_data
53
51
 
54
- it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
55
- tag = clazz.new('@a_tag')
56
- data = tag.parsing_data
52
+ expect(data.keys).to match_array([:location, :name, :id])
53
+ expect(data[:name]).to eq('@a_tag')
54
+ end
57
55
 
58
- expect(data.keys).to match_array([:type, :location, :name])
59
- expect(data[:type]).to eq(:Tag)
60
- end
56
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7) do
57
+ tag = clazz.new('@a_tag')
58
+ data = tag.parsing_data
61
59
 
62
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
63
- tag = clazz.new('@a_tag')
64
- data = tag.parsing_data
60
+ expect(data.keys).to match_array([:location, :name])
61
+ expect(data[:name]).to eq('@a_tag')
62
+ end
65
63
 
66
- expect(data.keys).to match_array([:type, :location, :name])
67
- expect(data[:type]).to eq('Tag')
68
- end
64
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
65
+ tag = clazz.new('@a_tag')
66
+ data = tag.parsing_data
67
+
68
+ expect(data.keys).to match_array([:type, :location, :name])
69
+ expect(data[:type]).to eq(:Tag)
70
+ end
71
+
72
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
73
+ tag = clazz.new('@a_tag')
74
+ data = tag.parsing_data
75
+
76
+ expect(data.keys).to match_array([:type, :location, :name])
77
+ expect(data[:type]).to eq('Tag')
78
+ end
79
+
80
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
81
+ tag = clazz.new('@a_tag')
82
+ data = tag.parsing_data
69
83
 
70
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
71
- tag = clazz.new('@a_tag')
72
- data = tag.parsing_data
84
+ expect(data.keys).to match_array(['name', 'line'])
85
+ expect(data['name']).to eq('@a_tag')
86
+ end
73
87
 
74
- expect(data.keys).to match_array(['name', 'line'])
75
- expect(data['name']).to eq('@a_tag')
76
88
  end
77
89
 
78
90
 
@@ -21,15 +21,11 @@ describe 'Parsing, Integration' do
21
21
  end
22
22
  end
23
23
 
24
- it 'loads the correct dialects based on the version of Gherkin used', :gherkin6 => true do
24
+ it 'loads the correct dialects based on the version of Gherkin used', :unless => gherkin?(2) do
25
25
  expect(nodule.dialects).to equal(Gherkin::DIALECTS)
26
26
  end
27
27
 
28
- it 'loads the correct dialects based on the version of Gherkin used', :gherkin3 => true, :gherkin4_5 => true do
29
- expect(nodule.dialects).to equal(Gherkin::DIALECTS)
30
- end
31
-
32
- it 'loads the correct dialects based on the version of Gherkin used', :gherkin2 => true do
28
+ it 'loads the correct dialects based on the version of Gherkin used', :if => gherkin?(2) do
33
29
  expect(nodule.dialects).to equal(Gherkin::I18n::LANGUAGES)
34
30
  end
35
31
 
@@ -117,6 +113,31 @@ describe 'Parsing, Integration' do
117
113
 
118
114
  end
119
115
 
116
+ describe 'parsing invalid Gherkin' do
117
+
118
+ it 'correctly bubbles up parsing errors', :if => gherkin?(6, 7, 8, 9) do
119
+ expect { nodule.parse_text('bad file') }.to raise_error(/RuntimeError.*#EOF/)
120
+ end
121
+
122
+ it 'correctly bubbles up parsing errors', :if => gherkin?(4, 5) do
123
+ expect { nodule.parse_text('bad file') }.to raise_error(/Gherkin::CompositeParserException.*#EOF/m)
124
+ end
125
+
126
+ it 'correctly bubbles up parsing errors', :if => gherkin?(3) do
127
+ expect { nodule.parse_text('bad file') }.to raise_error(/Gherkin::CompositeParserException.*unexpected end of file/m)
128
+ end
129
+
130
+ it 'correctly bubbles up parsing errors', :if => gherkin?(2) do
131
+ # A different error is thrown on JRuby
132
+ if RUBY_PLATFORM == "java"
133
+ expect { nodule.parse_text('bad file') }.to raise_error(/Java::GherkinLexer.*_FEATURE_END_/m)
134
+ else
135
+ expect { nodule.parse_text('bad file') }.to raise_error(/Gherkin::Lexer::LexingError.*error on line 1/)
136
+ end
137
+ end
138
+
139
+ end
140
+
120
141
  end
121
142
 
122
143
  end
@@ -25,6 +25,7 @@ require "#{this_dir}/unit/shared/keyworded_models_unit_specs"
25
25
 
26
26
  require "#{this_dir}/../../dialect_helper"
27
27
  require "#{this_dir}/../../file_helper"
28
+ require "#{this_dir}/../../helper_methods"
28
29
 
29
30
  require 'rubygems/mock_gem_ui'
30
31
 
@@ -33,21 +34,48 @@ require 'rubygems/mock_gem_ui'
33
34
  # implementation and making the test dialect the default dialect so that language headers
34
35
  # aren't needed for all of the test code. Only possible with some versions of Gherkin.
35
36
 
36
- gherkin_version = Gem.loaded_specs['gherkin'].version.version
37
-
38
- case gherkin_version
39
- when /^6\./
40
- # gherkin 6 does not preload the dialect module
41
- require 'gherkin/dialect' if Gem.loaded_specs['gherkin'].version.version[/^6\./]
37
+ gherkin_major_version = Gem.loaded_specs['gherkin'].version.version.match(/^(\d+)\./)[1].to_i
42
38
 
39
+ case gherkin_major_version
40
+ when 8, 9
43
41
  # TODO: choose randomly from Gherkin::DIALECTS once I figure out how to handle encodings...
44
42
  test_dialect = ['en', 'en-lol', 'en-pirate', 'en-Scouse'].sample
45
43
  puts "Testing with dialect '#{test_dialect}'..."
46
44
 
45
+ CukeModeler::DialectHelper.set_dialect(Gherkin::DIALECTS[test_dialect])
46
+ CukeModeler::Parsing.dialect = test_dialect
47
+
48
+ module Gherkin
49
+ class << self
50
+ alias_method :original_from_source, :from_source
51
+
52
+ def from_source(uri, data, options = {})
53
+ options[:default_dialect] ||= CukeModeler::Parsing.dialect
54
+ original_from_source(uri, data, options)
55
+ end
56
+ end
57
+ end
58
+ when 6, 7
59
+ # TODO: choose randomly from Gherkin::DIALECTS once I figure out how to handle encodings...
60
+ test_dialect = ['en', 'en-lol', 'en-pirate', 'en-Scouse'].sample
61
+ puts "Testing with dialect '#{test_dialect}'..."
47
62
 
48
63
  CukeModeler::DialectHelper.set_dialect(Gherkin::DIALECTS[test_dialect])
49
64
  CukeModeler::Parsing.dialect = test_dialect
50
- when /^[543]\./
65
+
66
+ module Gherkin
67
+ class Gherkin
68
+ class << self
69
+ alias_method :original_from_source, :from_source
70
+
71
+ def from_source(uri, data, options = {})
72
+ options[:default_dialect] ||= CukeModeler::Parsing.dialect
73
+ original_from_source(uri, data, options)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ when 3, 4, 5
51
79
  # TODO: stop using test dialect and just randomize for all version of `gherkin`
52
80
  dialect_file_path = "#{this_dir}/../../test_languages.json"
53
81
  test_dialects = JSON.parse File.open(dialect_file_path, 'r:UTF-8').read
@@ -69,41 +97,17 @@ case gherkin_version
69
97
 
70
98
  CukeModeler::DialectHelper.set_dialect(test_dialects['cm-test'])
71
99
  CukeModeler::Parsing.dialect = 'cm-test'
72
- when /^2\./
100
+ when 2
73
101
  CukeModeler::DialectHelper.set_dialect(Gherkin::I18n::LANGUAGES['en'])
74
102
  CukeModeler::Parsing.dialect = 'en'
75
103
  else
76
- raise("Unknown Gherkin version: '#{gherkin_version}'")
104
+ raise("Unknown Gherkin major version: '#{gherkin_major_version}'")
77
105
  end
78
106
 
79
107
 
80
108
  RSpec.configure do |config|
81
- gherkin_version = Gem.loaded_specs['gherkin'].version.version
82
-
83
- case gherkin_version
84
- when /^6\./
85
- config.filter_run_excluding :gherkin2 => true,
86
- :gherkin3 => true,
87
- :gherkin4_5 => true,
88
- :gherkin6 => false
89
- when /^[54]\./
90
- config.filter_run_excluding :gherkin2 => true,
91
- :gherkin3 => true,
92
- :gherkin4_5 => false,
93
- :gherkin6 => true
94
- when /^3\./
95
- config.filter_run_excluding :gherkin2 => true,
96
- :gherkin3 => false,
97
- :gherkin4_5 => true,
98
- :gherkin6 => true
99
- when /^2\./
100
- config.filter_run_excluding :gherkin2 => false,
101
- :gherkin3 => true,
102
- :gherkin4_5 => true,
103
- :gherkin6 => true
104
- else
105
- raise("Unknown Gherkin version: '#{gherkin_version}'")
106
- end
109
+
110
+ include CukeModeler::HelperMethods
107
111
 
108
112
  config.before(:suite) do
109
113
  FEATURE_KEYWORD = CukeModeler::DialectHelper.feature_keyword
@@ -122,15 +126,4 @@ RSpec.configure do |config|
122
126
  end
123
127
  end
124
128
 
125
-
126
- def assert_bidirectional_equality(base_thing, compared_thing)
127
- expect(base_thing).to eq(compared_thing)
128
- expect(compared_thing).to eq(base_thing)
129
- end
130
-
131
- def assert_bidirectional_inequality(base_thing, compared_thing)
132
- expect(base_thing).to_not eq(compared_thing)
133
- expect(compared_thing).to_not eq(base_thing)
134
- end
135
-
136
129
  end
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '10.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '7.0'
26
+ version: '10.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,11 @@ files:
196
196
  - lib/cuke_modeler/adapters/gherkin_2_adapter.rb
197
197
  - lib/cuke_modeler/adapters/gherkin_3_adapter.rb
198
198
  - lib/cuke_modeler/adapters/gherkin_4_adapter.rb
199
+ - lib/cuke_modeler/adapters/gherkin_5_adapter.rb
199
200
  - lib/cuke_modeler/adapters/gherkin_6_adapter.rb
201
+ - lib/cuke_modeler/adapters/gherkin_7_adapter.rb
202
+ - lib/cuke_modeler/adapters/gherkin_8_adapter.rb
203
+ - lib/cuke_modeler/adapters/gherkin_9_adapter.rb
200
204
  - lib/cuke_modeler/containing.rb
201
205
  - lib/cuke_modeler/described.rb
202
206
  - lib/cuke_modeler/models/background.rb
@@ -274,10 +278,18 @@ files:
274
278
  - testing/gemfiles/gherkin4.gemfile
275
279
  - testing/gemfiles/gherkin5.gemfile
276
280
  - testing/gemfiles/gherkin6.gemfile
281
+ - testing/gemfiles/gherkin7.gemfile
282
+ - testing/gemfiles/gherkin8.gemfile
283
+ - testing/gemfiles/gherkin9.gemfile
284
+ - testing/helper_methods.rb
277
285
  - testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb
278
286
  - testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb
279
287
  - testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb
288
+ - testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb
280
289
  - testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb
290
+ - testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb
291
+ - testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb
292
+ - testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb
281
293
  - testing/rspec/spec/integration/models/background_integration_spec.rb
282
294
  - testing/rspec/spec/integration/models/cell_integration_spec.rb
283
295
  - testing/rspec/spec/integration/models/comment_integration_spec.rb