Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move deprecated cucumber steps into a separate file #622

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/aruba/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'aruba/cucumber/hooks'
require 'aruba/cucumber/command'
require 'aruba/cucumber/core'
require 'aruba/cucumber/deprecated'
require 'aruba/cucumber/environment'
require 'aruba/cucumber/file'
require 'aruba/cucumber/testing_frameworks'
Expand Down
36 changes: 0 additions & 36 deletions lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@
end
require 'aruba/generators/script_file'

When(/^I run "(.*)"$/)do |cmd|
warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})

cmd = sanitize_text(cmd)
run_command_and_stop(cmd, false)
end

When(/^I run `([^`]*)`$/)do |cmd|
cmd = sanitize_text(cmd)
run_command_and_stop(cmd, :fail_on_error => false)
end

When(/^I successfully run "(.*)"$/)do |cmd|
warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})

cmd = sanitize_text(cmd)
run_command_and_stop(cmd)
end

## I successfully run `echo -n "Hello"`
## I successfully run `sleep 29` for up to 30 seconds
When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, secs|
Expand All @@ -40,12 +26,6 @@
step 'I run `myscript`'
end

When(/^I run "([^"]*)" interactively$/) do |cmd|
Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})

step %(I run `#{cmd}` interactively)
end

When(/^I run `([^`]*)` interactively$/)do |cmd|
cmd = sanitize_text(cmd)
@interactive = run_command(cmd)
Expand Down Expand Up @@ -374,22 +354,6 @@
end
end

Given(/the default aruba timeout is (\d+) seconds/) do |seconds|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
# rubocop:enable Metrics/LineLength

aruba.config.exit_timeout = seconds.to_i
end

Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
# rubocop:enable Metrics/LineLength

aruba.config.exit_timeout = seconds.to_i
end

Given(/^the (?:default )?aruba io wait timeout is ([\d.]+) seconds?$/) do |seconds|
aruba.config.io_wait_timeout = seconds.to_f
end
Expand Down
93 changes: 93 additions & 0 deletions lib/aruba/cucumber/deprecated.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Before('@announce-cmd') do
Aruba.platform.deprecated 'The use of "@announce-cmd"-hook is deprecated. Please use "@announce-command"'

aruba.announcer.activate :command
end

Before('@announce-dir') do
Aruba.platform.deprecated 'The use of "@announce-dir"-hook is deprecated. Please use "@announce-directory"'

aruba.announcer.activate :directory
end

Before('@announce-env') do
Aruba.platform.deprecated 'The use of "@announce-env"-hook is deprecated. Please use "@announce-changed-environment"'

aruba.announcer.activate :environment
end

Before('@announce-environment') do
Aruba.platform.deprecated '@announce-environment is deprecated. Use @announce-changed-environment instead'

aruba.announcer.activate :changed_environment
end

Before('@announce-modified-environment') do
Aruba.platform.deprecated '@announce-modified-environment is deprecated. Use @announce-changed-environment instead'

aruba.announcer.activate :changed_environment
end

Before('@ansi') do
# rubocop:disable Metrics/LineLength
Aruba::Platform.deprecated('The use of "@ansi" is deprecated. Use "@keep-ansi-escape-sequences" instead. But be aware, that this hook uses the aruba configuration and not an instance variable')
# rubocop:enable Metrics/LineLength

aruba.config.remove_ansi_escape_sequences = false
end


Before '@mocked_home_directory' do
Aruba.platform.deprecated('The use of "@mocked_home_directory" is deprecated. Use "@mocked-home-directory" instead')

set_environment_variable 'HOME', expand_path('.')
end

When(/^I run "(.*)"$/)do |cmd|
warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})

cmd = sanitize_text(cmd)
run_command_and_stop(cmd, false)
end

When(/^I successfully run "(.*)"$/)do |cmd|
warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})

cmd = sanitize_text(cmd)
run_command_and_stop(cmd)
end

When(/^I run "([^"]*)" interactively$/) do |cmd|
Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})

step %(I run `#{cmd}` interactively)
end

