cuke_modeler 3.18.0 → 3.20.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -1
  3. data/LICENSE.txt +1 -1
  4. data/cuke_modeler.gemspec +12 -10
  5. data/lib/cuke_modeler/adapters/gherkin_20_adapter.rb +15 -6
  6. data/lib/cuke_modeler/adapters/gherkin_26_adapter.rb +13 -0
  7. data/lib/cuke_modeler/adapters/gherkin_27_adapter.rb +13 -0
  8. data/lib/cuke_modeler/described.rb +1 -1
  9. data/lib/cuke_modeler/models/background.rb +10 -0
  10. data/lib/cuke_modeler/models/cell.rb +9 -3
  11. data/lib/cuke_modeler/models/comment.rb +9 -0
  12. data/lib/cuke_modeler/models/directory.rb +12 -4
  13. data/lib/cuke_modeler/models/doc_string.rb +11 -1
  14. data/lib/cuke_modeler/models/example.rb +11 -2
  15. data/lib/cuke_modeler/models/feature.rb +9 -0
  16. data/lib/cuke_modeler/models/feature_file.rb +12 -4
  17. data/lib/cuke_modeler/models/model.rb +13 -0
  18. data/lib/cuke_modeler/models/outline.rb +11 -2
  19. data/lib/cuke_modeler/models/row.rb +11 -0
  20. data/lib/cuke_modeler/models/rule.rb +9 -4
  21. data/lib/cuke_modeler/models/scenario.rb +9 -0
  22. data/lib/cuke_modeler/models/step.rb +9 -0
  23. data/lib/cuke_modeler/models/table.rb +11 -0
  24. data/lib/cuke_modeler/models/tag.rb +9 -0
  25. data/lib/cuke_modeler/parsing.rb +3 -3
  26. data/lib/cuke_modeler/version.rb +1 -1
  27. data/testing/cucumber/features/modeling/background_output.feature +19 -5
  28. data/testing/cucumber/features/modeling/cell_output.feature +18 -4
  29. data/testing/cucumber/features/modeling/comment_output.feature +19 -5
  30. data/testing/cucumber/features/modeling/directory_output.feature +21 -4
  31. data/testing/cucumber/features/modeling/doc_string_output.feature +19 -5
  32. data/testing/cucumber/features/modeling/example_output.feature +21 -7
  33. data/testing/cucumber/features/modeling/feature_file_output.feature +21 -4
  34. data/testing/cucumber/features/modeling/feature_output.feature +20 -6
  35. data/testing/cucumber/features/modeling/model_output.feature +53 -5
  36. data/testing/cucumber/features/modeling/outline_output.feature +19 -5
  37. data/testing/cucumber/features/modeling/row_output.feature +19 -5
  38. data/testing/cucumber/features/modeling/rule_output.feature +27 -6
  39. data/testing/cucumber/features/modeling/scenario_output.feature +19 -5
  40. data/testing/cucumber/features/modeling/step_output.feature +19 -5
  41. data/testing/cucumber/features/modeling/table_output.feature +18 -4
  42. data/testing/cucumber/features/modeling/tag_output.feature +19 -5
  43. metadata +12 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ce5182bc247dd91ecfc20e43a317871507326558424d0637ab1035b9b7661fe
4
- data.tar.gz: 04b7b4ca30fdfc6fa76e2251179d0b10eb6a7032ba6420e88c345491367f6590
3
+ metadata.gz: db68bd0813ac0151f45f174d89c95c5accb2c11a77df2321f859d18f62ecf06f
4
+ data.tar.gz: 5d9b7ee4ea5c98a8e90d4d8d6d657223150064be4e867a8ef444eb93b357a195
5
5
  SHA512:
