turnip 4.2.0 → 4.4.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: c86f0ce3b7829fd47b7383b07a322c1726f84c91b5da26882e7595ff9113c6d2
4
- data.tar.gz: 35fd833aac33e1eab40239bdfac960f63c762ac6c5fcdc990cfc8a4669f927cc
3
+ metadata.gz: 32d3aecd977c3e3d73df64781c8c929c6375ca79e86e94ba3339f18541db5450
4
+ data.tar.gz: 89d504ed60b272b9d31f90756c6f4f0e7fd28a136ab7444a7b11fbc88298d452
5
5
  SHA512:
6
- metadata.gz: 7dff32468733fbdc9998ece81cea23877098f51e24f2a06d32da65ac3fb7afe4beb22f2f45bce45ee3e1e5961193b3bb859cccee8fb72266de83dfddfe187441
7
- data.tar.gz: 7a3123de579bf41c9a8aeee4ef04cb9f25814c90e051b77a15319cff29f935634256f4d845668ac8ea83b6782ed0251d2354563023c9a58035a1f6a5730610b6
6
+ metadata.gz: c7473753934fb4d5deaa5b3c3856be1206aceea11bbdd8c1692e11cef24f340d96c95c78065b887772402fbe724c75581ee9788717193fa577e1c9044530b86e
7
+ data.tar.gz: ad6e2fc48ab21319383eaa81fb51fdb943bd716f4350912c3336b8a574d386d75f27f684ad96005d114623f69aefd5cfc902630973fe1f8d1f377aed44476774
@@ -6,14 +6,13 @@ jobs:
6
6
  fail-fast: false
7
7
  matrix:
8
8
  ruby:
9
- - '2.5'
10
- - '2.6'
11
9
  - '2.7'
10
+ - '3.0'
11
+ - '3.1'
12
12
  - jruby
13
13
  gemfiles:
14
- - gemfiles/Gemfile-rspec-3.7.x
15
- - gemfiles/Gemfile-rspec-3.8.x
16
- - gemfiles/Gemfile-rspec-3.9.x
14
+ - gemfiles/Gemfile-rspec-3.11.x
15
+ - gemfiles/Gemfile-rspec-3.12.x
17
16
  runs-on: ubuntu-latest
18
17
  steps:
19
18
  - uses: actions/checkout@v2
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,102 @@
1
+ # CHANGE LOG
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [4.4.0] - 2022-11-04
6
+
7
+ ### Added
8
+
9
+ - Add CukeModeler as Gherkin abstraction layer [[GH-244](https://github.com/jnicklas/turnip/pull/244)]
10
+ - Send step notifications and add metadata for RSpec reporter [[GH-249](https://github.com/jnicklas/turnip/pull/249)]
11
+
12
+ ### Fixed
13
+
14
+ - Add "missing step" context when raising error for unimplemented steps [[GH-240](https://github.com/jnicklas/turnip/pull/240)]
15
+ - Support rspec 3.11 and 3.12 and deprecate EOL rubies [[GH-250](https://github.com/jnicklas/turnip/pull/250)]
16
+
17
+ ## [4.3.0] - 2021-05-16
18
+
19
+ ### Added
20
+
21
+ - Support scenario name substitution [[GH-237](https://github.com/jnicklas/turnip/pull/237)]
22
+
23
+ ### Fixed
24
+
25
+ - Support RSpec 3.9 and 3.10 (drop 3.7 and 3.8) [[GH-238](https://github.com/jnicklas/turnip/pull/238)]
26
+ - Replace TravisCI with GitHub Workflows [[GH-239](https://github.com/jnicklas/turnip/pull/239)]
27
+
28
+ ## [4.2.0] - 2020-09-02
29
+
30
+ ### Changed
31
+
32
+ - Update gherkin version
33
+ - v11 [[GH-222](https://github.com/jnicklas/turnip/pull/222)]
34
+ - v12 [[GH-224](https://github.com/jnicklas/turnip/pull/224)]
35
+ - v14 [[GH-229](https://github.com/jnicklas/turnip/pull/229)]
36
+
37
+ ### Fixed
38
+
39
+ - Test against Ruby 2.7 [[GH-223](https://github.com/jnicklas/turnip/pull/223)]
40
+ - Drop support Ruby 2.3 and 2.4 [[GH-225](https://github.com/jnicklas/turnip/pull/225)]
41
+ - Update travis.yml [[GH-226](https://github.com/jnicklas/turnip/pull/226)]]
42
+ - Setup GitHub Actions [[GH-227](https://github.com/jnicklas/turnip/pull/227)]
43
+ - Suppress deprecation warning in Capybara 3.33.0 [[GH-232](https://github.com/jnicklas/turnip/pull/232)]
44
+
45
+ ## [4.1.0] - 2020-03-02
46
+
47
+ ### Added
48
+
49
+ - Warn when replacing placeholders [[GH-219](https://github.com/jnicklas/turnip/pull/219))
50
+
51
+ ### Changed
52
+
53
+ - Update gherkin version
54
+ - v8 [[GH-217](https://github.com/jnicklas/turnip/pull/217)]
55
+ - v9 [[GH-218](https://github.com/jnicklas/turnip/pull/218)]
56
+ - v10 [[GH-221](https://github.com/jnicklas/turnip/pull/221)]
57
+
58
+ ### Fixed
59
+
60
+ - Update README.md [[GH-216](https://github.com/jnicklas/turnip/pull/216)]
61
+
62
+ ## [4.0.1] - 2019-04-22
63
+
64
+ ### Changed
65
+
66
+ - Add `required_ruby_version` [[GH-212](https://github.com/jnicklas/turnip/pull/212)]
67
+ - Add support Ruby 2.6 by upgrading Gherkin version [[GH-214](https://github.com/jnicklas/turnip/pull/214)]
68
+
69
+ ### Fixed
70
+
71
+ - Update README.md [[GH-211](https://github.com/jnicklas/turnip/pull/211)]
72
+ - Add homepage url to gemspec [[GH-209](https://github.com/jnicklas/turnip/pull/209)]
73
+
74
+ ## [4.0.0] - 2019-02-28
75
+
76
+ ### Changed
77
+
78
+ - Use Gherkin 6.0 [[GH-206](https://github.com/jnicklas/turnip/pull/206)] [[GH-208](https://github.com/jnicklas/turnip/pull/208)]
79
+ - Support RSpec 3.7 and 3.8 (drop 3.6) [[GH-203](https://github.com/jnicklas/turnip/pull/203)]
80
+ - Drop support Ruby 2.2 [[GH-204](https://github.com/jnicklas/turnip/pull/204)]
81
+
82
+ ### Fixed
83
+
84
+ - Test against Ruby 2.6 (fail yet) [[GH-207](https://github.com/jnicklas/turnip/pull/207)]
85
+
86
+ ## [3.1.0] - 2018-01-30
87
+
88
+ ### Changed
89
+
90
+ - Use Gherkin 5.0 [[GH-200](https://github.com/jnicklas/turnip/pull/200)]
91
+ - Support Ruby 2.5.0 [[GH-201](https://github.com/jnicklas/turnip/pull/201)]
92
+ - Drop support Ruby 2.1 [[GH-191](https://github.com/jnicklas/turnip/pull/191)]
93
+ - Support RSpec 3.7.0 and 3.6.0 [[GH-197](https://github.com/jnicklas/turnip/pull/197)]
94
+
95
+ ## Fixed
96
+
97
+ - Add license to gemspec [[GH-193](https://github.com/jnicklas/turnip/pull/193)]
98
+ - Suppress warning [[GH-195](https://github.com/jnicklas/turnip/pull/195)]
99
+
100
+ ## [3.0.0] - 2017-04-04
101
+
102
+ TBD (You can see https://github.com/jnicklas/turnip/releases for before this bersion)
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Join the chat at https://gitter.im/jnicklas/turnip](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/turnip?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/jnicklas/turnip.png)](http://travis-ci.org/jnicklas/turnip)
6
5
  ![Test](https://github.com/jnicklas/turnip/workflows/Test/badge.svg)
7
6
  [![Code Climate](https://codeclimate.com/github/jnicklas/turnip.png)](https://codeclimate.com/github/jnicklas/turnip)
8
7
 
@@ -441,7 +440,7 @@ end
441
440
  Turnip mark a scenario as pending when steps in the scenario is not implemented.
442
441
  If you sets `raise_error_for_unimplemented_steps` as `true`, turnip will mark a scenario as fail.
443
442
 
444
- It defaults to `false`, you can change it by following configuration:
443
+ It defaults to `false`, you can change it by adding following configuration to `spec/turnip_helper.rb`:
445
444
 
446
445
  ```ruby
447
446
  RSpec.configure do |config|
@@ -477,6 +476,24 @@ tags you'd use in Cucumber to switch between drivers e.g. `@javascript` or
477
476
  metadata, so that Capybara is included and also any other extensions you might
478
477
  want to add.
479
478
 
479
+ ## RSpec custom formatters
480
+
481
+ Turnip sends notifications to the RSpec reporter about step progress. You can
482
+ listen for these by registering your formatter class with the following
483
+ notifications:
484
+
485
+ ``` ruby
486
+ class MyFormatter
487
+ RSpec::Core::Formatters.register self, :step_started, :step_passed, :step_failed, :step_pending
488
+
489
+ def step_passed(step)
490
+ puts "Starting step: #{step.text}"
491
+ end
492
+
493
+ # …
494
+ end
495
+ ```
496
+
480
497
  ## License
481
498
 
482
499
  (The MIT License)
@@ -0,0 +1,13 @@
1
+ Feature: using scenario outlines
2
+ Scenario Outline: a monster introduced himself as <name>
3
+ Given there is a monster called <name>
4
+ Then the monster introduced himself:
5
+ """
6
+ Ahhhhhhh! i'm <name>!
7
+ """
8
+
9
+ Examples:
10
+ | name |
11
+ | John |
12
+ | "John Smith" |
13
+ | "O'Flannahan" |
@@ -0,0 +1,5 @@
1
+ # language: en-au
2
+
3
+ Pretty much: A feature that specifies a language
4
+ Awww, look mate: This is a language specific feature
5
+ * a step
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in turnip.gemspec
4
4
  gemspec :path => '..'
5
5
 
6
- gem 'rspec', '~> 3.7.0'
6
+ gem 'rspec', '~> 3.11.0'
7
7
  gem 'pry-byebug', platforms: :mri
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in turnip.gemspec
4
4
  gemspec :path => '..'
5
5
 
6
- gem 'rspec', '~> 3.8.0'
6
+ gem 'rspec', '~> 3.12.0'
7
7
  gem 'pry-byebug', platforms: :mri
@@ -1,19 +1,13 @@
1
- require "gherkin"
1
+ require "cuke_modeler"
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.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
7
+ feature_file = CukeModeler::FeatureFile.new(feature_file)
14
8
 
15
- return nil if result.nil? || result[:feature].nil?
16
- Node::Feature.new(result[:feature])
9
+ return nil unless feature_file.feature
10
+ Node::Feature.new(feature_file.feature)
17
11
  end
18
12
  end
19
13
  end
@@ -20,15 +20,15 @@ module Turnip
20
20
  include HasTags
21
21
 
22
22
  def keyword
23
- @raw[:keyword]
23
+ @raw.keyword
24
24
  end
25
25
 
26
26
  def name
27
- @raw[:name]
27
+ @raw.name
28
28
  end
29
29
 
30
30
  def description
31
- @raw[:description]
31
+ @raw.description
32
32
  end
33
33
 
34
34
  #
@@ -42,7 +42,7 @@ module Turnip
42
42
  # @return [Array]
43
43
  #
44
44
  def header
45
- @header ||= @raw[:table_header][:cells].map { |c| c[:value] }
45
+ @header ||= @raw.parameter_row.cells.map { |c| c.value }
46
46
  end
47
47
 
48
48
  #
@@ -56,8 +56,8 @@ module Turnip
56
56
  # @return [Array]
57
57
  #
58
58
  def rows
59
- @rows ||= @raw[:table_body].map do |row|
60
- row[:cells].map { |c| c[:value] }
59
+ @rows ||= @raw.argument_rows.map do |row|
60
+ row.cells.map { |c| c.value }
61
61
  end
62
62
  end
63
63
  end
@@ -23,22 +23,25 @@ module Turnip
23
23
  include HasTags
24
24
 
25
25
  def language
26
- @raw[:language]
26
+ @raw.language
27
27
  end
28
28
 
29
29
  def children
30
- @children ||= @raw[:children].map do |child|
31
- unless child[:background].nil?
32
- next Background.new(child[:background])
30
+ @children ||= @raw.children.map do |child|
31
+ if child.is_a?(CukeModeler::Background)
32
+ next Background.new(child)
33
33
  end
34
34
 
35
- unless child[:scenario].nil?
36
- klass = child.dig(:scenario, :examples).nil? ? Scenario : ScenarioOutline
37
- next klass.new(child[:scenario])
35
+ if child.is_a?(CukeModeler::Scenario)
36
+ next Scenario.new(child)
38
37
  end
39
38
 
40
- unless child[:rule].nil?
41
- next Rule.new(child[:rule])
39
+ if child.is_a?(CukeModeler::Outline)
40
+ next ScenarioOutline.new(child)
41
+ end
42
+
43
+ if child.is_a?(CukeModeler::Rule)
44
+ next Rule.new(child)
42
45
  end
43
46
  end.compact
44
47
  end
@@ -23,7 +23,7 @@ module Turnip
23
23
  # @return [Location]
24
24
  #
25
25
  def location
26
- @location ||= Location.new(@raw[:location][:line], @raw[:location][:column])
26
+ @location ||= Location.new(@raw.source_line, @raw.source_column)
27
27
  end
28
28
 
29
29
  def line
@@ -16,14 +16,17 @@ module Turnip
16
16
  #
17
17
  class Rule < ScenarioGroupDefinition
18
18
  def children
19
- @children ||= @raw[:children].map do |child|
20
- unless child[:background].nil?
21
- next Background.new(child[:background])
19
+ @children ||= @raw.children.map do |child|
20
+ if child.is_a?(CukeModeler::Background)
21
+ next Background.new(child)
22
22
  end
23
23
 
24
- unless child[:scenario].nil?
25
- klass = child.dig(:scenario, :examples).nil? ? Scenario : ScenarioOutline
26
- next klass.new(child[:scenario])
24
+ if child.is_a?(CukeModeler::Scenario)
25
+ next Scenario.new(child)
26
+ end
27
+
28
+ if child.is_a?(CukeModeler::Outline)
29
+ next ScenarioOutline.new(child)
27
30
  end
28
31
  end.compact
29
32
  end
@@ -5,19 +5,19 @@ module Turnip
5
5
  module Node
6
6
  class ScenarioDefinition < Base
7
7
  def name
8
- @raw[:name]
8
+ @raw.name
9
9
  end
10
10
 
11
11
  def keyword
12
- @raw[:keyword]
12
+ @raw.keyword
13
13
  end
14
14
 
15
15
  def description
16
- @raw[:description]
16
+ @raw.description
17
17
  end
18
18
 
19
19
  def steps
20
- @steps ||= @raw[:steps].map do |step|
20
+ @steps ||= @raw.steps.map do |step|
21
21
  Step.new(step)
22
22
  end
23
23
  end
@@ -7,15 +7,15 @@ module Turnip
7
7
  module Node
8
8
  class ScenarioGroupDefinition < Base
9
9
  def name
10
- @raw[:name]
10
+ @raw.name
11
11
  end
12
12
 
13
13
  def keyword
14
- @raw[:keyword]
14
+ @raw.keyword
15
15
  end
16
16
 
17
17
  def description
18
- @raw[:description]
18
+ @raw.description
19
19
  end
20
20
 
21
21
  def backgrounds
@@ -20,7 +20,7 @@ module Turnip
20
20
  include HasTags
21
21
 
22
22
  def examples
23
- @examples ||= @raw[:examples].map do |raw|
23
+ @examples ||= @raw.examples.map do |raw|
24
24
  Example.new(raw)
25
25
  end
26
26
  end
@@ -57,27 +57,27 @@ module Turnip
57
57
  header = example.header
58
58
 
59
59
  example.rows.map do |row|
60
- metadata = convert_metadata_to_scenario
60
+ scenario = convert_metadata_to_scenario(header, row)
61
61
 
62
62
  #
63
63
  # Replace <placeholder> using Example values
64
64
  #
65
- metadata[:steps].each do |step|
66
- step[:text] = substitute(step[:text], header, row)
65
+ scenario.steps.each do |step|
66
+ step.text = substitute(step.text, header, row)
67
67
 
68
68
  case
69
- when step[:doc_string]
70
- step[:doc_string][:content] = substitute(step[:doc_string][:content], header, row)
71
- when step[:data_table]
72
- step[:data_table][:rows].map do |table_row|
73
- table_row[:cells].map do |cell|
74
- cell[:value] = substitute(cell[:value], header, row)
69
+ when step.block&.is_a?(CukeModeler::DocString)
70
+ step.block.content = substitute(step.block.content, header, row)
71
+ when step.block&.is_a?(CukeModeler::Table)
72
+ step.block.rows.map do |table_row|
73
+ table_row.cells.map do |cell|
74
+ cell.value = substitute(cell.value, header, row)
75
75
  end
76
76
  end
77
77
  end
78
78
  end
79
79
 
80
- Scenario.new(metadata)
80
+ Scenario.new(scenario)
81
81
  end
82
82
  end.flatten.compact
83
83
  end
@@ -115,12 +115,16 @@ module Turnip
115
115
  # @todo :keyword is not considered a language (en only)
116
116
  # @return [Hash]
117
117
  #
118
- def convert_metadata_to_scenario()
118
+ def convert_metadata_to_scenario(header, row)
119
119
  # deep copy
120
- Marshal.load(Marshal.dump(raw)).tap do |new_raw|
121
- new_raw.delete(:examples)
122
- new_raw[:type] = :Scenario
123
- new_raw[:keyword] = 'Scenario'
120
+ original = Marshal.load(Marshal.dump(raw))
121
+
122
+ CukeModeler::Scenario.new.tap do |scenario|
123
+ scenario.name = substitute(original.name, header, row)
124
+ scenario.keyword = 'Scenario' # TODO: Do we need to worry about dialects other than English?
125
+ scenario.steps = original.steps
126
+ scenario.source_line = original.source_line
127
+ scenario.source_column = original.source_column
124
128
  end
125
129
  end
126
130
 
@@ -16,11 +16,12 @@ module Turnip
16
16
  #
17
17
  class Step < Base
18
18
  def keyword
19
- @raw[:keyword]
19
+ # TODO: Do we want to keep the whitespace?
20
+ @raw.keyword + ' '
20
21
  end
21
22
 
22
23
  def text
23
- @raw[:text]
24
+ @raw.text
24
25
  end
25
26
 
26
27
  #
@@ -32,10 +33,10 @@ module Turnip
32
33
 
33
34
  def argument
34
35
  @argument ||= case
35
- when @raw[:doc_string]
36
- doc_string(@raw[:doc_string])
37
- when @raw[:data_table]
38
- data_table(@raw[:data_table])
36
+ when @raw.block&.is_a?(CukeModeler::DocString)
37
+ doc_string(@raw.block)
38
+ when @raw.block&.is_a?(CukeModeler::Table)
39
+ data_table(@raw.block)
39
40
  end
40
41
  end
41
42
 
@@ -46,13 +47,13 @@ module Turnip
46
47
  private
47
48
 
48
49
  def doc_string(doc)
49
- doc[:content]
50
+ doc.content
50
51
  end
51
52
 
52
53
  def data_table(table)
53
- rows = table[:rows].map do |row|
54
- row[:cells].map do |cell|
55
- cell[:value]
54
+ rows = table.rows.map do |row|
55
+ row.cells.map do |cell|
56
+ cell.value
56
57
  end
57
58
  end
58
59
  Turnip::Table.new(rows)
@@ -13,7 +13,7 @@ module Turnip
13
13
  #
14
14
  class Tag < Base
15
15
  def name
16
- @name ||= @raw[:name].gsub(/^@/, '')
16
+ @name ||= @raw.name.gsub(/^@/, '')
17
17
  end
18
18
  end
19
19
 
@@ -22,7 +22,7 @@ module Turnip
22
22
  # @return [Array] Array of Tag
23
23
  #
24
24
  def tags
25
- @tags ||= @raw.fetch(:tags, []).map do |tag|
25
+ @tags ||= @raw.tags.map do |tag|
26
26
  Tag.new(tag)
27
27
  end
28
28
  end
data/lib/turnip/rspec.rb CHANGED
@@ -40,25 +40,35 @@ module Turnip
40
40
  include Turnip::Execute
41
41
 
42
42
  def run_step(feature_file, step)
43
+ reporter = ::RSpec.current_example.reporter
44
+ reporter.publish(:step_started, { step: step })
45
+
43
46
  begin
44
47
  instance_eval <<-EOS, feature_file, step.line
45
48
  step(step)
46
49
  EOS
47
50
  rescue Turnip::Pending => e
51
+ reporter.publish(:step_pending, { step: step })
52
+
48
53
  example = ::RSpec.current_example
49
54
  example.metadata[:line_number] = step.line
50
55
  example.metadata[:location] = "#{example.metadata[:file_path]}:#{step.line}"
51
56
 
57
+ missing_step_message = "No such step: '#{e}' #{feature_file}:#{step.line}"
52
58
  if ::RSpec.configuration.raise_error_for_unimplemented_steps
53
59
  e.backtrace.push "#{feature_file}:#{step.line}:in `#{step.description}'"
54
- raise
60
+ raise e, missing_step_message
55
61
  end
56
62
 
57
- skip("No such step: '#{e}'")
63
+ skip(missing_step_message)
58
64
  rescue StandardError, ::RSpec::Expectations::ExpectationNotMetError => e
65
+ reporter.publish(:step_failed, { step: step })
66
+
59
67
  e.backtrace.push "#{feature_file}:#{step.line}:in `#{step.description}'"
60
68
  raise e
61
69
  end
70
+
71
+ reporter.publish(:step_passed, { step: step })
62
72
  end
63
73
  end
64
74
 
@@ -91,10 +101,11 @@ module Turnip
91
101
  end
92
102
 
93
103
  group.scenarios.each do |scenario|
94
- step_names = (background_steps + scenario.steps).map(&:to_s)
95
- description = step_names.join(' -> ')
104
+ all_steps = background_steps + scenario.steps
105
+ description = all_steps.map(&:to_s).join(' -> ')
106
+ metadata = scenario.metadata_hash.merge(turnip_steps: all_steps)
96
107
 
97
- context.describe scenario.name, scenario.metadata_hash do
108
+ context.describe scenario.name, metadata do
98
109
  instance_eval <<-EOS, filename, scenario.line
99
110
  it description do
100
111
  scenario.steps.each do |step|
@@ -1,3 +1,3 @@
1
1
  module Turnip
2
- VERSION = '4.2.0'
2
+ VERSION = '4.4.0'
3
3
  end
data/spec/builder_spec.rb CHANGED
@@ -75,6 +75,18 @@ describe Turnip::Builder do
75
75
  end
76
76
  end
77
77
 
78
+ context "with example scenario name in scenario outlines" do
79
+ let(:feature_file) { File.expand_path('../examples/scenario_outline_scenario_name_substitution.feature', File.dirname(__FILE__)) }
80
+
81
+ it "replaces placeholders in scenario name" do
82
+ feature.scenarios.map(&:name).should eq([
83
+ "a monster introduced himself as John",
84
+ 'a monster introduced himself as "John Smith"',
85
+ %(a monster introduced himself as "O'Flannahan")
86
+ ])
87
+ end
88
+ end
89
+
78
90
  context "with example tables in scenario outlines" do
79
91
  let(:feature_file) { File.expand_path('../examples/scenario_outline_table_substitution.feature', File.dirname(__FILE__)) }
80
92
 
@@ -12,12 +12,13 @@ describe 'The CLI', :type => :integration do
12
12
  end
13
13
 
14
14
  it "prints out failures and successes" do
15
- @result.should include('42 examples, 4 failures, 5 pending')
15
+ @result.should include('46 examples, 4 failures, 6 pending')
16
16
  end
17
17
 
18
18
  it "includes features in backtraces" do
19
19
  @result.should include('examples/errors.feature:5:in `raise error')
20
20
  @result.should include('examples/errors.feature:11:in `a step just does not exist')
21
+ @result.should include("No such step: 'a step just does not exist'")
21
22
  end
22
23
 
23
24
  it "includes the right step name when steps call steps" do
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Turnip::Node::Feature do
4
+ let(:feature) { Turnip::Builder.build(feature_file) }
5
+
6
+ context 'a file that specifies a language' do
7
+ let(:feature_file) { File.expand_path('../../examples/specific_language.feature', __dir__) }
8
+
9
+ it 'extracts the language' do
10
+ feature.language.should eq 'en-au'
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+
3
+ describe Turnip::RSpec::Execute do
4
+ let(:mod) { Module.new }
5
+ let(:obj) { Object.new.tap { |o| o.extend Turnip::RSpec::Execute; o.extend mod; def o.skip(*args); end } }
6
+ let(:reporter) { RSpec.current_example.reporter }
7
+
8
+ before { allow(reporter).to receive(:publish).and_call_original }
9
+
10
+ def create_step_node(text)
11
+ Turnip::Node::Step.new OpenStruct.new(source_line: 1, source_column: 0, text: text)
12
+ end
13
+
14
+ context '#run_step' do
15
+ it "publishes :step_started event when step is starting" do
16
+ step = create_step_node "a test step"
17
+
18
+ obj.run_step 'test.feature', step
19
+
20
+ expect(reporter).to have_received(:publish).with(:step_started, step: step)
21
+ end
22
+
23
+ it "publishes :step_passed event when step has passed" do
24
+ mod.step("a test step") { true }
25
+ step = create_step_node "a test step"
26
+
27
+ obj.run_step 'test.feature', step
28
+
29
+ expect(reporter).to have_received(:publish).with(:step_passed, step: step)
30
+ end
31
+
32
+ it "publishes :step_failed event when step has failed" do
33
+ mod.step("a failing step") { raise ::RSpec::Expectations::ExpectationNotMetError }
34
+ step = create_step_node "a failing step"
35
+
36
+ begin
37
+ obj.run_step 'test.feature', step
38
+ rescue ::RSpec::Expectations::ExpectationNotMetError => e
39
+ end
40
+
41
+ expect(reporter).to have_received(:publish).with(:step_failed, step: step)
42
+ end
43
+
44
+ it "publishes :step_pending event when step is pending" do
45
+ step = create_step_node "a pending step"
46
+
47
+ obj.run_step 'test.feature', step
48
+
49
+ expect(reporter).to have_received(:publish).with(:step_pending, step: step)
50
+ end
51
+ end
52
+ end
data/turnip.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency "rspec", [">=3.0", "<4.0"]
22
- s.add_runtime_dependency "cucumber-gherkin", "~> 14.0"
22
+ s.add_runtime_dependency "cuke_modeler", "~> 3.15"
23
23
  s.add_development_dependency "rake"
24
24
  s.add_development_dependency "pry"
25
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.2.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2022-11-09 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: cucumber-gherkin
34
+ name: cuke_modeler
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '14.0'
39
+ version: '3.15'
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: '14.0'
46
+ version: '3.15'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +97,8 @@ files:
97
97
  - ".github/workflows/test.yml"
98
98
  - ".gitignore"
99
99
  - ".rspec"
100
- - ".travis.yml"
100
+ - ".tool-versions"
101
+ - CHANGELOG.md
101
102
  - Gemfile
102
103
  - README.md
103
104
  - Rakefile
@@ -112,8 +113,10 @@ files:
112
113
  - examples/pending.feature
113
114
  - examples/scenario_outline.feature
114
115
  - examples/scenario_outline_multiline_string_substitution.feature
116
+ - examples/scenario_outline_scenario_name_substitution.feature
115
117
  - examples/scenario_outline_table_substitution.feature
116
118
  - examples/simple_feature.feature
119
+ - examples/specific_language.feature
117
120
  - examples/step_calling.feature
118
121
  - examples/steps/alignment_steps.rb
119
122
  - examples/steps/autoload_steps.rb
@@ -130,9 +133,8 @@ files:
130
133
  - examples/tags.feature
131
134
  - examples/with_backticks.feature
132
135
  - examples/with_comments.feature
133
- - gemfiles/Gemfile-rspec-3.7.x
134
- - gemfiles/Gemfile-rspec-3.8.x
135
- - gemfiles/Gemfile-rspec-3.9.x
136
+ - gemfiles/Gemfile-rspec-3.11.x
137
+ - gemfiles/Gemfile-rspec-3.12.x
136
138
  - lib/turnip.rb
137
139
  - lib/turnip/builder.rb
138
140
  - lib/turnip/capybara.rb
@@ -160,7 +162,9 @@ files:
160
162
  - spec/define_and_execute_spec.rb
161
163
  - spec/dsl_spec.rb
162
164
  - spec/integration_spec.rb
165
+ - spec/nodes/feature_spec.rb
163
166
  - spec/placeholder_spec.rb
167
+ - spec/reporter_spec.rb
164
168
  - spec/spec_helper.rb
165
169
  - spec/step_definition_spec.rb
166
170
  - spec/table_spec.rb
@@ -169,7 +173,7 @@ homepage: https://github.com/jnicklas/turnip/
169
173
  licenses:
170
174
  - MIT
171
175
  metadata: {}
172
- post_install_message:
176
+ post_install_message:
173
177
  rdoc_options: []
174
178
  require_paths:
175
179
  - lib
@@ -184,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
188
  - !ruby/object:Gem::Version
185
189
  version: '0'
186
190
  requirements: []
187
- rubygems_version: 3.0.3
188
- signing_key:
191
+ rubygems_version: 3.1.2
192
+ signing_key:
189
193
  specification_version: 4
190
194
  summary: Gherkin extension for RSpec
191
195
  test_files:
@@ -193,7 +197,9 @@ test_files:
193
197
  - spec/define_and_execute_spec.rb
194
198
  - spec/dsl_spec.rb
195
199
  - spec/integration_spec.rb
200
+ - spec/nodes/feature_spec.rb
196
201
  - spec/placeholder_spec.rb
202
+ - spec/reporter_spec.rb
197
203
  - spec/spec_helper.rb
198
204
  - spec/step_definition_spec.rb
199
205
  - spec/table_spec.rb
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
-
3
- sudo: false
4
- cache: bundler
5
-
6
- branches:
7
- only:
8
- - master
9
-
10
- rvm:
11
- - 2.5.8
12
- - 2.6.6
13
- - 2.7.1
14
- - jruby
15
-
16
- gemfile:
17
- - gemfiles/Gemfile-rspec-3.7.x
18
- - gemfiles/Gemfile-rspec-3.8.x
19
- - gemfiles/Gemfile-rspec-3.9.x
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in turnip.gemspec
4
- gemspec :path => '..'
5
-
6
- gem 'rspec', '~> 3.9.0'
7
- gem 'pry-byebug', platforms: :mri