Given(/the default aruba timeout is (\d+) seconds/) do |seconds|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
# rubocop:enable Metrics/LineLength

aruba.config.exit_timeout = seconds.to_i
end

Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
# rubocop:enable Metrics/LineLength

aruba.config.exit_timeout = seconds.to_i
end

Then(/^the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)"$/) do |file, negated, permissions|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of step "the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)" is deprecated. Use "^the (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$" instead')
# rubocop:enable Metrics/LineLength

if negated
expect(file).not_to have_permissions(permissions)
else
expect(file).to have_permissions(permissions)
end
end

12 changes: 0 additions & 12 deletions lib/aruba/cucumber/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,6 @@
end
end

Then(/^the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)"$/) do |file, negated, permissions|
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of step "the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)" is deprecated. Use "^the (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$" instead')
# rubocop:enable Metrics/LineLength

if negated
expect(file).not_to have_permissions(permissions)
else
expect(file).to have_permissions(permissions)
end
end

Then(/^the (?:file|directory)(?: named)? "([^"]*)" should( not)? have permissions "([^"]*)"$/) do |path, negated, permissions|
if negated
expect(path).not_to have_permissions(permissions)
Expand Down
44 changes: 0 additions & 44 deletions lib/aruba/cucumber/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
aruba.announcer.activate :command_filesystem_status
end

Before('@announce-cmd') do
Aruba.platform.deprecated 'The use of "@announce-cmd"-hook is deprecated. Please use "@announce-command"'

aruba.announcer.activate :command
end

Before('@announce-output') do
aruba.announcer.activate :stdout
aruba.announcer.activate :stderr
Expand All @@ -63,12 +57,6 @@
aruba.announcer.activate :stderr
end

Before('@announce-dir') do
Aruba.platform.deprecated 'The use of "@announce-dir"-hook is deprecated. Please use "@announce-directory"'

aruba.announcer.activate :directory
end

Before('@announce-directory') do
aruba.announcer.activate :directory
end
Expand All @@ -77,28 +65,10 @@
aruba.announcer.activate :stop_signal
end

Before('@announce-env') do
Aruba.platform.deprecated 'The use of "@announce-env"-hook is deprecated. Please use "@announce-changed-environment"'

aruba.announcer.activate :environment
end

Before('@announce-environment') do
Aruba.platform.deprecated '@announce-environment is deprecated. Use @announce-changed-environment instead'

aruba.announcer.activate :changed_environment
end

Before('@announce-full-environment') do
aruba.announcer.activate :full_environment
end

Before('@announce-modified-environment') do
Aruba.platform.deprecated '@announce-modified-environment is deprecated. Use @announce-changed-environment instead'

aruba.announcer.activate :changed_environment
end

Before('@announce-changed-environment') do
aruba.announcer.activate :changed_environment
end
Expand Down Expand Up @@ -135,25 +105,11 @@
# aruba.config.command_launcher = :spawn
# end

Before('@ansi') do
# rubocop:disable Metrics/LineLength
Aruba::Platform.deprecated('The use of "@ansi" is deprecated. Use "@keep-ansi-escape-sequences" instead. But be aware, that this hook uses the aruba configuration and not an instance variable')
# rubocop:enable Metrics/LineLength

aruba.config.remove_ansi_escape_sequences = false
end

Before('@keep-ansi-escape-sequences') do
aruba.config.remove_ansi_escape_sequences = false
aruba.config.keep_ansi = true
end

Before '@mocked_home_directory' do
Aruba.platform.deprecated('The use of "@mocked_home_directory" is deprecated. Use "@mocked-home-directory" instead')

set_environment_variable 'HOME', expand_path('.')
end

Before '@mocked-home-directory' do
set_environment_variable 'HOME', expand_path('.')
end
Expand Down