6
- metadata.gz: f7c314712bb69bd700686c04c92a58abcf7cc1f6bd1bc609caeb0bd51e6444c9932eef6e9f88ee0d827359cdc2c0d2b867182d609cf5c8eb9727436cebbe50f6
7
- data.tar.gz: 3615b14eabb2e9117a37c805957425d7814a69cc1e0e72398608e2a5bd1c101f55f4bbf75cfc3432c9f4687511f36d42096b76bfd020dfd9b461d00768a21b63
6
+ metadata.gz: a166c272417d15db4e3a04dcfb2057c0536a8412e7bce5810b9885998823d354667b42dbf9a49796d73498f469c1978779ea8a518ccd1ed92d2c9f6985c69f5e
7
+ data.tar.gz: c24f43b46820b37f16a0bf476e48d86c2a159ebc6b6a2b87da3194d7c6e0496b0ed25c7698a83c8a5f4bb1bc5fd77503c188492a19c3b8403298e994b03a5dab
data/CHANGELOG.md CHANGED
@@ -8,6 +8,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  Nothing yet...
10
10
 
11
+
12
+ ## [3.20.0] - 2023-9-21
13
+
14
+ ### Added
15
+ - Support added for more versions of the `cucumber-gherkin` gem
16
+ - 27.x
17
+
18
+ ### Changed
19
+ - `#inspect` for models now returns a reasonably small set of details for the model instead of the potentially
20
+ huge screen dump of information. Not considered a breaking change because the API never specified the behavior
21
+ of `#inspect` (it was just using the default Ruby implementation). Default Ruby inspection can still be triggered,
22
+ if desired (see documentation).
23
+
24
+ ## [3.19.0] - 2023-1-22
25
+
26
+ ### Added
27
+ - Support added for more versions of the `cucumber-gherkin` gem
28
+ - 26.x
29
+
11
30
  ## [3.18.0] - 2022-11-16
12
31
 
13
32
  ### Added
@@ -436,7 +455,9 @@ Nothing yet...
436
455
  - Initial release
437
456
 
438
457
 
