Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ gemspec
if ENV['CUCUMBER_RUBY_CORE']
gem 'cucumber-core', path: ENV['CUCUMBER_RUBY_CORE']
elsif !ENV['CUCUMBER_USE_RELEASED_GEMS']
gem 'cucumber-core', github: 'cucumber/cucumber-ruby-core'
gem 'cucumber-core', github: 'cucumber/cucumber-ruby-core', branch: 'gherkin-8'
end

if ENV['CUCUMBER_RUBY_WIRE']
gem 'cucumber-wire', path: ENV['CUCUMBER_RUBY_WIRE']
elsif !ENV['CUCUMBER_USE_RELEASED_GEMS']
gem 'cucumber-wire', github: 'cucumber/cucumber-ruby-wire'
gem 'cucumber-wire', github: 'cucumber/cucumber-ruby-wire', branch: 'gherkin-8'
end

gem 'cucumber-expressions', path: ENV['CUCUMBER_EXPRESSIONS_RUBY'] if ENV['CUCUMBER_EXPRESSIONS_RUBY']
Expand All @@ -22,7 +22,5 @@ gem 'gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY']

gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY']

gem 'cucumber-formatter-dots', path: ENV['CUCUMBER_FORMATTER_DOTS'] if ENV['CUCUMBER_FORMATTER_DOTS']

# Use an older protobuf on JRuby
gem 'google-protobuf', '~> 3.2.0.2' if RUBY_PLATFORM == 'java'
5 changes: 2 additions & 3 deletions cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.3'
s.add_dependency 'builder', '~> 3.2', '>= 3.2.3'
s.add_dependency 'cucumber-core', '~> 5.0', '>= 5.0.0'
s.add_dependency 'cucumber-expressions', '~> 8.0', '>= 8.0.0'
s.add_dependency 'cucumber-formatter-dots', '~> 1.2', '>= 1.2.0'
s.add_dependency 'cucumber-expressions', '~> 8.0', '>= 8.0.2'
s.add_dependency 'cucumber-wire', '~> 1.0', '>= 1.0.0'
s.add_dependency 'diff-lcs', '~> 1.3', '>= 1.3'
s.add_dependency 'gherkin', '~> 7.0', '>= 7.0.3'
s.add_dependency 'gherkin', '~> 8.1', '>= 8.1.1'
s.add_dependency 'multi_json', '~> 1.13', '>= 1.13.1'
s.add_dependency 'multi_test', '~> 0.1', '>= 0.1.2'

Expand Down
25 changes: 0 additions & 25 deletions features/docs/formatters/dots_formatter.feature

This file was deleted.

56 changes: 56 additions & 0 deletions features/docs/gherkin/example.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Feature: Example

Example is a synonym for Scenario.

Background:
Given a file named "features/example.feature" with:
"""
Feature: A simple example

Example: First example
Given some context
When I do an action
Then some results should be there
"""
And a file named "features/second_example.feature" with:
"""
Feature: Another example

Example: First example
Given some context
When I do an action
Then some results should be there
"""
And a file named "features/step_definitions/steps.rb" with:
"""
Given("some context") { }
When("I do an action") { }
Then("some results should be there") { }
"""

Example: I can use the Example keyword
When I run `cucumber -q features/example.feature`
Then it should pass with exactly:
"""
Feature: A simple example

Example: First example
Given some context
When I do an action
Then some results should be there

1 scenario (1 passed)
3 steps (3 passed)
"""

Example: an Example can have multiple Examples
When I run `cucumber -q <feature_file>`
Then the output should contain:
"""
<expected>
"""

Examples:
| feature_file | expected |
| features/example.feature | Feature: A simple example |
| features/second_example.feature | Feature: Another example |
66 changes: 66 additions & 0 deletions features/docs/gherkin/rule.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Feature: Rule

After running an example mapping session, you end up with four kind of cards: features, rules, examples and questions.
Since Gherkin 6, this is easily translated in your feature files.

Background:
Given a file named "features/rule.feature" with:
"""
Feature: Rule Sample

Rule: This is a rule

Example: First example
Given some context
When I do an action
Then some results should be there

Example: Second example
Given some context
When I do another action
Then some other results should be there

Rule: This is a second rule

Example: First example
Given some other context
When I do another action
Then some results should be there
"""
And a file named "features/step_definitions/steps.rb" with:
"""
Given("some context") { }
Given("some other context") { }
When("I do an action") { }
Then("some results should be there") { }
When("I do another action") { }
Then("some other results should be there") { }

"""


Rule: I use Gherkin 6+
Example: I can use the Rule keyword
When I run `cucumber -q features/rule.feature`
Then it should pass with exactly:
"""
Feature: Rule Sample

Example: First example
Given some context
When I do an action
Then some results should be there

Example: Second example
Given some context
When I do another action
Then some other results should be there

Example: First example
Given some other context
When I do another action
Then some results should be there

3 scenarios (3 passed)
9 steps (9 passed)
"""
1 change: 0 additions & 1 deletion lib/cucumber/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Options
BUILTIN_FORMATS = {
'pretty' => ['Cucumber::Formatter::Pretty', 'Prints the feature as is - in colours.'],
'progress' => ['Cucumber::Formatter::Progress', 'Prints one character per scenario.'],
'dots' => ['Cucumber::Formatter::Dots', 'Simple progress output to console'],
'rerun' => ['Cucumber::Formatter::Rerun', 'Prints failing files with line numbers.'],
'usage' => ['Cucumber::Formatter::Usage', "Prints where step definitions are used.\n" \
"#{INDENT}The slowest step definitions (with duration) are\n" \
Expand Down
13 changes: 11 additions & 2 deletions lib/cucumber/gherkin/data_table_parser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'gherkin/gherkin'
require 'gherkin'
require 'gherkin/dialect'

module Cucumber
Expand All @@ -12,7 +12,8 @@ def initialize(builder)

def parse(text)
gherkin_document = nil
messages = ::Gherkin::Gherkin.from_source('dummy', feature_header + text, include_source: false, include_pickles: false)
messages = ::Gherkin.from_source('dummy', feature_header + text, gherkin_options)

messages.each do |message|
gherkin_document = message.gherkinDocument.to_hash unless message.gherkinDocument.nil?
end
Expand All @@ -23,6 +24,14 @@ def parse(text)
end
end

def gherkin_options
{
include_source: false,
include_gherkin_document: true,
include_pickles: false
}
end

def feature_header
dialect = ::Gherkin::Dialect.for('en')
%(#{dialect.feature_keywords[0]}:
Expand Down
14 changes: 12 additions & 2 deletions lib/cucumber/gherkin/steps_parser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'gherkin/gherkin'
require 'gherkin'
require 'gherkin/dialect'

module Cucumber
Expand All @@ -14,14 +14,24 @@ def initialize(builder, language)
def parse(text)
dialect = ::Gherkin::Dialect.for(@language)
gherkin_document = nil
messages = ::Gherkin::Gherkin.from_source('dummy', feature_header(dialect) + text, default_dialect: @language, include_source: false, include_pickles: false)
messages = ::Gherkin.from_source('dummy', feature_header(dialect) + text, gherkin_options)

messages.each do |message|
gherkin_document = message.gherkinDocument.to_hash unless message.gherkinDocument.nil?
end

@builder.steps(gherkin_document[:feature][:children][0][:scenario][:steps])
end

def gherkin_options
{
default_dialect: @language,
include_source: false,
include_gherkin_document: true,
include_pickles: false
}
end

def feature_header(dialect)
%(#{dialect.feature_keywords[0]}:
#{dialect.scenario_keywords[0]}:
Expand Down