repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/filters/tag_limits/test_case_index_spec.rb | spec/cucumber/filters/tag_limits/test_case_index_spec.rb | # frozen_string_literal: true
require 'cucumber/filters/tag_limits'
describe Cucumber::Filters::TagLimits::TestCaseIndex do
subject(:index) { described_class.new }
let(:test_cases) do
[
double(:test_case, tags: [tag_one], location: a_location_of_tag_one),
double(:test_case, tags: [tag_one, tag_two], location: a_location_of_tag_one_and_tag_two)
]
end
let(:tag_one) { double(:tag_one, name: '@one') }
let(:tag_two) { double(:tag_two, name: '@two') }
let(:a_location_of_tag_one) { double(:a_location_of_tag_one) }
let(:a_location_of_tag_one_and_tag_two) { double(:a_location_of_tag_one_and_tag_two) }
before do
test_cases.map do |test_case|
index.add(test_case)
end
end
describe '#count_by_tag_name' do
it 'returns the number of test cases with the tag' do
expect(index.count_by_tag_name('@one')).to eq(2)
expect(index.count_by_tag_name('@two')).to eq(1)
end
end
describe '#locations_by_tag_name' do
it 'returns the locations of test cases with the tag' do
expect(index.locations_of_tag_name('@one')).to eq([a_location_of_tag_one, a_location_of_tag_one_and_tag_two])
expect(index.locations_of_tag_name('@two')).to eq([a_location_of_tag_one_and_tag_two])
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/filters/tag_limits/verifier_spec.rb | spec/cucumber/filters/tag_limits/verifier_spec.rb | # frozen_string_literal: true
require 'cucumber/filters/tag_limits'
describe Cucumber::Filters::TagLimits::Verifier do
describe '#verify!' do
subject(:verifier) { described_class.new(tag_limits) }
let(:test_case_index) { double(:test_case_index) }
context 'when the tag counts exceed the tag limits' do
let(:tag_limits) do
{
'@exceed_me' => 1
}
end
let(:locations) do
[
double(:location, to_s: 'path/to/some.feature:3'),
double(:location, to_s: 'path/to/some/other.feature:8')
]
end
before do
allow(test_case_index).to receive(:count_by_tag_name).with('@exceed_me').and_return(2)
allow(test_case_index).to receive(:locations_of_tag_name).with('@exceed_me') { locations }
end
it 'raises a TagLimitExceeded error with the locations of the tags' do
expect { verifier.verify!(test_case_index) }.to raise_error(
Cucumber::Filters::TagLimitExceededError,
"@exceed_me occurred 2 times, but the limit was set to 1\n" \
" path/to/some.feature:3\n" \
' path/to/some/other.feature:8'
)
end
end
context 'when the tag counts do not exceed the tag limits' do
let(:tag_limits) do
{
'@dont_exceed_me' => 2
}
end
before do
allow(test_case_index).to receive(:count_by_tag_name).with('@dont_exceed_me').and_return(1)
end
it 'does not raise an error' do
expect { verifier.verify!(test_case_index) }.not_to raise_error
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/rake/task_spec.rb | spec/cucumber/rake/task_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/rake/task'
require 'rake'
module Cucumber
module Rake
describe Task do
describe '#task_name' do
it 'can be read' do
expect(subject.task_name).to eq('cucumber')
end
end
describe '#task_name=' do
it { is_expected.not_to respond_to(:task_name=) }
end
describe '#cucumber_opts' do
before { subject.cucumber_opts = opts }
context 'when set via array' do
let(:opts) { %w[foo bar] }
it { expect(subject.cucumber_opts).to be opts }
end
context 'when set via string' do
let(:opts) { 'foo=bar' }
it { expect(subject.cucumber_opts).to eq %w[foo=bar] }
end
context 'when set via space-delimited string' do
let(:opts) { 'foo bar' }
it { expect(subject.cucumber_opts).to eq %w[foo bar] }
it 'emits a warning to suggest using arrays rather than string' do
expect { subject.cucumber_opts = opts }.to output(
a_string_including(
'WARNING: consider using an array rather than a space-delimited string with cucumber_opts to avoid undesired behavior.'
)
).to_stderr
end
end
end
describe '#cucumber_opts_with_profile' do
before do
subject.cucumber_opts = opts
subject.profile = profile
end
context 'with cucumber_opts' do
let(:opts) { %w[foo bar] }
context 'without profile' do
let(:profile) { nil }
it 'returns just cucumber_opts' do
expect(subject.cucumber_opts_with_profile).to be opts
end
end
context 'with profile' do
let(:profile) { 'fancy' }
it 'combines opts and profile into an array, prepending --profile option' do
expect(subject.cucumber_opts_with_profile).to eq %w[foo bar --profile fancy]
end
end
context 'with multiple profiles' do
let(:profile) { %w[fancy pants] }
it 'combines opts and each profile into an array, prepending --profile option' do
expect(subject.cucumber_opts_with_profile).to eq %w[foo bar --profile fancy --profile pants]
end
end
end
context 'without cucumber_opts' do
let(:opts) { nil }
context 'without profile' do
let(:profile) { nil }
it { expect(subject.cucumber_opts_with_profile).to eq [] }
end
context 'with profile' do
let(:profile) { 'fancy' }
it 'combines opts and profile into an array, prepending --profile option' do
expect(subject.cucumber_opts_with_profile).to eq %w[--profile fancy]
end
end
context 'with multiple profiles' do
let(:profile) { %w[fancy pants] }
it 'combines opts and each profile into an array, prepending --profile option' do
expect(subject.cucumber_opts_with_profile).to eq %w[--profile fancy --profile pants]
end
end
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/rake/forked_spec.rb | spec/cucumber/rake/forked_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/rake/task'
require 'rake'
module Cucumber
module Rake
describe Task::ForkedCucumberRunner do
let(:libs) { ['lib'] }
let(:binary) { Cucumber::BINARY }
let(:cucumber_opts) { ['--cuke-option'] }
let(:feature_files) { ['./some.feature'] }
context 'when running with bundler' do
let(:bundler) { true }
subject { described_class.new(libs, binary, cucumber_opts, bundler, feature_files) }
it 'does use bundler if bundler is set to true' do
expect(subject.use_bundler).to be true
end
it 'uses bundle exec to find cucumber and libraries' do
expect(subject.cmd).to eq [
Cucumber::RUBY_BINARY,
'-S',
'bundle',
'exec',
'cucumber',
'--cuke-option'
] + feature_files
end
end
context 'when running without bundler' do
let(:bundler) { false }
subject { described_class.new(libs, binary, cucumber_opts, bundler, feature_files) }
it 'does not use bundler if bundler is set to false' do
expect(subject.use_bundler).to be false
end
it 'uses well known cucumber location and specified libraries' do
expect(subject.cmd).to eq [
Cucumber::RUBY_BINARY,
'-I',
'"lib"',
"\"#{Cucumber::BINARY}\"",
'--cuke-option'
] + feature_files
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/cli/rerun_spec.rb | spec/cucumber/cli/rerun_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Cucumber
module Cli
describe RerunFile do
let(:rerun_file) { described_class.new('@rerun.txt') }
it 'expects rerun files to have a leading @' do
allow(File).to receive(:file?).and_return(true)
expect(described_class.can_read?('rerun.txt')).to eq false
expect(described_class.can_read?('@rerun.txt')).to eq true
end
it 'does not treat directories as rerun files' do
allow(File).to receive(:file?).and_return(false)
expect(described_class.can_read?('@rerun.txt')).to eq false
end
it 'removes leading @ character from filename' do
expect(rerun_file.path).to eq 'rerun.txt'
end
context 'with a rerun file containing a single feature reference' do
before(:each) do
allow(IO).to receive(:read).and_return('cucumber.feature')
end
it 'produces an array containing a single feature file path' do
expect(rerun_file.features).to eq %w[cucumber.feature]
end
end
context 'with a rerun file containing multiple feature references on multiple lines' do
before(:each) do
allow(IO).to receive(:read).and_return("cucumber.feature\nfoo.feature")
end
it 'produces an array containing multiple feature file paths' do
expect(rerun_file.features).to eq %w[cucumber.feature foo.feature]
end
end
context 'with a rerun file containing multiple feature references on the same line' do
before(:each) do
allow(IO).to receive(:read).and_return('cucumber.feature foo.feature')
end
it 'produces an array containing multiple feature file paths' do
expect(rerun_file.features).to eq %w[cucumber.feature foo.feature]
end
end
context 'with a rerun file containing multiple scenario references on the same line' do
before(:each) do
allow(IO).to receive(:read).and_return('cucumber.feature:8 foo.feature:8:16')
end
it 'produces an array containing multiple feature file paths with scenario lines' do
expect(rerun_file.features).to eq %w[cucumber.feature:8 foo.feature:8:16]
end
end
context 'with a rerun file containing multiple feature references with spaces in file names' do
before(:each) do
allow(IO).to receive(:read).and_return('cucumber test.feature:8 foo.feature:8:16')
end
it 'produces an array containing multiple feature file paths with scenario lines' do
expect(rerun_file.features).to eq ['cucumber test.feature:8', 'foo.feature:8:16']
end
end
context 'with a rerun file containing multiple scenario references without spaces in between them' do
before(:each) do
allow(IO).to receive(:read).and_return('cucumber test.feature:8foo.feature:8:16')
end
it 'produces an array containing multiple feature file paths with scenario lines' do
expect(rerun_file.features).to eq ['cucumber test.feature:8', 'foo.feature:8:16']
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/cli/configuration_spec.rb | spec/cucumber/cli/configuration_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'yaml'
module Cucumber
module Cli
module ExposesOptions
attr_reader :options
end
describe Configuration do
def given_cucumber_yml_defined_as(hash_or_string)
allow(File).to receive(:exist?).and_return(true)
cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
end
def given_the_following_files(*files)
allow(File).to receive(:directory?).and_return(true)
allow(File).to receive(:file?).and_return(true)
allow(Dir).to receive(:[]) { files }
end
before do
allow(File).to receive(:exist?).and_return(false)
allow(Kernel).to receive(:exit)
end
def config
@config ||= Configuration.new(@out = StringIO.new, @error = StringIO.new).extend(ExposesOptions)
end
def reset_config
@config = nil
end
attr_reader :out, :error
it 'uses the default profile when no profile is defined' do
given_cucumber_yml_defined_as('default' => '--require some_file')
config.parse!(%w[--format progress])
expect(config.options[:require]).to include('some_file')
end
context 'when using the --profile flag' do
it 'expands args from profiles in the cucumber.yml file' do
given_cucumber_yml_defined_as('bongo' => '--require from/yml')
config.parse!(%w[--format progress --profile bongo])
expect(config.options[:formats]).to eq [['progress', {}, out]]
expect(config.options[:require]).to eq ['from/yml']
end
it 'expands args from the default profile when no flags are provided' do
given_cucumber_yml_defined_as('default' => '--require from/yml')
config.parse!([])
expect(config.options[:require]).to eq ['from/yml']
end
it 'allows --strict to be set by a profile' do
given_cucumber_yml_defined_as('bongo' => '--strict')
config.parse!(%w[--profile bongo])
expect(config.options[:strict].strict?(:undefined)).to be true
expect(config.options[:strict].strict?(:pending)).to be true
expect(config.options[:strict].strict?(:flaky)).to be true
end
it 'allows --strict from a profile to be selectively overridden' do
given_cucumber_yml_defined_as('bongo' => '--strict')
config.parse!(%w[--profile bongo --no-strict-flaky])
expect(config.options[:strict].strict?(:undefined)).to be true
expect(config.options[:strict].strict?(:pending)).to be true
expect(config.options[:strict].strict?(:flaky)).to be false
end
it 'parses ERB syntax in the cucumber.yml file' do
given_cucumber_yml_defined_as("---\ndefault: \"<%=\"--require some_file\"%>\"\n")
config.parse!([])
expect(config.options[:require]).to include('some_file')
end
it 'parses ERB in cucumber.yml that makes uses nested ERB sessions' do
given_cucumber_yml_defined_as(<<~ERB_YML)
<%= ERB.new({'standard' => '--require some_file'}.to_yaml).result %>
<%= ERB.new({'enhanced' => '--require other_file'}.to_yaml).result %>
ERB_YML
config.parse!(%w[-p standard])
expect(config.options[:require]).to include('some_file')
end
it 'provides a helpful error message when a specified profile does not exists in cucumber.yml' do
given_cucumber_yml_defined_as('default' => '--require from/yml', 'json_report' => '--format json')
expected_message = <<~END_OF_MESSAGE
Could not find profile: 'i_do_not_exist'
Defined profiles in cucumber.yml:
* default
* json_report
END_OF_MESSAGE
expect { config.parse!(%w[--profile i_do_not_exist]) }.to raise_error(ProfileNotFound, expected_message)
end
it 'allows profiles to be defined in arrays' do
given_cucumber_yml_defined_as('foo' => ['-f', 'progress'])
config.parse!(%w[--profile foo])
expect(config.options[:formats]).to eq [['progress', {}, out]]
end
it 'disregards default STDOUT formatter defined in profile when another is passed in (via cmd line)' do
given_cucumber_yml_defined_as('foo' => %w[--format pretty])
config.parse!(%w[--format progress --profile foo])
expect(config.options[:formats]).to eq [['progress', {}, out]]
end
['--no-profile', '-P'].each do |flag|
context "when #{flag} is specified with none" do
it 'disables profiles' do
given_cucumber_yml_defined_as('default' => '-v --require file_specified_in_default_profile.rb')
config.parse!("#{flag} --require some_file.rb".split(' '))
expect(config.options[:require]).to eq ['some_file.rb']
end
it 'notifies the user that the profiles are being disabled' do
given_cucumber_yml_defined_as('default' => '-v')
config.parse!("#{flag} --require some_file.rb".split(' '))
expect(out.string).to match(/Disabling profiles.../)
end
end
end
it 'issues a helpful error message when a specified profile exists but is nil or blank' do
[nil, ' '].each do |bad_input|
given_cucumber_yml_defined_as('foo' => bad_input)
expected_error = /The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml./
expect { config.parse!(%w[--profile foo]) }.to raise_error(expected_error)
end
end
it 'issues a helpful error message when no YAML file exists and a profile is specified' do
expect(File).to receive(:exist?).with('cucumber.yml').and_return(false)
expect { config.parse!(%w[--profile i_do_not_exist]) }.to raise_error(/cucumber\.yml was not found/)
end
it 'issues a helpful error message when cucumber.yml is blank or malformed' do
expected_error_message = /cucumber\.yml was found, but was blank or malformed.\nPlease refer to cucumber's documentation on correct profile usage./
['', 'sfsadfs', "--- \n- an\n- array\n", '---dddfd'].each do |bad_input|
given_cucumber_yml_defined_as(bad_input)
expect { config.parse!([]) }.to raise_error(expected_error_message)
reset_config
end
end
it 'issues a helpful error message when cucumber.yml can not be parsed' do
given_cucumber_yml_defined_as('input that causes an exception in YAML loading')
expect(YAML).to receive(:load).and_raise(ArgumentError)
expect { config.parse!([]) }.to raise_error(/cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage./)
end
it 'issues a helpful error message when cucumber.yml can not be parsed by ERB' do
given_cucumber_yml_defined_as('<% this_fails %>')
expect { config.parse!([]) }.to raise_error(/cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage./)
end
end
it 'accepts --dry-run option' do
config.parse!(%w[--dry-run])
expect(config.options[:dry_run]).to be true
end
it 'implies --no-duration with --dry-run option' do
config.parse!(%w[--dry-run])
expect(config.options[:duration]).to be false
end
it 'accepts --no-source option' do
config.parse!(%w[--no-source])
expect(config.options[:source]).to be false
end
it 'accepts --no-snippets option' do
config.parse!(%w[--no-snippets])
expect(config.options[:snippets]).to be false
end
it 'sets snippets and source and duration to false with --quiet option' do
config.parse!(%w[--quiet])
expect(config.options[:snippets]).to be false
expect(config.options[:source]).to be false
expect(config.options[:duration]).to be false
end
it 'sets duration to false with --no-duration' do
config.parse!(%w[--no-duration])
expect(config.options[:duration]).to be false
end
it 'accepts --verbose option' do
config.parse!(%w[--verbose])
expect(config.options[:verbose]).to be true
end
it 'uses the pretty formatter to stdout when no formatter is defined' do
config.parse!([])
expect(config.formats).to eq [['pretty', {}, out]]
end
it 'adds the default formatter when no other formatter is defined with --publish' do
config.parse!(['--publish'])
expect(config.formats).to eq [
['pretty', {}, out],
['message', {}, 'https://messages.cucumber.io/api/reports -X GET']
]
end
it 'does not add the default formatter when a formatter is defined with --publish' do
config.parse!(['--publish', '--format', 'progress'])
expect(config.formats).to eq [
['progress', {}, out],
['message', {}, 'https://messages.cucumber.io/api/reports -X GET']
]
end
it 'does not add the default formatter with --format message' do
config.parse!(['--format', 'message'])
expect(config.formats).to eq [
['message', {}, out]
]
end
it 'accepts --out option' do
config.parse!(%w[--out jalla.txt])
expect(config.formats).to eq [['pretty', {}, 'jalla.txt']]
end
it 'accepts multiple --out options' do
config.parse!(%w[--format progress --out file1 --out file2])
expect(config.formats).to eq [['progress', {}, 'file2']]
end
it 'accepts multiple --format options and put the STDOUT one first so progress is seen' do
config.parse!(%w[--format pretty --out pretty.txt --format progress])
expect(config.formats).to eq [['progress', {}, out], ['pretty', {}, 'pretty.txt']]
end
it 'does not accept multiple --format options when both use implicit STDOUT' do
expect { config.parse!(%w[--format pretty --format progress]) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'does not accept multiple --format options when both use implicit STDOUT (using profile with no formatters)' do
given_cucumber_yml_defined_as('default' => ['-q'])
expect { config.parse!(%w[--format pretty --format progress]) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'accepts same --format options with implicit STDOUT, and keep only one' do
config.parse!(%w[--format pretty --format pretty])
expect(config.formats).to eq [['pretty', {}, out]]
end
it 'does not accept multiple --out streams pointing to the same place' do
expected_error = 'All but one formatter must use --out, only one can print to each stream (or STDOUT)'
expect { config.parse!(%w[--format pretty --out file1 --format progress --out file1]) }.to raise_error(expected_error)
end
it 'does not accept multiple --out streams pointing to the same place (one from profile, one from command line)' do
given_cucumber_yml_defined_as('default' => ['-f', 'progress', '--out', 'file1'])
expect { config.parse!(%w[--format pretty --out file1]) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'associates --out to previous --format' do
config.parse!(%w[--format progress --out file1 --format profile --out file2])
expect(config.formats).to match_array([['progress', {}, 'file1'], ['profile', {}, 'file2']])
end
it 'accepts same --format options with same --out streams and keep only one' do
config.parse!(%w[--format json --out file --format pretty --format json --out file])
expect(config.formats).to eq [['pretty', {}, out], ['json', {}, 'file']]
end
it 'accepts same --format options with different --out streams' do
config.parse!(%w[--format json --out file1 --format json --out file2])
expect(config.formats).to match_array([['json', {}, 'file1'], ['json', {}, 'file2']])
end
it 'accepts --color option' do
expect(Cucumber::Term::ANSIColor).to receive(:coloring=).with(true)
config.parse!(['--color'])
end
it 'accepts --no-color option' do
expect(Cucumber::Term::ANSIColor).to receive(:coloring=).with(false)
config = described_class.new(StringIO.new)
config.parse!(['--no-color'])
end
describe '--backtrace' do
before do
Cucumber.use_full_backtrace = false
end
after do
Cucumber.use_full_backtrace = false
end
it 'shows full backtrace when --backtrace is present' do
Main.new(['--backtrace'])
expect('x').to eq('y')
rescue RSpec::Expectations::ExpectationNotMetError => e
expect(e.backtrace[0]).not_to eq "#{__FILE__}:#{__LINE__ - 2}"
end
end
it 'accepts multiple --name options' do
config.parse!(['--name', 'User logs in', '--name', 'User signs up'])
expect(config.options[:name_regexps]).to include(/User logs in/)
expect(config.options[:name_regexps]).to include(/User signs up/)
end
it 'accepts multiple -n options' do
config.parse!(['-n', 'User logs in', '-n', 'User signs up'])
expect(config.options[:name_regexps]).to include(/User logs in/)
expect(config.options[:name_regexps]).to include(/User signs up/)
end
it 'allows specifying environment variables on the command line' do
config.parse!(['foo=bar'])
expect(ENV['foo']).to eq 'bar'
expect(config.paths).not_to include('foo=bar')
end
it 'allows specifying environment variables in profiles' do
given_cucumber_yml_defined_as('selenium' => 'RAILS_ENV=selenium')
config.parse!(['--profile', 'selenium'])
expect(ENV['RAILS_ENV']).to eq 'selenium'
expect(config.paths).not_to include('RAILS_ENV=selenium')
end
describe '#tag_expressions' do
it 'returns an empty expression when no tags are specified' do
config.parse!([])
expect(config.tag_expressions).to be_empty
end
it 'returns an expression when tags are specified' do
config.parse!(['--tags', '@foo'])
expect(config.tag_expressions).not_to be_empty
end
end
describe '#tag_limits' do
it 'returns an empty hash when no limits are specified' do
config.parse!([])
expect(config.tag_limits).to eq({})
end
it 'returns a hash of limits when limits are specified' do
config.parse!(['--tags', '@foo:1'])
expect(config.tag_limits).to eq('@foo' => 1)
end
end
describe '#dry_run?' do
it 'returns true when --dry-run was specified on in the arguments' do
config.parse!(['--dry-run'])
expect(config.dry_run?).to be true
end
it 'returns true when --dry-run was specified in yaml file' do
given_cucumber_yml_defined_as('default' => '--dry-run')
config.parse!([])
expect(config.dry_run?).to be true
end
it 'returns false by default' do
config.parse!([])
expect(config.dry_run?).to be false
end
end
describe '#snippet_type' do
it 'returns the snippet type when it was set' do
config.parse!(['--snippet-type', 'classic'])
expect(config.snippet_type).to eq(:classic)
end
it 'returns the snippet type when it was set with shorthand option' do
config.parse!(['-I', 'classic'])
expect(config.snippet_type).to eq(:classic)
end
it 'returns the default snippet type if it was not set' do
config.parse!([])
expect(config.snippet_type).to eq(:cucumber_expression)
end
end
describe '#retry_attempts' do
it 'returns the specified number of retries' do
config.parse!(['--retry=3'])
expect(config.retry_attempts).to eq(3)
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/cli/profile_loader_spec.rb | spec/cucumber/cli/profile_loader_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'yaml'
module Cucumber
module Cli
describe ProfileLoader do
subject(:loader) { described_class.new }
def given_cucumber_yml_defined_as(hash_or_string)
allow(Dir).to receive(:glob).with('{,.config/,config/}cucumber{.yml,.yaml}').and_return(['cucumber.yml'])
allow(File).to receive(:exist?).and_return(true)
cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
end
context 'when on a Windows OS' do
before { skip('These tests are only to be ran on Windows') unless Cucumber::WINDOWS }
it 'treats backslashes as literals in rerun.txt when on Windows (JRuby or MRI)' do
given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22')
expect(loader.args_from('default')).to eq(['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22'])
end
it 'treats forward slashes as literals' do
given_cucumber_yml_defined_as('default' => '--format "ugly" features/sync_imap_mailbox.feature:16:22')
expect(loader.args_from('default')).to eq ['--format', 'ugly', 'features/sync_imap_mailbox.feature:16:22']
end
it 'treats percent sign as ERB code block after YAML directive' do
yml = <<~HERE
---
% x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
default: <%= x %>
HERE
given_cucumber_yml_defined_as yml
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features/sync_imap_mailbox.feature:16:22']
end
it 'correctly parses a profile that uses tag expressions (with double quotes)' do
given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22 --tags "not @jruby"')
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
end
it 'correctly parses a profile that uses tag expressions (with single quotes)' do
given_cucumber_yml_defined_as('default' => "--format 'pretty' features\\sync_imap_mailbox.feature:16:22 --tags 'not @jruby'")
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
end
end
context 'when on non-Windows OS' do
before { skip('These tests are only to be ran on a "Non-Windows" OS') if Cucumber::WINDOWS }
it 'treats backslashes as literals in rerun.txt when on Windows (JRuby or MRI)' do
given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22')
expect(loader.args_from('default')).to eq(['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22'])
end
it 'treats forward slashes as literals' do
given_cucumber_yml_defined_as('default' => '--format "ugly" features/sync_imap_mailbox.feature:16:22')
expect(loader.args_from('default')).to eq ['--format', 'ugly', 'features/sync_imap_mailbox.feature:16:22']
end
it 'treats percent sign as ERB code block after YAML directive' do
yml = <<~HERE
---
% x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
default: <%= x %>
HERE
given_cucumber_yml_defined_as yml
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features/sync_imap_mailbox.feature:16:22']
end
it 'correctly parses a profile that uses tag expressions (with double quotes)' do
given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22 --tags "not @jruby"')
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
end
it 'correctly parses a profile that uses tag expressions (with single quotes)' do
given_cucumber_yml_defined_as('default' => "--format 'pretty' features\\sync_imap_mailbox.feature:16:22 --tags 'not @jruby'")
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/cli/main_spec.rb | spec/cucumber/cli/main_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'yaml'
module Cucumber
module Cli
describe Main do
before(:each) do
allow(File).to receive(:exist?).and_return(false) # When Configuration checks for cucumber.yml
allow(Dir).to receive(:[]).and_return([]) # to prevent cucumber's features dir to being laoded
end
let(:args) { [] }
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
let(:kernel) { double(:kernel) }
subject { described_class.new(args, stdout, stderr, kernel) }
describe '#execute!' do
context 'when passed an existing runtime' do
let(:existing_runtime) { double('runtime').as_null_object }
def do_execute
subject.execute!(existing_runtime)
end
it 'configures that runtime' do
expected_configuration = double('Configuration').as_null_object
allow(Configuration).to receive(:new) { expected_configuration }
expect(existing_runtime).to receive(:configure).with(expected_configuration)
expect(kernel).to receive(:exit).with(1)
do_execute
end
it 'uses that runtime for running and reporting results' do
expected_results = double('results', failure?: true)
expect(existing_runtime).to receive(:run!)
allow(existing_runtime).to receive(:results) { expected_results }
expect(kernel).to receive(:exit).with(1)
do_execute
end
end
context 'when interrupted with ctrl-c' do
after do
Cucumber.wants_to_quit = false
end
it 'exits with error code' do
results = double('results', failure?: false)
allow_any_instance_of(Runtime).to receive(:run!)
allow_any_instance_of(Runtime).to receive(:results) { results }
Cucumber.wants_to_quit = true
expect(kernel).to receive(:exit).with(2)
subject.execute!
end
end
end
[ProfilesNotDefinedError, YmlLoadError, ProfileNotFound].each do |exception_klass|
it "rescues #{exception_klass}, prints the message to the error stream" do
configuration = double('configuration')
allow(Configuration).to receive(:new) { configuration }
allow(configuration).to receive(:parse!).and_raise(exception_klass.new('error message'))
allow(kernel).to receive(:exit).with(2)
subject.execute!
expect(stderr.string).to eq "error message\n"
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/cli/options_spec.rb | spec/cucumber/cli/options_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'yaml'
require 'cucumber/cli/options'
module Cucumber
module Cli
describe Options do
def given_cucumber_yml_defined_as(hash_or_string)
allow(File).to receive(:exist?).and_return(true)
cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
end
before(:each) do
allow(File).to receive(:exist?).and_return(false) # Meaning, no cucumber.yml exists
allow(Kernel).to receive(:exit)
end
def output_stream
@output_stream ||= StringIO.new
end
def error_stream
@error_stream ||= StringIO.new
end
def options
@options ||= Options.new(output_stream, error_stream)
end
def prepare_args(args)
args.is_a?(Array) ? args : args.split(' ')
end
describe 'parsing' do
def when_parsing(args)
yield
options.parse!(prepare_args(args))
end
def after_parsing(args)
options.parse!(prepare_args(args))
yield
end
def with_env(name, value)
previous_value = ENV[name]
ENV[name] = value.to_s
yield
if previous_value.nil?
ENV.delete(name)
else
ENV[name] = previous_value
end
end
context 'when using -r or --require' do
it 'collects all specified files into an array' do
after_parsing('--require some_file.rb -r another_file.rb') do
expect(options[:require]).to eq ['some_file.rb', 'another_file.rb']
end
end
end
context 'with --i18n-languages' do
it 'lists all known languages' do
after_parsing '--i18n-languages' do
::Gherkin::DIALECTS.keys.map do |key|
expect(@output_stream.string).to include(key.to_s)
end
end
end
it 'exits the program' do
when_parsing('--i18n-languages') { expect(Kernel).to receive(:exit) }
end
end
context 'with --i18n-keywords but an invalid LANG' do
it 'exits' do
when_parsing '--i18n-keywords foo' do
expect(Kernel).to receive(:exit)
end
end
it 'says the language was invalid' do
after_parsing '--i18n-keywords foo' do
expect(@output_stream.string).to include("Invalid language 'foo'. Available languages are:")
end
end
it 'displays the language table' do
after_parsing '--i18n-keywords foo' do
::Gherkin::DIALECTS.keys.map do |key|
expect(@output_stream.string).to include(key.to_s)
end
end
end
end
context 'when using -f FORMAT or --format FORMAT' do
it 'defaults the output for the formatter to the output stream (STDOUT)' do
after_parsing('-f pretty') { expect(options[:formats]).to eq [['pretty', {}, output_stream]] }
end
it 'extracts per-formatter options' do
after_parsing('-f pretty,foo=bar,foo2=bar2') do
expect(options[:formats]).to eq [['pretty', { 'foo' => 'bar', 'foo2' => 'bar2' }, output_stream]]
end
end
it 'extracts junit formatter file attribute option' do
after_parsing('-f junit,file-attribute=true') do
expect(options[:formats]).to eq [['junit', { 'file-attribute' => 'true' }, output_stream]]
end
end
it 'extracts junit formatter file attribute option with pretty' do
after_parsing('-f pretty -f junit,file-attribute=true -o file.txt') do
expect(options[:formats]).to eq [['pretty', {}, output_stream], ['junit', { 'file-attribute' => 'true' }, 'file.txt']]
end
end
end
context 'when using -o [FILE|DIR] or --out [FILE|DIR]' do
it "defaults the formatter to 'pretty' when not specified earlier" do
after_parsing('-o file.txt') { expect(options[:formats]).to eq [['pretty', {}, 'file.txt']] }
end
it 'sets the output for the formatter defined immediately before it' do
after_parsing('-f profile --out file.txt -f pretty -o file2.txt') do
expect(options[:formats]).to eq [['profile', {}, 'file.txt'], ['pretty', {}, 'file2.txt']]
end
end
end
context 'when handling multiple formatters' do
let(:options) { described_class.new(output_stream, error_stream, default_profile: 'default') }
it 'catches multiple command line formatters using the same stream' do
expect { options.parse!(prepare_args('-f pretty -f progress')) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'catches multiple profile formatters using the same stream' do
given_cucumber_yml_defined_as('default' => '-f progress -f pretty')
expect { options.parse!(%w[]) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'profiles does not affect the catching of multiple command line formatters using the same stream' do
given_cucumber_yml_defined_as('default' => '-q')
expect { options.parse!(%w[-f progress -f pretty]) }.to raise_error('All but one formatter must use --out, only one can print to each stream (or STDOUT)')
end
it 'merges profile formatters and command line formatters' do
given_cucumber_yml_defined_as('default' => '-f junit -o result.xml')
options.parse!(%w[-f pretty])
expect(options[:formats]).to eq [['pretty', {}, output_stream], ['junit', {}, 'result.xml']]
end
end
context 'when using -t TAGS or --tags TAGS' do
it 'handles tag expressions as argument' do
after_parsing(['--tags', 'not @foo or @bar']) do
expect(options[:tag_expressions]).to eq(['not @foo or @bar'])
end
end
it 'stores tags passed with different --tags separately' do
after_parsing('--tags @foo --tags @bar') do
expect(options[:tag_expressions]).to eq(['@foo', '@bar'])
end
end
it 'strips tag limits from the tag expressions stored' do
after_parsing(['--tags', 'not @foo:2 or @bar:3']) do
expect(options[:tag_expressions]).to eq(['not @foo or @bar'])
end
end
it 'stores tag limits separately' do
after_parsing(['--tags', 'not @foo:2 or @bar:3']) do
expect(options[:tag_limits]).to eq({ '@foo' => 2, '@bar' => 3 })
end
end
it 'raise exception for inconsistent tag limits' do
expect { after_parsing('--tags @foo:2 --tags @foo:3') }.to raise_error(RuntimeError, 'Inconsistent tag limits for @foo: 2 and 3')
end
end
context 'when using -n NAME or --name NAME' do
it 'stores the provided names as regular expressions' do
after_parsing('-n foo --name bar') do
expect(options[:name_regexps]).to eq([/foo/, /bar/])
end
end
end
context 'when using -e PATTERN or --exclude PATTERN' do
it 'stores the provided exclusions as regular expressions' do
after_parsing('-e foo --exclude bar') do
expect(options[:excludes]).to eq([/foo/, /bar/])
end
end
end
context 'when using -l LINES or --lines LINES' do
it 'adds line numbers to args' do
options.parse!(%w[-l24 FILE])
expect(options.instance_variable_get(:@args)).to eq(['FILE:24'])
end
end
context 'when using -p PROFILE or --profile PROFILE' do
it 'uses the default profile passed in during initialization if none are specified by the user' do
given_cucumber_yml_defined_as('default' => '--require some_file')
options = described_class.new(output_stream, error_stream, default_profile: 'default')
options.parse!(%w[--format progress])
expect(options[:require]).to include('some_file')
end
it 'merges all uniq values from both cmd line and the profile' do
given_cucumber_yml_defined_as('foo' => %w[--verbose])
options.parse!(%w[--wip --profile foo])
expect(options[:wip]).to be true
expect(options[:verbose]).to be true
end
it "gives precedence to the original options' paths" do
given_cucumber_yml_defined_as('foo' => %w[features])
options.parse!(%w[my.feature -p foo])
expect(options[:paths]).to eq(%w[my.feature])
end
it 'combines the require files of both' do
given_cucumber_yml_defined_as('bar' => %w[--require features -r dog.rb])
options.parse!(%w[--require foo.rb -p bar])
expect(options[:require]).to eq(%w[foo.rb features dog.rb])
end
it 'combines the tag names of both' do
given_cucumber_yml_defined_as('baz' => %w[-t @bar])
options.parse!(%w[--tags @foo -p baz])
expect(options[:tag_expressions]).to eq(['@foo', '@bar'])
end
it 'combines the tag limits of both' do
given_cucumber_yml_defined_as('baz' => %w[-t @bar:2])
options.parse!(%w[--tags @foo:3 -p baz])
expect(options[:tag_limits]).to eq({ '@foo' => 3, '@bar' => 2 })
end
it 'raise exceptions for inconsistent tag limits' do
given_cucumber_yml_defined_as('baz' => %w[-t @bar:2])
expect { options.parse!(%w[--tags @bar:3 -p baz]) }.to raise_error(RuntimeError, 'Inconsistent tag limits for @bar: 3 and 2')
end
it 'only takes the paths from the original options, and disgregards the profiles' do
given_cucumber_yml_defined_as('baz' => %w[features])
options.parse!(%w[my.feature -p baz])
expect(options[:paths]).to eq(['my.feature'])
end
it 'uses the paths from the profile when none are specified originally' do
given_cucumber_yml_defined_as('baz' => %w[some.feature])
options.parse!(%w[-p baz])
expect(options[:paths]).to eq(['some.feature'])
end
it 'combines environment variables from the profile but gives precendene to cmd line args' do
given_cucumber_yml_defined_as('baz' => %w[FOO=bar CHEESE=swiss])
options.parse!(%w[-p baz CHEESE=cheddar BAR=foo])
expect(options[:env_vars]).to eq('BAR' => 'foo', 'FOO' => 'bar', 'CHEESE' => 'cheddar')
end
it 'disregards STDOUT formatter defined in profile when another is passed in (via cmd line)' do
given_cucumber_yml_defined_as('foo' => %w[--format pretty])
options.parse!(%w[--format progress --profile foo])
expect(options[:formats]).to eq([['progress', {}, output_stream]])
end
it 'includes any non-STDOUT formatters from the profile' do
given_cucumber_yml_defined_as('json' => %w[--format json -o features.json])
options.parse!(%w[--format progress --profile json])
expect(options[:formats]).to eq([['progress', {}, output_stream], ['json', {}, 'features.json']])
end
it 'does not include STDOUT formatters from the profile if there is a STDOUT formatter in command line' do
given_cucumber_yml_defined_as('json' => %w[--format json -o features.json --format pretty])
options.parse!(%w[--format progress --profile json])
expect(options[:formats]).to eq([['progress', {}, output_stream], ['json', {}, 'features.json']])
end
it 'includes any STDOUT formatters from the profile if no STDOUT formatter was specified in command line' do
given_cucumber_yml_defined_as('json' => %w[--format json])
options.parse!(%w[--format rerun -o rerun.txt --profile json])
expect(options[:formats]).to eq([['json', {}, output_stream], ['rerun', {}, 'rerun.txt']])
end
it 'assumes all of the formatters defined in the profile when none are specified on cmd line' do
given_cucumber_yml_defined_as('json' => %w[--format progress --format json -o features.json])
options.parse!(%w[--profile json])
expect(options[:formats]).to eq([['progress', {}, output_stream], ['json', {}, 'features.json']])
end
it 'only reads cucumber.yml once' do
original_parse_count = $cucumber_yml_read_count
$cucumber_yml_read_count = 0
begin
given_cucumber_yml_defined_as(<<-YML
<% $cucumber_yml_read_count += 1 %>
default: --format pretty
YML
)
options = described_class.new(output_stream, error_stream, default_profile: 'default')
options.parse!(%w[-f progress])
expect($cucumber_yml_read_count).to eq 1
ensure
$cucumber_yml_read_count = original_parse_count
end
end
it 'respects --quiet when defined in the profile' do
given_cucumber_yml_defined_as('foo' => '-q')
options.parse!(%w[-p foo])
expect(options[:publish_quiet]).to be true
end
it 'uses --no-duration when defined in the profile' do
given_cucumber_yml_defined_as('foo' => '--no-duration')
options.parse!(%w[-p foo])
expect(options[:duration]).to be false
end
context 'with --retry' do
context 'when --retry is not defined on the command line' do
it 'uses the --retry option from the profile' do
given_cucumber_yml_defined_as('foo' => '--retry 2')
options.parse!(%w[-p foo])
expect(options[:retry]).to eq(2)
end
end
context 'when --retry is defined on the command line' do
it 'ignores the --retry option from the profile' do
given_cucumber_yml_defined_as('foo' => '--retry 2')
options.parse!(%w[--retry 1 -p foo])
expect(options[:retry]).to eq(1)
end
end
end
context 'with --retry-total' do
context 'when --retry-total is not defined on the command line' do
it 'uses the --retry-total option from the profile' do
given_cucumber_yml_defined_as('foo' => '--retry-total 2')
options.parse!(%w[-p foo])
expect(options[:retry_total]).to eq(2)
end
end
context 'when --retry-total is defined on the command line' do
it 'ignores the --retry-total option from the profile' do
given_cucumber_yml_defined_as('foo' => '--retry-total 2')
options.parse!(%w[--retry-total 1 -p foo])
expect(options[:retry_total]).to eq(1)
end
end
end
end
context 'when using -P or --no-profile' do
it 'disables profiles' do
given_cucumber_yml_defined_as('default' => '-v --require file_specified_in_default_profile.rb')
after_parsing('-P --require some_file.rb') do
expect(options[:require]).to eq(['some_file.rb'])
end
end
it 'notifies the user that the profiles are being disabled' do
given_cucumber_yml_defined_as('default' => '-v')
after_parsing('--no-profile --require some_file.rb') do
expect(output_stream.string).to match(/Disabling profiles.../)
end
end
end
context 'when using -b or --backtrace' do
it "turns on cucumber's full backtrace" do
when_parsing('-b') do
expect(Cucumber).to receive(:use_full_backtrace=).with(true)
end
end
end
context 'with --version' do
it "displays the cucumber version" do
after_parsing('--version') do
expect(output_stream.string).to match(/#{Cucumber::VERSION}/)
end
end
it 'exits the program' do
when_parsing('--version') { expect(Kernel).to receive(:exit) }
end
end
context 'when using environment variables (i.e. MODE=webrat)' do
it 'places all of the environment variables into a hash' do
after_parsing('MODE=webrat FOO=bar') do
expect(options[:env_vars]).to eq('MODE' => 'webrat', 'FOO' => 'bar')
end
end
end
context 'with --retry' do
it 'is 0 by default' do
after_parsing('') do
expect(options[:retry]).to eq(0)
end
end
it 'sets the options[:retry] value' do
after_parsing('--retry 4') do
expect(options[:retry]).to eq(4)
end
end
end
context 'with --retry-total' do
it 'is INFINITY by default' do
after_parsing('') do
expect(options[:retry_total]).to eq(Float::INFINITY)
end
end
it 'sets the options[:retry_total] value' do
after_parsing('--retry-total 10') do
expect(options[:retry_total]).to eq(10)
end
end
end
it 'assigns any extra arguments as paths to features' do
after_parsing('-f pretty my_feature.feature my_other_features') do
expect(options[:paths]).to eq(['my_feature.feature', 'my_other_features'])
end
end
it 'does not mistake environment variables as feature paths' do
after_parsing('my_feature.feature FOO=bar') do
expect(options[:paths]).to eq(['my_feature.feature'])
end
end
context 'with --snippet-type' do
it 'parses the snippet type argument' do
after_parsing('--snippet-type classic') do
expect(options[:snippet_type]).to eq(:classic)
end
end
end
context 'with --publish' do
it 'adds message formatter with output to default reports publishing url' do
after_parsing('--publish') do
expect(@options[:formats]).to include(['message', {}, Cucumber::Cli::Options::CUCUMBER_PUBLISH_URL])
end
end
it 'adds message formatter with output to default reports publishing url when CUCUMBER_PUBLISH_ENABLED=true' do
with_env('CUCUMBER_PUBLISH_ENABLED', 'true') do
after_parsing('') do
expect(@options[:formats]).to include(['message', {}, Cucumber::Cli::Options::CUCUMBER_PUBLISH_URL])
end
end
end
it 'enables publishing when CUCUMBER_PUBLISH_ENABLED=true' do
with_env('CUCUMBER_PUBLISH_ENABLED', 'true') do
after_parsing('') do
expect(@options[:publish_enabled]).to be true
end
end
end
it 'does not enable publishing when CUCUMBER_PUBLISH_ENABLED=false' do
with_env('CUCUMBER_PUBLISH_ENABLED', 'false') do
after_parsing('') do
expect(@options[:publish_enabled]).to be nil
end
end
end
it 'adds authentication header with CUCUMBER_PUBLISH_TOKEN environment variable value if set' do
with_env('CUCUMBER_PUBLISH_TOKEN', 'abcd1234') do
after_parsing('--publish') do
expect(@options[:formats]).to include(['message', {}, %(#{Cucumber::Cli::Options::CUCUMBER_PUBLISH_URL} -H "Authorization: Bearer abcd1234")])
end
end
end
it 'enables publishing if CUCUMBER_PUBLISH_TOKEN environment variable is set' do
with_env('CUCUMBER_PUBLISH_TOKEN', 'abcd1234') do
after_parsing('--publish') do
expect(@options[:publish_enabled]).to be true
end
end
end
it 'adds authentication header with CUCUMBER_PUBLISH_TOKEN environment variable value if set and no --publish' do
with_env('CUCUMBER_PUBLISH_TOKEN', 'abcd1234') do
after_parsing('') do
expect(@options[:formats]).to include(['message', {}, %(#{Cucumber::Cli::Options::CUCUMBER_PUBLISH_URL} -H "Authorization: Bearer abcd1234")])
end
end
end
end
context 'with --publish-quiet' do
it 'silences publish banner' do
after_parsing('--publish-quiet') do
expect(@options[:publish_quiet]).to be true
end
end
it 'enables publishing when CUCUMBER_PUBLISH_QUIET=true' do
with_env('CUCUMBER_PUBLISH_QUIET', 'true') do
after_parsing('') do
expect(@options[:publish_quiet]).to be true
end
end
end
end
end
describe 'dry-run' do
it 'has the default value for snippets' do
given_cucumber_yml_defined_as('foo' => %w[--dry-run])
options.parse!(%w[--dry-run])
expect(options[:snippets]).to be true
end
it 'sets snippets to false when no-snippets provided after dry-run' do
given_cucumber_yml_defined_as('foo' => %w[--dry-run --no-snippets])
options.parse!(%w[--dry-run --no-snippets])
expect(options[:snippets]).to be false
end
it 'sets snippets to false when no-snippets provided before dry-run' do
given_cucumber_yml_defined_as('foo' => %w[--no-snippet --dry-run])
options.parse!(%w[--no-snippets --dry-run])
expect(options[:snippets]).to be false
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/glue/snippet_spec.rb | spec/cucumber/glue/snippet_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/cucumber_expressions/parameter_type_registry'
require 'cucumber/cucumber_expressions/parameter_type'
require 'cucumber/cucumber_expressions/cucumber_expression_generator'
require 'cucumber/glue/snippet'
require 'cucumber/formatter/console'
module Cucumber
module Glue
describe Snippet do
include Cucumber::Formatter::Console
let(:code_keyword) { 'Given' }
let(:snippet) do
snippet_class.new(@cucumber_expression_generator, code_keyword, @step_text, @multiline_argument)
end
before do
@step_text = 'we have a missing step'
@multiline_argument = Core::Test::EmptyMultilineArgument.new
@registry = CucumberExpressions::ParameterTypeRegistry.new
@cucumber_expression_generator = CucumberExpressions::CucumberExpressionGenerator.new(@registry)
end
describe Snippet::Regexp do
let(:snippet_class) { described_class }
let(:snippet_text) { snippet.to_s }
it 'wraps snippet patterns in parentheses' do
@step_text = 'A "string" with 4 spaces'
cucumber_output = <<~CUKE.chomp
Given(/^A "([^"]*)" with (\\d+) spaces$/) do |arg1, arg2|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'recognises numbers in name and make according regexp' do
@step_text = 'Cloud 9 yeah'
cucumber_output = <<~CUKE.chomp
Given(/^Cloud (\\d+) yeah$/) do |arg1|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'recognises a mix of ints, strings and why not a table too' do
@step_text = 'I have 9 "awesome" cukes in 37 "boxes"'
@multiline_argument = Core::Test::DataTable.new([[]])
cucumber_output = <<~CUKE.chomp
Given(/^I have (\\d+) "([^"]*)" cukes in (\\d+) "([^"]*)"$/) do |arg1, arg2, arg3, arg4, table|
# table is a Cucumber::MultilineArgument::DataTable
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'recognises quotes in name and make according regexp' do
@step_text = 'A "first" arg'
cucumber_output = <<~CUKE.chomp
Given(/^A "([^"]*)" arg$/) do |arg1|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'recognises several quoted words in name and make according regexp and args' do
@step_text = 'A "first" and "second" arg'
cucumber_output = <<~CUKE.chomp
Given(/^A "([^"]*)" and "([^"]*)" arg$/) do |arg1, arg2|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'does not use quote group when there are no quotes' do
@step_text = 'A first arg'
cucumber_output = <<~CUKE.chomp
Given(/^A first arg$/) do
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'is helpful with tables' do
@step_text = 'A "first" arg'
@multiline_argument = Core::Test::DataTable.new([[]])
cucumber_output = <<~CUKE.chomp
Given(/^A "([^"]*)" arg$/) do |arg1, table|
# table is a Cucumber::MultilineArgument::DataTable
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
it 'is helpful with doc string' do
@step_text = 'A "first" arg'
@multiline_argument = MultilineArgument.from('', Core::Test::Location.new(''))
cucumber_output = <<~CUKE.chomp
Given(/^A "([^"]*)" arg$/) do |arg1, doc_string|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet_text).to eq(cucumber_output)
end
end
describe Snippet::Classic do
let(:snippet_class) { described_class }
it 'renders snippet as unwrapped regular expression' do
cucumber_output = <<~CUKE.chomp
Given /^we have a missing step$/ do
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet.to_s).to eq(cucumber_output)
end
end
describe Snippet::Percent do
let(:snippet_class) { described_class }
it 'renders snippet as percent-style regular expression' do
cucumber_output = <<~CUKE.chomp
Given %r{^we have a missing step$} do
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet.to_s).to eq(cucumber_output)
end
end
describe Snippet::CucumberExpression do
let(:snippet_class) { described_class }
it 'renders snippet as cucumber expression' do
@step_text = 'I have 2.3 cukes in my belly'
@registry.define_parameter_type(CucumberExpressions::ParameterType.new(
'veg',
/(cuke|banana)s?/,
Object,
->(s) { s },
true,
false
))
@registry.define_parameter_type(CucumberExpressions::ParameterType.new(
'cucumis',
/(bella|cuke)s?/,
Object,
->(s) { s },
true,
false
))
cucumber_output = <<~CUKE.chomp
Given('I have {float} {cucumis} in my belly') do |float, cucumis|
# Given('I have {float} {veg} in my belly') do |float, veg|
pending # Write code here that turns the phrase above into concrete actions
end
CUKE
expect(snippet.to_s).to eq(cucumber_output)
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/glue/step_definition_spec.rb | spec/cucumber/glue/step_definition_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/glue/registry_and_more'
require 'support/fake_objects'
module Cucumber
module Glue
describe StepDefinition do
let(:id) { double }
let(:user_interface) { double('user interface') }
let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
let(:registry) { support_code.registry }
let(:test_case) { double('scenario', language: 'en').as_null_object }
let(:dsl) do
registry
Object.new.extend(Cucumber::Glue::Dsl)
end
before do
registry.begin_scenario(test_case)
@@inside = nil
end
def run_step(text)
step_match(text).invoke(MultilineArgument::None.new)
end
def step_match(text)
StepMatchSearch.new(registry.method(:step_matches), Configuration.default).call(text).first
end
it 'allows calling of other steps' do
dsl.Given('Outside') { step 'Inside' }
dsl.Given('Inside') { @@inside = true }
run_step 'Outside'
expect(@@inside).to be true
end
it 'allows calling of other steps with inline arg' do
dsl.Given('Outside') { step 'Inside', table([['inside']]) }
dsl.Given('Inside') { |t| @@inside = t.raw[0][0] }
run_step 'Outside'
expect(@@inside).to eq('inside')
end
context 'when mapping to world methods' do
before do
# TODO: LH -> Remove this skip pragma in 2026 as they should be fully fixed and released by then
skip('These tests are problematic on truffleruby. See: https://github.com/oracle/truffleruby/issues/3870') if RUBY_ENGINE.start_with?('truffleruby')
end
it 'calls a method on the world when specified with a symbol' do
expect(registry.current_world).to receive(:with_symbol)
dsl.Given(/With symbol/, :with_symbol)
run_step 'With symbol'
end
it 'calls a method on a specified object' do
target = double('target')
allow(registry.current_world).to receive(:target) { target }
dsl.Given(/With symbol on block/, :with_symbol, on: -> { target })
expect(target).to receive(:with_symbol)
run_step 'With symbol on block'
end
it 'calls a method on a specified world attribute' do
target = double('target')
allow(registry.current_world).to receive(:target) { target }
dsl.Given(/With symbol on symbol/, :with_symbol, on: :target)
expect(target).to receive(:with_symbol)
run_step 'With symbol on symbol'
end
it 'has the correct location' do
dsl.Given('With symbol', :with_symbol)
expect(step_match('With symbol').file_colon_line).to eq("spec/cucumber/glue/step_definition_spec.rb:#{__LINE__ - 2}")
end
end
it 'raises UndefinedDynamicStep when inside step is not defined' do
dsl.Given('Outside') { step 'Inside' }
expect { run_step 'Outside' }.to raise_error(Cucumber::UndefinedDynamicStep)
end
it 'raises UndefinedDynamicStep when an undefined step is parsed dynamically' do
dsl.Given(/Outside/) do
steps %(
Given Inside
)
end
expect { run_step 'Outside' }.to raise_error(Cucumber::UndefinedDynamicStep)
end
it 'raises UndefinedDynamicStep when an undefined step with doc string is parsed dynamically' do
dsl.Given(/Outside/) do
steps %(
Given Inside
"""
abc
"""
)
end
expect { run_step 'Outside' }.to raise_error(Cucumber::UndefinedDynamicStep)
end
it 'raises UndefinedDynamicStep when an undefined step with data table is parsed dynamically' do
dsl.Given(/Outside/) do
steps %(
Given Inside
| a |
| 1 |
)
end
expect { run_step 'Outside' }.to raise_error(Cucumber::UndefinedDynamicStep)
end
it 'allows forced pending' do
dsl.Given('Outside') { pending('Do me!') }
expect { run_step 'Outside' }.to raise_error(Cucumber::Pending, 'Do me!')
end
it 'raises ArityMismatchError when the number of capture groups differs from the number of step arguments' do
dsl.Given(/No group: \w+/) { |_arg| }
expect { run_step 'No group: arg' }.to raise_error(Cucumber::Glue::ArityMismatchError)
end
it 'does not modify the step_match arg when arg is modified in a step' do
dsl.Given(/My car is (.*)/) do |colour|
colour << 'xxx'
end
step_name = 'My car is white'
step_args = step_match(step_name).args
expect { run_step step_name }.not_to(change { step_args.first })
end
context 'with ParameterType' do
before(:each) do
@actor = nil
dsl.ParameterType(
name: 'actor',
regexp: /[A-Z]{1}[a-z]+/,
transformer: ->(name) { @actor = FakeObjects::Actor.new(name) }
)
end
it 'uses the instance created by the ParameterType transformer proc' do
dsl.Given 'capture this: {actor}' do |arg|
expect(arg.name).to eq('Anjie')
expect(arg).to eq(@actor)
end
run_step 'capture this: Anjie'
end
it 'does not modify the step_match arg when arg is modified in a step' do
dsl.Given 'capture this: {actor}' do |actor|
actor.name = 'Dave'
end
run_step 'capture this: Anjie'
step_args = step_match('capture this: Anjie').args
expect(step_args[0].name).not_to eq('Dave')
expect(step_args[0].name).to eq('Anjie')
end
end
describe '#log' do
it 'calls "attach" with the correct media type' do
expect(user_interface).to receive(:attach).with('wasup', 'text/x.cucumber.log+plain', nil)
dsl.Given('Loud') { log 'wasup' }
run_step 'Loud'
end
it 'calls `to_s` if the message is not a String' do
expect(user_interface).to receive(:attach).with('["Not", 1, "string"]', 'text/x.cucumber.log+plain', nil)
dsl.Given('Loud') { log ['Not', 1, 'string'] }
run_step 'Loud'
end
end
it 'recognizes $arg style captures' do
dsl.Given('capture this: {word}') do |arg|
expect(arg).to eq('up')
end
run_step 'capture this: up'
end
it 'has a JSON representation of the signature' do
expect(described_class.new(id, registry, /I CAN HAZ (\d+) CUKES/i, -> {}, {}).to_hash).to eq(
source: { type: 'regular expression', expression: 'I CAN HAZ (\\d+) CUKES' },
regexp: { source: 'I CAN HAZ (\\d+) CUKES', flags: 'i' }
)
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/glue/proto_world_spec.rb | spec/cucumber/glue/proto_world_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/formatter/spec_helper'
require 'cucumber/formatter/pretty'
require 'cucumber/formatter/message'
module Cucumber
module Glue
describe ProtoWorld do
let(:runtime) { double('runtime') }
let(:language) { double('language') }
let(:world) { Object.new.extend(described_class.for(runtime, language)) }
describe '#table' do
it 'produces Ast::Table by #table' do
expect(world.table(%(
| account | description | amount |
| INT-100 | Taxi | 114 |
| CUC-101 | Peeler | 22 |
))).to be_kind_of(MultilineArgument::DataTable)
end
end
describe 'Handling logs in step definitions' do
extend Cucumber::Formatter::SpecHelperDsl
include Cucumber::Formatter::SpecHelper
before(:each) do
Cucumber::Term::ANSIColor.coloring = false
@out = StringIO.new
@formatter = Cucumber::Formatter::Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: false))
run_defined_feature
end
describe 'when modifying the printed variable after the call to #log' do
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
When log is called twice for the same variable
FEATURE
define_steps do
When('log is called twice for the same variable') do
foo = String.new('a')
log foo
foo.upcase!
log foo
end
end
it 'prints the variable value at the time `#log` was called' do
expect(@out.string).to include <<~OUTPUT
When log is called twice for the same variable
a
A
OUTPUT
end
end
describe 'when logging an object' do
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
When an object is logged
FEATURE
define_steps do
When('an object is logged') do
object = Object.new
def object.to_s
'<test-object>'
end
log(object)
end
end
it 'prints the stringified version of the object as a log message' do
expect(@out.string).to include('<test-object>')
end
end
describe 'when logging multiple items on one call' do
define_feature <<~FEATURE
Feature: Logging multiple entries
Scenario: Logging multiple entries
When logging multiple entries
FEATURE
define_steps do
When('logging multiple entries') do
log 'entry one', 'entry two', 'entry three'
end
end
it 'logs each entry independently' do
expect(@out.string).to include([
' entry one',
' entry two',
' entry three'
].join("\n"))
end
end
end
describe 'Handling attachments in step definitions' do
extend Cucumber::Formatter::SpecHelperDsl
include Cucumber::Formatter::SpecHelper
before do
Cucumber::Term::ANSIColor.coloring = false
@out = StringIO.new
@formatter = Cucumber::Formatter::Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: false))
run_defined_feature
end
context 'when attaching data with null byte' do
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
When some data is attached
FEATURE
define_steps do
When('some data is attached') do
attach("'\x00'attachment", 'text/x.cucumber.log+plain')
end
end
it 'does not report an error' do
expect(@out.string).not_to include('Error')
end
it 'properly attaches the data' do
expect(@out.string).to include("'\x00'attachment")
end
end
context 'when attaching a image using a file path' do
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
When some data is attached
FEATURE
define_steps do
When('some data is attached') do
path = "#{Dir.pwd}/docs/img/cucumber-open-logo.png"
attach(path, 'image/png')
end
end
it 'does not report an error' do
expect(@out.string).not_to include('Error')
end
it 'properly attaches the image' do
pending 'This is correct currently with the pretty implementation'
expect(@out.string).to include("'\x00'attachment")
end
end
context 'when attaching a image using the input-read data' do
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
When some data is attached
FEATURE
define_steps do
When('some data is attached') do
path = "#{Dir.pwd}/docs/img/cucumber-open-logo.png"
image_data = File.read(path, mode: 'rb')
attach(image_data, 'base64;image/png')
end
end
it 'does not report an error' do
expect(@out.string).not_to include('Error')
end
it 'properly attaches the image' do
pending 'This is correct currently with the pretty implementation'
expect(@out.string).to include("'\x00'attachment")
end
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/spec/cucumber/glue/registry_and_more_spec.rb | spec/cucumber/glue/registry_and_more_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'cucumber/glue/registry_and_more'
require 'support/fake_objects'
module Cucumber
module Glue
describe StepDefinition do
let(:user_interface) { double('user interface') }
let(:registry) { support_code.registry }
let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
let(:dsl) do
registry
Object.new.extend(Glue::Dsl)
end
describe '#load_code_file' do
after(:each) do
FileUtils.rm_rf('tmp1.rb')
FileUtils.rm_rf('tmp2.rb')
FileUtils.rm_rf('tmp3.rb')
FileUtils.rm_rf('docs1.md')
FileUtils.rm_rf('docs2.md')
FileUtils.rm_rf('docs3.md')
end
let(:value1) do
<<~STRING
class Foo
def self.value; 1; end
end
STRING
end
let(:value2) do
<<~STRING
class Foo
def self.value; 2; end
end
STRING
end
let(:value3) do
<<~STRING
class Foo
def self.value; 3; end
end
STRING
end
def a_file_called(name)
File.open(name, 'w') do |f|
f.puts yield
end
end
context 'when not specifying the loading strategy' do
it 'does not re-load the file when called multiple times' do
a_file_called('tmp1.rb') { value1 }
registry.load_code_file('tmp1.rb')
a_file_called('tmp1.rb') { value2 }
registry.load_code_file('tmp1.rb')
expect(Foo.value).to eq(1)
end
it 'only loads ruby files' do
a_file_called('tmp1.rb') { value1 }
a_file_called('docs1.md') { value3 }
registry.load_code_file('tmp1.rb')
registry.load_code_file('docs1.md')
expect(Foo.value).not_to eq(3)
end
end
context 'when using `use_legacy_autoloader`' do
before(:each) { allow(Cucumber).to receive(:use_legacy_autoloader).and_return(true) }
it 're-loads the file when called multiple times' do
a_file_called('tmp2.rb') { value1 }
registry.load_code_file('tmp2.rb')
a_file_called('tmp2.rb') { value2 }
registry.load_code_file('tmp2.rb')
expect(Foo.value).to eq(2)
end
it 'only loads ruby files' do
a_file_called('tmp2.rb') { value1 }
a_file_called('docs2.md') { value3 }
registry.load_code_file('tmp2.rb')
registry.load_code_file('docs2.md')
expect(Foo.value).not_to eq(3)
end
end
context 'when explicitly NOT using `use_legacy_autoloader`' do
before(:each) { allow(Cucumber).to receive(:use_legacy_autoloader).and_return(false) }
after(:each) { FileUtils.rm_rf('tmp3.rb') }
it 'does not re-load the file when called multiple times' do
a_file_called('tmp3.rb') { value1 }
registry.load_code_file('tmp3.rb')
a_file_called('tmp3.rb') { value2 }
registry.load_code_file('tmp3.rb')
expect(Foo.value).to eq(1)
end
it 'only loads ruby files' do
a_file_called('tmp3.rb') { value1 }
a_file_called('docs3.md') { value3 }
registry.load_code_file('tmp3.rb')
registry.load_code_file('docs3.md')
expect(Foo.value).not_to eq(3)
end
end
end
describe 'Handling the World' do
it 'raises an error if the world is nil' do
dsl.World {}
expect { registry.begin_scenario(nil) }.to raise_error(Glue::NilWorld).with_message('World procs should never return nil')
end
it 'implicitly extends the world with modules' do
dsl.World(FakeObjects::ModuleOne, FakeObjects::ModuleTwo)
registry.begin_scenario(double('scenario').as_null_object)
class << registry.current_world
extend RSpec::Matchers
expect(included_modules).to include(FakeObjects::ModuleOne).and include(FakeObjects::ModuleTwo)
end
end
it 'places the current world inside the `Object` superclass' do
dsl.World(FakeObjects::ModuleOne, FakeObjects::ModuleTwo)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.class).to eq(Object)
end
it 'raises error when we try to register more than one World proc' do
dsl.World { {} }
expect { dsl.World { [] } }.to raise_error(Glue::MultipleWorld, /^You can only pass a proc to #World once/)
end
end
describe 'Handling namespaced World' do
it 'can still handle top level methods inside the world the world with namespaces' do
dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world).to respond_to(:method_one)
end
it 'can scope calls to a specific namespaced module' do
dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.module_two).to respond_to(:method_two)
end
it 'can scope calls to a different specific namespaced module' do
dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.module_three).to respond_to(:method_three)
end
it 'can show all the namespaced included modules' do
dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.inspect).to include('ModuleTwo (as module_two)').and include('ModuleThree (as module_three)')
end
it 'merges methods when assigning different modules to the same namespace' do
dsl.World(namespace: FakeObjects::ModuleOne)
dsl.World(namespace: FakeObjects::ModuleTwo)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.namespace).to respond_to(:method_one).and respond_to(:method_two)
end
it 'resolves conflicts by using the latest defined definition when assigning different modules to the same namespace' do
dsl.World(namespace: FakeObjects::ModuleOne)
dsl.World(namespace: FakeObjects::ModuleTwo)
registry.begin_scenario(double('scenario').as_null_object)
expect(registry.current_world.namespace.method_one).to eq(2)
end
end
describe 'hooks' do
it 'finds before hooks' do
fish = dsl.Before('@fish') {}
meat = dsl.Before('@meat') {}
scenario = double('Scenario')
allow(scenario).to receive(:accept_hook?).with(fish).and_return(true)
allow(scenario).to receive(:accept_hook?).with(meat).and_return(false)
expect(registry.hooks_for(:before, scenario)).to eq([fish])
end
it 'finds around hooks' do
a = dsl.Around {}
b = dsl.Around('@tag') {}
scenario = double('Scenario')
allow(scenario).to receive(:accept_hook?).with(a).and_return(true)
allow(scenario).to receive(:accept_hook?).with(b).and_return(false)
expect(registry.hooks_for(:around, scenario)).to eq([a])
end
end
end
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/de/features/step_definitions/calculator_steps.rb | examples/i18n/de/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Angenommen(/ich habe (\d+) in den Taschenrechner eingegeben/) do |n|
@calc.push n.to_i
end
Wenn(/ich (\w+) drücke/) do |op|
@result = @calc.send op
end
Dann(/sollte das Ergebniss auf dem Bildschirm (.*) sein/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/de/lib/calculator.rb | examples/i18n/de/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sk/features/step_definitions/calculator_steps.rb | examples/i18n/sk/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/Zadám číslo (\d+) do kalkulačky/) do |n|
@calc.push n.to_i
end
When(/Stlačím tlačidlo (\w+)/) do |op|
@result = @calc.send op
end
Then(/Výsledok by mal byť (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sk/lib/calculator.rb | examples/i18n/sk/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uz/features/support/world.rb | examples/i18n/uz/features/support/world.rb | # frozen_string_literal: true
module LazyCalc
def calc
@calc ||= Calculator.new
end
end
World(LazyCalc)
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uz/features/support/env.rb | examples/i18n/uz/features/support/env.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uz/features/step_definitions/calculator_steps.rb | examples/i18n/uz/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Агар('{int} сонини киритсам') do |сон|
calc.push сон
end
Агар('ундан сунг {int} сонини киритсам') do |сон|
calc.push сон
end
Агар('ман {int} сонини киритсам') do |сон|
calc.push сон
end
Агар('{word} боссам') do |операция|
calc.send операция
end
Агар('{int} ва {int} сонини кушсам') do |сон1, сон2|
calc.push сон1.to_i
calc.push сон2.to_i
calc.send '+'
end
Унда('жавоб {int} сони булиши керак') do |жавоб|
expect(calc.result).to eq(жавоб)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uz/lib/calculator.rb | examples/i18n/uz/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def result
@stack.last
end
def +
number1 = @stack.pop
number2 = @stack.pop
@stack.push(number1 + number2)
end
def /
divisor = @stack.pop
dividend = @stack.pop
@stack.push(dividend / divisor)
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/fi/features/step_definitions/laskin_steps.rb | examples/i18n/fi/features/step_definitions/laskin_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'laskin'
Before do
@laskin = Laskin.new
end
After do
end
Given(/että olen syöttänyt laskimeen luvun (\d+)/) do |n|
@laskin.pinoa n.to_i
end
When(/painan "(\w+)"/) do |op|
@tulos = @laskin.send op
end
Then(/laskimen ruudulla pitäisi näkyä tulos (.*)/) do |tulos|
expect(@tulos).to eq(tulos.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/fi/lib/laskin.rb | examples/i18n/fi/lib/laskin.rb | # frozen_string_literal: true
class Laskin
def initialize
@stack = []
end
def pinoa(arg)
@stack.push(arg)
end
def summaa
@stack.inject(0) { |n, sum| sum + n }
end
def jaa
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb | examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'hesap_makinesi'
Before do
@calc = HesapMakinesi.new
end
After do
end
Diyelimki(/hesap makinesine (\d+) girdim/) do |n|
@calc.push n.to_i
end
Eğerki(/(.*) tuşuna basarsam/) do |op|
@result = @calc.send op
end
Ozaman(/ekrandaki sonuç (.*) olmalı/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/tr/lib/hesap_makinesi.rb | examples/i18n/tr/lib/hesap_makinesi.rb | # frozen_string_literal: true
class HesapMakinesi
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def topla
@stack.inject(0) { |n, sum| sum + n }
end
def böl
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/he/features/step_definitions/calculator_steps.rb | examples/i18n/he/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/שהזנתי (\d+) למחשבון/) do |n|
@calc.push n.to_i
end
When(/אני לוחץ על (.+)/) do |op|
@result = @calc.send op
end
Then(/התוצאה על המסך צריכה להיות (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/he/lib/calculator.rb | examples/i18n/he/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def חבר
@stack.inject(0) { |n, sum| sum + n }
end
def חלק
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uk/features/support/world.rb | examples/i18n/uk/features/support/world.rb | # frozen_string_literal: true
module LazyCalc
def calc
@calc ||= Calculator.new
end
end
World(LazyCalc)
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uk/features/support/env.rb | examples/i18n/uk/features/support/env.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uk/features/step_definitions/calculator_steps.rb | examples/i18n/uk/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Припустимо('потім/я ввожу число {int}') do |число|
calc.push число
end
Якщо('я натискаю {string}') do |операція|
calc.send операція
end
То('результатом повинно бути число {float}') do |результат|
expect(calc.result).to eq(результат)
end
Припустимо('я додав {int} і {int}') do |число1, число2|
calc.push число1
calc.push число2
calc.send '+'
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/uk/lib/calculator.rb | examples/i18n/uk/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def result
@stack.last
end
def +
number1 = @stack.pop
number2 = @stack.pop
@stack.push(number1 + number2)
end
def /
divisor = @stack.pop
dividend = @stack.pop
@stack.push(dividend / divisor)
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb | examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'kalkilatris'
Before do
@kalk = Kalkilatris.new
end
Sipoze('mwen te antre {int} nan kalkilatris la') do |int|
@kalk.push int
end
Lè('mwen peze {word}') do |op|
@result = @kalk.send op
end
Lè('sa a rezilta a ta dwe {float} sou ekran an') do |rezilta|
expect(@result).to eq(rezilta)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ht/lib/kalkilatris.rb | examples/i18n/ht/lib/kalkilatris.rb | # frozen_string_literal: true
class Kalkilatris
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def ajoute
@stack.inject(0) { |n, sum| sum + n }
end
def divize
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/bg/features/support/world.rb | examples/i18n/bg/features/support/world.rb | # frozen_string_literal: true
module LazyCalc
def calc
@calc ||= Calculator.new
end
end
World(LazyCalc)
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/bg/features/support/env.rb | examples/i18n/bg/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/bg/features/step_definitions/calculator_steps.rb | examples/i18n/bg/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Дадено('е че съм въвел {int}') do |int|
calc.push int
end
Дадено('съм въвел {int}') do |int|
calc.push int
end
Дадено('е че съм събрал {int} и {int}') do |int1, int2|
calc.push int1
calc.push int2
calc.send '+'
end
Когато('въведа {int}') do |int|
calc.push int
end
Когато('натисна {string}') do |op|
calc.send op
end
То('резултата трябва да е равен на {int}') do |int|
expect(calc.result).to eq(int)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/bg/lib/calculator.rb | examples/i18n/bg/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def result
@stack.last
end
def +
number1 = @stack.pop
number2 = @stack.pop
@stack.push(number1 + number2)
end
def /
divisor = @stack.pop
dividend = @stack.pop
@stack.push(dividend / divisor)
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/cs/features/step_definitions/calculator_steps.rb | examples/i18n/cs/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
Pokud('Zadám číslo {int} do kalkulačky') do |int|
@calc.push int
end
Když('stisknu {word}') do |op|
@result = @calc.send op
end
Pak('výsledek by měl být {float}') do |float|
expect(@result).to eq(float)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/cs/lib/calculator.rb | examples/i18n/cs/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en/features/step_definitions/calculator_steps.rb | examples/i18n/en/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/I have entered (\d+) into the calculator/) do |n|
@calc.push n.to_i
end
When(/I press (\w+)/) do |op|
@result = @calc.send op
end
Then(/the result should be (.*) on the screen/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en/lib/calculator.rb | examples/i18n/en/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ja/features/support/env.rb | examples/i18n/ja/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ja/features/step_definitions/calculator_steps.rb | examples/i18n/ja/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Before do
@calc = Calculator.new
end
After do
end
前提('{int} を入力') do |int|
@calc.push int
end
もし(/(\w+) を押した/) do |op|
@result = @calc.send op
end
ならば(/(.*) を表示/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ja/lib/calculator.rb | examples/i18n/ja/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pl/features/support/env.rb | examples/i18n/pl/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pl/features/step_definitions/calculator_steps.rb | examples/i18n/pl/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Zakładając(/wprowadzenie do kalkulatora liczby (\d+)/) do |n|
@calc.push n.to_i
end
Jeżeli(/nacisnę (\w+)/) do |op|
@result = @calc.send op
end
Wtedy(/rezultat (.*) wyświetli się na ekranie/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pl/lib/calculator.rb | examples/i18n/pl/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def dodaj
@stack.inject(0) { |n, sum| sum + n }
end
def podziel
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ar/features/step_definitions/calculator_steps.rb | examples/i18n/ar/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given 'كتابة $n في الآلة الحاسبة' do |n|
@calc.push n.to_i
end
When(/يتم الضغط على (.+)/) do |op|
@result = @calc.send op
end
Then(/يظهر (.*) على الشاشة/) do |result|
expect(@result).to eq(result)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ar/lib/calculator.rb | examples/i18n/ar/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def جمع
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/fr/features/support/env.rb | examples/i18n/fr/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculatrice'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb | examples/i18n/fr/features/step_definitions/calculatrice_steps.rb | # frozen_string_literal: true
Soit(/^une calculatrice$/) do
@calc = Calculatrice.new
end
Etantdonnéqu('on tape {int}') do |entier|
@calc.push entier
end
Soit("j'entre {int} pour le premier/second nombre") do |entier|
@calc.push entier
end
Soit('je tape sur la touche {string}') do |_touche|
@result = @calc.additionner
end
Lorsqu(/on tape additionner/) do
@result = @calc.additionner
end
Alors('le résultat affiché doit être {float}') do |resultat_attendu|
expect(@result).to eq(resultat_attendu)
end
Alors('le résultat doit être {float}') do |resultat_attendu|
expect(@result).to eq(resultat_attendu)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/fr/lib/calculatrice.rb | examples/i18n/fr/lib/calculatrice.rb | # frozen_string_literal: true
class Calculatrice
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def additionner
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pt/features/support/env.rb | examples/i18n/pt/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculadora'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pt/features/step_definitions/calculadora_steps.rb | examples/i18n/pt/features/step_definitions/calculadora_steps.rb | # frozen_string_literal: true
Before do
@calc = Calculadora.new
end
After do
end
Dado(/que eu digitei (\d+) na calculadora/) do |n|
@calc.push n.to_i
end
Quando('eu aperto o botão de soma') do
@result = @calc.soma
end
Então(/o resultado na calculadora deve ser (\d*)/) do |result|
expect(@result).to eq(result.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/pt/lib/calculadora.rb | examples/i18n/pt/lib/calculadora.rb | # frozen_string_literal: true
class Calculadora
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def soma
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb | examples/i18n/it/features/step_definitions/calcolatrice_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calcolatrice'
Before do
@calc = Calcolatrice.new
end
After do
end
Given(/che ho inserito (\d+)/) do |n|
@calc.push n.to_i
end
When('premo somma') do
@result = @calc.add
end
Then(/il risultato deve essere (\d*)/) do |result|
expect(@result).to eq(result.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/it/lib/calcolatrice.rb | examples/i18n/it/lib/calcolatrice.rb | # frozen_string_literal: true
class Calcolatrice
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/lt/features/step_definitions/calculator_steps.rb | examples/i18n/lt/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/aš įvedžiau (\d+) į skaičiuotuvą/) do |n|
@calc.push n.to_i
end
When(/aš paspaudžiu "(\w+)"/) do |op|
@result = @calc.send op
end
Then(/rezultatas ekrane turi būti (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/lt/lib/calculator.rb | examples/i18n/lt/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/hu/features/step_definitions/calculator_steps.rb | examples/i18n/hu/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Ha(/^beütök a számológépbe egy (\d+)-(?:es|as|ös|ás)t$/) do |n|
@calc.push n.to_i
end
Majd(/^megnyomom az? (\w+) gombot$/) do |op|
@result = @calc.send op
end
Akkor(/^eredményül (.*)-(?:e|a|ö|á|)t kell kapnom$/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/hu/lib/calculator.rb | examples/i18n/hu/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb | examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
Zadato('Unesen {int} broj u kalkulator') do |int|
@calc.push int
end
Kada('pritisnem {word}') do |op|
@result = @calc.send op
end
Onda('bi trebalo da bude {float} prikazano na ekranu') do |float|
expect(@result).to eq(float)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sr-Latn/lib/calculator.rb | examples/i18n/sr-Latn/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/el/features/step_definitions/calculator_steps.rb | examples/i18n/el/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Δεδομένου('ότι έχω εισάγει {int} στην αριθμομηχανή') do |int|
@calc.push int
end
Δεδομένου('έχω εισάγει {int} στην αριθμομηχανή') do |int|
@calc.push int
end
Όταν(/πατάω (\w+)/) do |op|
@result = @calc.send op
end
Τότε(/το αποτέλεσμα στην οθόνη πρέπει να είναι (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/el/lib/calculator.rb | examples/i18n/el/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ca/features/step_definitions/calculator_steps.rb | examples/i18n/ca/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculadora'
Before do
@calc = Calculadora.new
end
Donat(/que he introduït (\d+) a la calculadora/) do |n|
@calc.push n.to_i
end
Quan(/premo el (\w+)/) do |op|
@result = @calc.send op
end
Aleshores(/el resultat ha de ser (\d+) a la pantalla/) do |result|
expect(@result).to eq(result)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ca/lib/calculadora.rb | examples/i18n/ca/lib/calculadora.rb | # frozen_string_literal: true
class Calculadora
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/eo/features/step_definitions/calculator_steps.rb | examples/i18n/eo/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Se('mi entajpas {int} en la kalkulilon') do |int|
@calc.push int
end
Donitaĵo('mi premas/premis {word}') do |op|
@result = @calc.send op
end
Do('la rezulto estu {float}') do |float|
expect(@result).to eq(float)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/eo/lib/calculator.rb | examples/i18n/eo/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en-lol/features/support/env.rb | examples/i18n/en-lol/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'basket'
require 'belly'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb | examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb | # frozen_string_literal: true
ICANHAZ(/^IN TEH BEGINNIN (\d+) CUCUMBRZ$/) do |n|
@basket = Basket.new(n.to_i)
end
WEN(/^I EAT (\d+) CUCUMBRZ$/) do |n|
@belly = Belly.new
@belly.eat(@basket.take(n.to_i))
end
DEN(/^I HAS (\d+) CUCUMBERZ IN MAH BELLY$/) do |n|
expect(@belly.cukes).to eq(n.to_i)
end
DEN(/^IN TEH END (\d+) CUCUMBRZ KTHXBAI$/) do |n|
expect(@basket.cukes).to eq(n.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en-lol/lib/basket.rb | examples/i18n/en-lol/lib/basket.rb | # frozen_string_literal: true
class Basket
attr_reader :cukes
def initialize(cukes)
@cukes = cukes
end
def take(cukes)
@cukes -= cukes
cukes
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/en-lol/lib/belly.rb | examples/i18n/en-lol/lib/belly.rb | # frozen_string_literal: true
class Belly
attr_reader :cukes
def initialize
@cukes = 0
end
def eat(cukes)
@cukes += cukes
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ro/features/step_definitions/calculator_steps.rb | examples/i18n/ro/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Datfiind(/un calculator/) do
@calc = Calculator.new
end
Cand(/introduc (\d+)/) do |n|
@calc.push n.to_i
end
Cand('apăs tasta Egal') do
@result = @calc.add
end
Atunci(/ecranul trebuie să afişeze (\d*)/) do |result|
expect(@result).to eq(result.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ro/lib/calculator.rb | examples/i18n/ro/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ko/features/step_definitions/calculator_steps.rb | examples/i18n/ko/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/^계산기에 (.*)을 입력했음$/) do |n|
@calc.push n.to_i
end
When(/^내가 (.*)를 누르면$/) do |op|
@result = @calc.send op
end
Then(/^화면에 출력된 결과는 (.*)이다$/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ko/lib/calculator.rb | examples/i18n/ko/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/id/features/step_definitions/calculator_steps.rb | examples/i18n/id/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/aku sudah masukkan (\d+) ke kalkulator/) do |n|
@calc.push n.to_i
end
When(/aku tekan (\w+)/) do |op|
@result = @calc.send op
end
Then(/hasilnya harus (.*) di layar/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/id/lib/calculator.rb | examples/i18n/id/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/hi/features/step_definitions/calculator_steps.rb | examples/i18n/hi/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
ops = {
जोड़: 'add',
भाग: 'divide'
}
ParameterType(
name: 'op',
regexp: /#{ops.keys.join('|')}/,
transformer: ->(s) { ops[s.to_sym] }
)
अगर('मैं गणक में {int} डालता हूँ') do |int|
@calc.push int
end
जब('मैं {op} दबाता हूँ') do |op|
@result = @calc.send op
end
अगर('परिणाम {float} परदे पर प्रदशित होना चाहिए') do |float|
expect(@result).to eq(float)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/hi/lib/calculator.rb | examples/i18n/hi/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ru/features/support/world.rb | examples/i18n/ru/features/support/world.rb | # frozen_string_literal: true
module LazyCalc
def calc
@calc ||= Calculator.new
end
end
World(LazyCalc)
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ru/features/support/env.rb | examples/i18n/ru/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ru/features/step_definitions/calculator_steps.rb | examples/i18n/ru/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Допустим('я ввожу число {int}') do |число|
calc.push число
end
Допустим('затем ввожу число {int}') do |число|
calc.push число
end
Если('нажимаю {string}') do |операция|
calc.send операция
end
Если('я нажимаю {string}') do |операция|
calc.send операция
end
То('результатом должно быть число {float}') do |результат|
expect(calc.result).to eq(результат)
end
Допустим('я сложил {int} и {int}') do |слагаемое1, слагаемое2|
calc.push слагаемое1
calc.push слагаемое2
calc.send '+'
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/ru/lib/calculator.rb | examples/i18n/ru/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def result
@stack.last
end
def +
number1 = @stack.pop
number2 = @stack.pop
@stack.push(number1 + number2)
end
def /
divisor = @stack.pop
dividend = @stack.pop
@stack.push(dividend / divisor)
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/no/features/support/env.rb | examples/i18n/no/features/support/env.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'kalkulator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/no/features/step_definitions/kalkulator_steps.rb | examples/i18n/no/features/step_definitions/kalkulator_steps.rb | # frozen_string_literal: true
Before do
@calc = Kalkulator.new
end
Given(/at jeg har tastet inn (\d+)/) do |n|
@calc.push n.to_i
end
Når('jeg summerer') do
@result = @calc.add
end
Så(/skal resultatet være (\d*)/) do |result|
expect(@result).to eq(result.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/no/lib/kalkulator.rb | examples/i18n/no/lib/kalkulator.rb | # frozen_string_literal: true
class Kalkulator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb | examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/我已經在計算機上輸入 (\d+)/) do |n|
@calc.push n.to_i
end
When(/我按下 (\w+)/) do |op|
@result = @calc.send op
end
Then(/螢幕上應該顯示 (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/zh-TW/lib/calculator.rb | examples/i18n/zh-TW/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sr-Cyrl/features/support/env.rb | examples/i18n/sr-Cyrl/features/support/env.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sr-Cyrl/features/step_definitions/calculator_steps.rb | examples/i18n/sr-Cyrl/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
Before do
@calc = Calculator.new
end
After do
end
Задати(/унесен број (\d+) у калкулатор/) do |n|
@calc.push n.to_i
end
Када(/притиснем (\w+)/) do |op|
@result = @calc.send op
end
Онда('би требало да буде {float} прикаѕано на екрану') do |result|
expect(@result).to eq(result)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sr-Cyrl/lib/calculator.rb | examples/i18n/sr-Cyrl/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb | examples/i18n/sv/features/step_definitions/kalkulator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'kalkulator'
Before do
@calc = Kalkulator.new
end
After do
end
Given(/att jag har knappat in (\d+)/) do |n|
@calc.push n.to_i
end
When 'jag summerar' do
@result = @calc.add
end
Then(/ska resultatet vara (\d+)/) do |result|
expect(@result).to eq(result.to_i)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/sv/lib/kalkulator.rb | examples/i18n/sv/lib/kalkulator.rb | # frozen_string_literal: true
class Kalkulator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb | examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
ParameterType(
name: 'op',
regexp: /按相加按/,
transformer: ->(_s) { 'add' }
)
假如('我已经在计算器里输入{int}') do |n|
@calc.push n
end
当('我{op}钮') do |op|
@result = @calc.send op
end
那么('我应该在屏幕上看到的结果是{float}') do |result|
expect(@result).to eq(result)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/zh-CN/lib/calculator.rb | examples/i18n/zh-CN/lib/calculator.rb | # frozen_string_literal: true
class Calculator
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/es/features/step_definitions/calculador_steps.rb | examples/i18n/es/features/step_definitions/calculador_steps.rb | # frozen_string_literal: true
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculador'
Before do
@calc = Calculador.new
end
Dado(/que he introducido (\d+) en la calculadora/) do |n|
@calc.push n.to_i
end
Cuando(/oprimo el (\w+)/) do |op|
@result = @calc.send op
end
Entonces(/el resultado debe ser (.*) en la pantalla/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/es/lib/calculador.rb | examples/i18n/es/lib/calculador.rb | # frozen_string_literal: true
class Calculador
def initialize
@stack = []
end
def push(arg)
@stack.push(arg)
end
def add
@stack.inject(0) { |n, sum| sum + n }
end
def divide
@stack[0].to_f / @stack[1]
end
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
cucumber/cucumber-ruby | https://github.com/cucumber/cucumber-ruby/blob/50c37055b0e5e74de50a026756ca915f0f7b7820/examples/i18n/lv/features/step_definitions/calculator_steps.rb | examples/i18n/lv/features/step_definitions/calculator_steps.rb | # frozen_string_literal: true
begin
require 'rspec/expectations'
rescue LoadError
require 'spec/expectations'
end
require 'cucumber/formatter/unicode'
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
require 'calculator'
Before do
@calc = Calculator.new
end
After do
end
Given(/esmu ievadījis kalkulatorā (\d+)/) do |n|
@calc.push n.to_i
end
When(/nospiežu pogu (\w+)/) do |op|
@result = @calc.send op
end
Then(/rezultātam uz ekrāna ir jābūt (.*)/) do |result|
expect(@result).to eq(result.to_f)
end
| ruby | MIT | 50c37055b0e5e74de50a026756ca915f0f7b7820 | 2026-01-04T15:43:43.142161Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.