439
- [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.18.0...HEAD
458
+ [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.20.0...HEAD
459
+ [3.20.0]: https://github.com/enkessler/cuke_modeler/compare/v3.19.0...v3.20.0
460
+ [3.19.0]: https://github.com/enkessler/cuke_modeler/compare/v3.18.0...v3.19.0
440
461
  [3.18.0]: https://github.com/enkessler/cuke_modeler/compare/v3.17.0...v3.18.0
441
462
  [3.17.0]: https://github.com/enkessler/cuke_modeler/compare/v3.16.0...v3.17.0
442
463
  [3.16.0]: https://github.com/enkessler/cuke_modeler/compare/v3.15.0...v3.16.0
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2022 Eric Kessler, et al
1
+ Copyright (c) 2014-2023 Eric Kessler, et al
2
2
 
3
3
  MIT License
4
4
 
data/cuke_modeler.gemspec CHANGED
@@ -18,11 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.license = 'MIT'
19
19
 
20
20
  spec.metadata = {
21
- 'bug_tracker_uri' => 'https://github.com/enkessler/cuke_modeler/issues',
22
- 'changelog_uri' => 'https://github.com/enkessler/cuke_modeler/blob/master/CHANGELOG.md',
23
- 'documentation_uri' => 'https://www.rubydoc.info/gems/cuke_modeler',
24
- 'homepage_uri' => 'https://github.com/enkessler/cuke_modeler',
25
- 'source_code_uri' => 'https://github.com/enkessler/cuke_modeler'
21
+ 'bug_tracker_uri' => 'https://github.com/enkessler/cuke_modeler/issues',
22
+ 'changelog_uri' => 'https://github.com/enkessler/cuke_modeler/blob/master/CHANGELOG.md',
23
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/cuke_modeler',
24
+ 'homepage_uri' => 'https://github.com/enkessler/cuke_modeler',
25
+ 'source_code_uri' => 'https://github.com/enkessler/cuke_modeler',
26
+ 'rubygems_mfa_required' => 'true'
26
27
  }
27
28
 
28
29
  # Specify which files should be added to the gem when it is released.
@@ -36,19 +37,20 @@ Gem::Specification.new do |spec|
36
37
 
37
38
  spec.required_ruby_version = '>= 2.3', '< 4.0'
38
39
 
39
- spec.add_runtime_dependency 'cucumber-gherkin', '< 26.0'
40
+ spec.add_runtime_dependency 'cucumber-gherkin', '< 28.0'
40
41
 
41
42
  spec.add_development_dependency 'bundler', '< 3.0'
42
43
  spec.add_development_dependency 'childprocess', '< 5.0'
43
44
  spec.add_development_dependency 'ffi', '< 2.0' # This is an invisible dependency for the `childprocess` gem on Windows
44
45
  # Cucumber 4.x is the earliest version to use cucumber-gherkin
45
- spec.add_development_dependency 'cucumber', '>= 4.0.0', '< 8.0.0'
46
+ spec.add_development_dependency 'cucumber', '>= 4.0.0', '< 10.0.0'
46
47
  spec.add_development_dependency 'rainbow', '< 4.0.0'
47
48
  spec.add_development_dependency 'rake', '< 14.0.0'
48
49
  spec.add_development_dependency 'rspec', '~> 3.0'
49
- # RuboCop drops Ruby 2.3 support after this version and we need to maintain Ruby 2.3 compatibility when writing code
50
- # for this gem
51
- spec.add_development_dependency 'rubocop', '< 0.82.0'
50
+ # Running recent RuboCop versions requires a recent version of Ruby but it can still lint against Ruby 2.3 styles.
51
+ # Can't set a lower bound because RuboCop will still get installed in the testing environments for earlier Rubies,
52
+ # even if it never actually gets run. Current "minimum" version is 1.44.0.
53
+ spec.add_development_dependency 'rubocop', '< 2.0'
52
54
  spec.add_development_dependency 'simplecov', '< 1.0'
53
55
  spec.add_development_dependency 'simplecov-lcov', '< 1.0'
54
56
  spec.add_development_dependency 'test-unit', '< 4.0.0'
@@ -327,14 +327,23 @@ module CukeModeler
327
327
 
328
328
  def clear_child_elements(ast, child_paths)
329
329
  # rubocop:disable Security/Eval - This is not blind data
330
+ # rubocop:disable Style/DocumentDynamicEvalDefinition - Nice idea but bad detection ability
330
331
  child_paths.each do |traversal_path|
331
- # Wipe the value if it's there but don't add any attributes to the object if it didn't already have them
332
- if eval("ast['cuke_modeler_parsing_data'].#{traversal_path.join('.')}", binding, __FILE__, __LINE__)
333
- property_path = traversal_path[0..-2].join('.')
334
- eval("ast['cuke_modeler_parsing_data']#{property_path.empty? ? '' : '.' + property_path}.instance_variable_set(\"@#{traversal_path.last}\", nil)", binding, __FILE__, __LINE__) # rubocop:disable Layout/LineLength
335
- end
332
+ # Don't add any properties to the object if it didn't already have them
333
+ # e.g. ast['cuke_modeler_parsing_data'].background.steps
334
+ # e.g. ast['cuke_modeler_parsing_data'].data_table
335
+ next unless eval("ast['cuke_modeler_parsing_data'].#{traversal_path.join('.')}", binding, __FILE__, __LINE__)
336
+
337
+
338
+ # Determine the path to the property and wipe it
339
+ property_path = traversal_path[0..-2].join('.')
340
+ property_path = property_path.empty? ? '' : ".#{property_path}"
341
+
342
+ # e.g. ast['cuke_modeler_parsing_data'].scenario.instance_variable_set("@steps", nil)
343
+ # e.g. ast['cuke_modeler_parsing_data'].instance_variable_set("@tags", nil)
344
+ eval("ast['cuke_modeler_parsing_data']#{property_path}.instance_variable_set(\"@#{traversal_path.last}\", nil)", binding, __FILE__, __LINE__) # rubocop:disable Layout/LineLength
336
345
  end
337
- # rubocop:enable Security/Eval
346
+ # rubocop:enable Security/Eval, Style/DocumentDynamicEvalDefinition
338
347
  end
339
348
 
340
349
  def test_has_examples?(ast_node)
@@ -0,0 +1,13 @@
1
+ require_relative 'gherkin_20_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 26.x of the *cucumber-gherkin* gem into input that is consumable
8
+ # by this gem.
9
+
10
+ class Gherkin26Adapter < Gherkin20Adapter
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'gherkin_20_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 27.x of the *cucumber-gherkin* gem into input that is consumable
8
+ # by this gem.
9
+
10
+ class Gherkin27Adapter < Gherkin20Adapter
11
+
12
+ end
13
+ end
@@ -52,7 +52,7 @@ module CukeModeler
52
52
  end
53
53
 
54
54
  def trim_leading_spaces(description)
55
- non_blank_lines = description.select { |line| line =~ /\S/ }
55
+ non_blank_lines = description.grep(/\S/)
56
56
 
57
57
  fewest_spaces = non_blank_lines.collect { |line| line[/^\s*/].length }.min || 0
58
58
 
@@ -53,6 +53,16 @@ module CukeModeler
53
53
  text
54
54
  end
55
55
 
56
+ # See `Object#inspect`. Returns some basic information about the
57
+ # object, including its class, object ID, and its most meaningful
58
+ # attribute. For a background model, this will be the name of the
59
+ # background.
60
+ def inspect(verbose: false)
61
+ return super(verbose: verbose) if verbose
62
+
63
+ "#{super.chop} @name: #{name.inspect}>"
64
+ end
65
+
56
66
 
57
67
  private
58
68
 
@@ -30,12 +30,19 @@ module CukeModeler
30
30
  @value ? @value.gsub('\\', '\\\\\\').gsub('|', '\|') : ''
31
31
  end
32
32
 
33
+ # See `Object#inspect`. Returns some basic information about the
34
+ # object, including its class, object ID, and its most meaningful
35
+ # attribute. For a cell model, this will be the value of the cell.
36
+ def inspect(verbose: false)
37
+ return super(verbose: verbose) if verbose
38
+
39
+ "#{super.chop} @value: #{value.inspect}>"
40
+ end
41
+
33
42
 
34
43
  private
35
44
 
36
45
 
37
- # It's only considered complex because of how deeply nested cells are in the tree. It's not REALLY complex.
38
- # rubocop:disable Metrics/AbcSize
39
46
  def parse_source(source_text)
40
47
  base_file_string = "# language: #{Parsing.dialect}
41
48
  #{dialect_feature_keyword}: Fake feature to parse
@@ -47,7 +54,6 @@ module CukeModeler
47
54
 
48
55
  parsed_file['feature']['elements'].first['steps'].first['table']['rows'].first['cells'].first
49
56
  end
50
- # rubocop:enable Metrics/AbcSize
51
57
 
52
58
  end
53
59
 
@@ -29,6 +29,15 @@ module CukeModeler
29
29
  text || ''
30
30
  end
31
31
 
32
+ # See `Object#inspect`. Returns some basic information about the
33
+ # object, including its class, object ID, and its most meaningful
34
+ # attribute. For a comment model, this will be the text of the comment.
35
+ def inspect(verbose: false)
36
+ return super(verbose: verbose) if verbose
37
+
38
+ "#{super.chop} @text: #{text.inspect}>"
39
+ end
40
+
32
41
 
33
42
  private
34
43
 
@@ -46,6 +46,16 @@ module CukeModeler
46
46
  path.to_s
47
47
  end
48
48
 
49
+ # See `Object#inspect`. Returns some basic information about the
50
+ # object, including its class, object ID, and its most meaningful
51
+ # attribute. For a directory model, this will be the path of the
52
+ # directory.
53
+ def inspect(verbose: false)
54
+ return super(verbose: verbose) if verbose
55
+
56
+ "#{super.chop} @path: #{@path.inspect}>"
57
+ end
58
+
49
59
 
50
60
  private
51
61
 
@@ -75,12 +85,10 @@ module CukeModeler
75
85
  end
76
86
 
77
87
  def process_feature_file(file_path)
78
- source_text = IO.read(file_path)
79
-
88
+ source_text = File.read(file_path)
80
89
  feature_file_data = Parsing.parse_text(source_text, file_path)
81
- feature_file_data = feature_file_data.merge({ 'path' => file_path })
82
90
 
83
- feature_file_data
91
+ feature_file_data.merge({ 'path' => file_path })
84
92
  end
85
93
 
86
94
  end
@@ -34,6 +34,16 @@ module CukeModeler
34
34
  text << '"""'
35
35
  end
36
36
 
37
+ # See `Object#inspect`. Returns some basic information about the
38
+ # object, including its class, object ID, and its most meaningful
39
+ # attribute. For a doc string model, this will be the content of
40
+ # the doc string.
41
+ def inspect(verbose: false)
42
+ return super(verbose: verbose) if verbose
43
+
44
+ "#{super.chop} @content: #{content.inspect}>"
45
+ end
46
+
37
47
 
38
48
  private
39
49
 
@@ -55,7 +65,7 @@ module CukeModeler
55
65
  end
56
66
 
57
67
  def content_output_string
58
- content.nil? || content.empty? ? '' : content.gsub('"""', '\"\"\"') + "\n"
68
+ content.nil? || content.empty? ? '' : "#{content.gsub('"""', '\"\"\"')}\n"
59
69
  end
60
70
 
61
71
  end
@@ -99,7 +99,7 @@ module CukeModeler
99
99
  end
100
100
 
101
101
  # Building strings just isn't pretty
102
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
102
+ # rubocop:disable Metrics/AbcSize
103
103
 
104
104
  # Returns a string representation of this model. For an example model,
105
105
  # this will be Gherkin text that is equivalent to the example being modeled.
@@ -116,7 +116,16 @@ module CukeModeler
116
116
  text
117
117
  end
118
118
 
119
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
119
+ # rubocop:enable Metrics/AbcSize
120
+
121
+ # See `Object#inspect`. Returns some basic information about the
122
+ # object, including its class, object ID, and its most meaningful
123
+ # attribute. For an example model, this will be the name of the example.
124
+ def inspect(verbose: false)
125
+ return super(verbose: verbose) if verbose
126
+
127
+ "#{super.chop} @name: #{name.inspect}>"
128
+ end
120
129
 
121
130
 
122
131
  private
@@ -99,6 +99,15 @@ module CukeModeler
99
99
 
100
100
  # rubocop:enable Metrics/AbcSize
101
101
 
102
+ # See `Object#inspect`. Returns some basic information about the
103
+ # object, including its class, object ID, and its most meaningful
104
+ # attribute. For a feature model, this will be the name of the feature.
105
+ def inspect(verbose: false)
106
+ return super(verbose: verbose) if verbose
107
+
108
+ "#{super.chop} @name: #{name.inspect}>"
109
+ end
110
+
102
111
 
103
112
  private
104
113
 
@@ -47,17 +47,25 @@ module CukeModeler
47
47
  path.to_s
48
48
  end
49
49
 
50
+ # See `Object#inspect`. Returns some basic information about the
51
+ # object, including its class, object ID, and its most meaningful
52
+ # attribute. For a feature file model, this will be the path of
53
+ # the feature file.
54
+ def inspect(verbose: false)
55
+ return super(verbose: verbose) if verbose
56
+
57
+ "#{super.chop} @path: #{@path.inspect}>"
58
+ end
59
+
50
60
 
51
61
  private
52
62
 
53
63
 
54
64
  def process_feature_file(file_path)
55
- source_text = IO.read(file_path)
56
-
65
+ source_text = File.read(file_path)
57
66
  feature_file_data = Parsing.parse_text(source_text, file_path)
58
- feature_file_data = feature_file_data.merge({ 'path' => file_path })
59
67
 
60
- feature_file_data
68
+ feature_file_data.merge({ 'path' => file_path })
61
69
  end
62
70
 
63
71
  end
@@ -16,16 +16,29 @@ module CukeModeler
16
16
  # This should be overridden by a child class
17
17
  end
18
18
 
19
+ # It's a lazy implementation but it's mandatory for the class to define this method
20
+ # rubocop:disable Lint/UselessMethodDefinition
21
+
19
22
  # Returns a string representation of this model.
20
23
  def to_s
21
24
  # This should be overridden by a child class
22
25
  super
23
26
  end
24
27
 
28
+ # rubocop:enable Lint/UselessMethodDefinition
29
+
25
30
  # Returns the model objects that belong to this model.
26
31
  def children
27
32
  []
28
33
  end
29
34
 
35
+ # See `Object#inspect`. Returns some basic information about the
36
+ # object, including its class and object ID.
37
+ def inspect(verbose: false)
38
+ return super() if verbose
39
+
40
+ "#<#{self.class.name}:#{object_id}>"
41
+ end
42
+
30
43
  end
31
44
  end
@@ -47,7 +47,7 @@ module CukeModeler
47
47
  end
48
48
 
49
49
  # Building strings just isn't pretty
50
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
50
+ # rubocop:disable Metrics/AbcSize
51
51
 
52
52
  # Returns a string representation of this model. For an outline model,
53
53
  # this will be Gherkin text that is equivalent to the outline being modeled.
@@ -64,7 +64,16 @@ module CukeModeler
64
64
  text
65
65
  end
66
66
 
67
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
67
+ # rubocop:enable Metrics/AbcSize
68
+
69
+ # See `Object#inspect`. Returns some basic information about the
70
+ # object, including its class, object ID, and its most meaningful
71
+ # attribute. For an outline model, this will be the name of the outline.
72
+ def inspect(verbose: false)
73
+ return super(verbose: verbose) if verbose
74
+
75
+ "#{super.chop} @name: #{name.inspect}>"
76
+ end
68
77
 
69
78
 
70
79
  private
@@ -37,6 +37,17 @@ module CukeModeler
37
37
  "| #{text_cells.join(' | ')} |"
38
38
  end
39
39
 
40
+ # See `Object#inspect`. Returns some basic information about the
41
+ # object, including its class, object ID, and its most meaningful
42
+ # attribute. For a row model, this will be the cells of the row.
43
+ def inspect(verbose: false)
44
+ return super(verbose: verbose) if verbose
45
+
46
+ cell_output = @cells&.collect(&:value)
47
+
48
+ "#{super.chop} @cells: #{cell_output.inspect}>"
49
+ end
50
+
40
51
 
41
52
  private
42
53
 
@@ -60,9 +60,6 @@ module CukeModeler
60
60
  models
61
61
  end
62
62
 
63
- # Building strings just isn't pretty
64
- # rubocop:disable Metrics/AbcSize
65
-
66
63
  # Returns a string representation of this model. For a rule model,
67
64
  # this will be Gherkin text that is equivalent to the rule being modeled.
68
65
  def to_s
@@ -76,7 +73,15 @@ module CukeModeler
76
73
 
77
74
  text
78
75
  end
79
- # rubocop:enable Metrics/AbcSize
76
+
77
+ # See `Object#inspect`. Returns some basic information about the
78
+ # object, including its class, object ID, and its most meaningful
79
+ # attribute. For a rule model, this will be the name of the rule.
80
+ def inspect(verbose: false)
81
+ return super(verbose: verbose) if verbose
82
+
83
+ "#{super.chop} @name: #{@name.inspect}>"
84
+ end
80
85
 
81
86
 
82
87
  private
@@ -61,6 +61,15 @@ module CukeModeler
61
61
 
62
62
  # rubocop:enable Metrics/AbcSize
63
63
 
64
+ # See `Object#inspect`. Returns some basic information about the
65
+ # object, including its class, object ID, and its most meaningful
66
+ # attribute. For a scenario model, this will be the name of the scenario.
67
+ def inspect(verbose: false)
68
+ return super(verbose: verbose) if verbose
69
+
70
+ "#{super.chop} @name: #{name.inspect}>"
71
+ end
72
+
64
73
 
65
74
  private
66
75
 
@@ -53,6 +53,15 @@ module CukeModeler
53
53
  text
54
54
  end
55
55
 
56
+ # See `Object#inspect`. Returns some basic information about the
57
+ # object, including its class, object ID, and its most meaningful
58
+ # attribute. For a step model, this will be the text of the step.
59
+ def inspect(verbose: false)
60
+ return super(verbose: verbose) if verbose
61
+
62
+ "#{super.chop} @text: #{@text.inspect}>"
63
+ end
64
+
56
65
 
57
66
  private
58
67
 
@@ -36,6 +36,17 @@ module CukeModeler
36
36
  rows.empty? ? '' : rows.collect { |row| row_output_string(row) }.join("\n")
37
37
  end
38
38
 
39
+ # See `Object#inspect`. Returns some basic information about the
40
+ # object, including its class, object ID, and its most meaningful
41
+ # attribute. For a table model, this will be the rows of the table.
42
+ def inspect(verbose: false)
43
+ return super(verbose: verbose) if verbose
44
+
45
+ row_output = @rows&.collect { |row| row.cells.collect(&:value) }
46
+
47
+ "#{super.chop} @rows: #{row_output.inspect}>"
48
+ end
49
+
39
50
 
40
51
  private
41
52
 
@@ -29,6 +29,15 @@ module CukeModeler
29
29
  name || ''
30
30
  end
31
31
 
32
+ # See `Object#inspect`. Returns some basic information about the
33
+ # object, including its class, object ID, and its most meaningful
34
+ # attribute. For a tag model, this will be the name of the tag.
35
+ def inspect(verbose: false)
36
+ return super(verbose: verbose) if verbose
37
+
38
+ "#{super.chop} @name: #{@name.inspect}>"
39
+ end
40
+
32
41
 
33
42
  private
34
43
 
@@ -9,7 +9,7 @@ require 'gherkin'
9
9
  # an 'adapter' appropriate to the version of the *cucumber-gherkin* gem that has been activated.
10
10
  gherkin_version = Gem.loaded_specs['cucumber-gherkin'].version.version
11
11
  gherkin_major_version = gherkin_version.match(/^(\d+)\./)[1].to_i
12
- supported_gherkin_versions = (9..25)
12
+ supported_gherkin_versions = (9..27)
13
13
 
14
14
  raise("Unknown Gherkin version: '#{gherkin_version}'") unless supported_gherkin_versions.include?(gherkin_major_version)
15
15
 
@@ -63,7 +63,7 @@ module CukeModeler
63
63
  # inside of it, so I'm leaving this here in case it changes again
64
64
  # rubocop:disable Lint/DuplicateMethods
65
65
  case gherkin_major_version
66
- when 20, 21, 22, 23, 24, 25
66
+ when 20, 21, 22, 23, 24, 25, 26, 27
67
67
  # TODO: make these methods private?
68
68
  # NOT A PART OF THE PUBLIC API
69
69
  # The method to use for parsing Gherkin text
@@ -185,7 +185,7 @@ module CukeModeler
185
185
  end
186
186
 
187
187
  def get_word(word_set)
188
- word_set = word_set.is_a?(Array) ? word_set : word_set.split('|')
188
+ word_set = word_set.split('|') unless word_set.is_a?(Array)
189
189
 
190
190
  word_set.first
191
191
  end
@@ -1,4 +1,4 @@
1
1
  module CukeModeler
2
2
  # The gem version
3
- VERSION = '3.18.0'.freeze
3
+ VERSION = '3.20.0'.freeze
4
4
  end
@@ -1,9 +1,10 @@
1
1
  Feature: Background output
2
2
 
3
- A background model's string output is a Gherkin representation of itself. As such, output from a background model can be used as input for the same kind of model.
3
+ A background model's string output is a Gherkin representation of itself and its most relevant attribute for
4
+ inspection is the name of the background that it models.
4
5
 
5
6
 
6
- Scenario: Outputting a background model
7
+ Background:
7
8
  Given the following gherkin:
8
9
  """
9
10
  Background: A background with everything that it could have
@@ -20,11 +21,14 @@ Feature: Background output
20
21
  """
21
22
  And a background model based on that gherkin
22
23
  """
23
- @model = CukeModeler::Background.new(<source_text>)
24
+ @model = CukeModeler::Background.new(<source_text>)
24
25
  """
26
+
27
+
28
+ Scenario: Stringify a background model
25
29
  When the model is output as a string
26
30
  """
27
- @model.to_s
31
+ @model.to_s
28
32
  """
29
33
  Then the following text is provided:
30
34
  """
@@ -42,5 +46,15 @@ Feature: Background output
42
46
  """
43
47
  And the output can be used to make an equivalent model
44
48
  """
45
- CukeModeler::Background.new(@model.to_s)
49
+ CukeModeler::Background.new(@model.to_s)
50
+ """
51
+
52
+ Scenario: Inspect a background model
53
+ When the model is inspected
54
+ """
55
+ @model.inspect
56
+ """
57
+ Then the following text is provided:
58
+ """
59
+ #<CukeModeler::Background:<object_id> @name: "A background with everything that it could have">
46
60
  """