diff --git a/features/lib/step_definitions/aruba_steps.rb b/features/lib/step_definitions/aruba_steps.rb index 5c729bb401..eb336cb545 100644 --- a/features/lib/step_definitions/aruba_steps.rb +++ b/features/lib/step_definitions/aruba_steps.rb @@ -9,19 +9,19 @@ assert_success result == 'pass' end -Then(/^"([^"]*)" should not be required$/) do |file_name| +Then('{string} should not be required') do |file_name| expect(all_output).not_to include("* #{file_name}") end -Then(/^"([^"]*)" should be required$/) do |file_name| +Then('{string} should be required') do |file_name| expect(all_output).to include("* #{file_name}") end -Then(/^it fails before running features with:$/) do |expected| +Then('it fails before running features with:') do |expected| assert_matching_output("\\A#{expected}", all_output) assert_success(false) end -Then(/^the output includes the message "(.*)"$/) do |message| +Then('the output includes the message {string}') do |message| expect(all_output).to include(message) end diff --git a/features/lib/step_definitions/cli_steps.rb b/features/lib/step_definitions/cli_steps.rb index 0975b90551..0a6436bfa4 100644 --- a/features/lib/step_definitions/cli_steps.rb +++ b/features/lib/step_definitions/cli_steps.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -Then(/^I should see the CLI help$/) do +Then('I should see the CLI help') do expect(all_output).to include('Usage:') end diff --git a/features/lib/step_definitions/cucumber_steps.rb b/features/lib/step_definitions/cucumber_steps.rb index 02ecf92d93..d3a35e11f1 100644 --- a/features/lib/step_definitions/cucumber_steps.rb +++ b/features/lib/step_definitions/cucumber_steps.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -Given(/^a directory without standard Cucumber project directory structure$/) do +Given('a directory without standard Cucumber project directory structure') do in_current_dir do FileUtils.rm_rf 'features' if File.directory?('features') end end -Given(/^a scenario with a step that looks like this:$/) do |string| +Given('a scenario with a step that looks like this:') do |string| create_feature do create_scenario { string } end end -Given(/^a scenario with a step that looks like this in japanese:$/) do |string| +Given('a scenario with a step that looks like this in japanese:') do |string| create_feature_ja do create_scenario_ja { string } end end -Given(/^the standard step definitions$/) do +Given('the standard step definitions') do write_file 'features/step_definitions/steps.rb', <<-STEPS @@ -29,11 +29,11 @@ STEPS end -Given(/^a step definition that looks like this:$/) do |string| +Given('a step definition that looks like this:') do |string| create_step_definition { string } end -Given(/^a scenario "([^\"]*)" that passes$/) do |name| +Given('a scenario {string} that passes') do |name| write_file "features/#{name}.feature", <<-FEATURE Feature: #{name} @@ -47,7 +47,7 @@ STEPS end -Given(/^a scenario "([^\"]*)" that fails$/) do |name| +Given('a scenario {string} that fails') do |name| write_file "features/#{name}.feature", <<-FEATURE Feature: #{name} @@ -66,7 +66,7 @@ run_feature features.first, formatter end -Then(/^the stderr should contain a warning message$/) do +Then('the stderr should contain a warning message') do expect(all_stderr).to include('[warning]') end diff --git a/features/lib/step_definitions/junit_steps.rb b/features/lib/step_definitions/junit_steps.rb index a76a2d579f..550eaf5f56 100644 --- a/features/lib/step_definitions/junit_steps.rb +++ b/features/lib/step_definitions/junit_steps.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -Then(/^the junit output file "(.*?)" should contain:$/) do |actual_file, text| +Then('the junit output file {string} should contain:') do |actual_file, text| actual = IO.read(current_dir + '/' + actual_file) actual = replace_junit_time(actual) expect(actual).to eq text diff --git a/features/lib/step_definitions/language_steps.rb b/features/lib/step_definitions/language_steps.rb index 0ea73fd27f..8be800cc99 100644 --- a/features/lib/step_definitions/language_steps.rb +++ b/features/lib/step_definitions/language_steps.rb @@ -1,7 +1,7 @@ # encoding: utf-8 # frozen_string_literal: true -Then(/^cucumber lists all the supported languages$/) do +Then('cucumber lists all the supported languages') do sample_languages = %w(Arabic български Pirate English 日本語) sample_languages.each do |language| expect(all_output.force_encoding('utf-8')).to include(language) diff --git a/features/lib/step_definitions/profile_steps.rb b/features/lib/step_definitions/profile_steps.rb index 0b11e93bf1..dd9ebdde22 100644 --- a/features/lib/step_definitions/profile_steps.rb +++ b/features/lib/step_definitions/profile_steps.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -Given(/^the following profiles? (?:are|is) defined:$/) do |profiles| +Given('the following profile(s) are/is defined:') do |profiles| write_file 'cucumber.yml', profiles end -Then(/^the (.*) profile should be used$/) do |profile| +Then('the {word} profile should be used') do |profile| step 'the stdout should contain:', profile end -Then(/^exactly these files should be loaded:\s*(.*)$/) do |files| - expect(all_stdout.scan(/^ \* (.*\.rb)$/).flatten).to eq files.split(/,\s+/) +Then('exactly these files should be loaded: {list}') do |files| + expect(all_stdout.scan(/^ \* (.*\.rb)$/).flatten).to eq files end -Then(/^exactly these features should be run:\s*(.*)$/) do |files| - expect(all_stdout.scan(/^ \* (.*\.feature)$/).flatten).to eq files.split(/,\s+/) +Then('exactly these features should be run: {list}') do |files| + expect(all_stdout.scan(/^ \* (.*\.feature)$/).flatten).to eq files end diff --git a/features/lib/step_definitions/retry_steps.rb b/features/lib/step_definitions/retry_steps.rb index 0751d75955..da4a35359b 100644 --- a/features/lib/step_definitions/retry_steps.rb +++ b/features/lib/step_definitions/retry_steps.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -Given(/^a scenario "([^\"]*)" that fails once, then passes$/) do |full_name| +Given('a scenario {string} that fails once, then passes') do |full_name| name = snake_case(full_name) write_file "features/#{name}.feature", <<-FEATURE @@ -22,7 +22,7 @@ INIT end -Given(/^a scenario "([^\"]*)" that fails twice, then passes$/) do |full_name| +Given('a scenario {string} that fails twice, then passes') do |full_name| name = snake_case(full_name) write_file "features/#{name}.feature", <<-FEATURE diff --git a/features/lib/step_definitions/ruby_steps.rb b/features/lib/step_definitions/ruby_steps.rb index 685b2c34df..5f180502fa 100644 --- a/features/lib/step_definitions/ruby_steps.rb +++ b/features/lib/step_definitions/ruby_steps.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -When(/^I run the following Ruby code:$/) do |code| +When('I run the following Ruby code:') do |code| run_simple %{ruby -e "#{code}"} end diff --git a/features/lib/support/parameter_types.rb b/features/lib/support/parameter_types.rb new file mode 100644 index 0000000000..5c2f8dc0f5 --- /dev/null +++ b/features/lib/support/parameter_types.rb @@ -0,0 +1,8 @@ +ParameterType( + name: 'list', + regexp: /.*/, + type: Array, + transformer: ->(s) { s.split(/,\s+/)}, + use_for_snippets: false, + prefer_for_regexp_match: false +)