Merge branch 'features-clean-up'
Clean up our cucumber features, remove usage of an ugly monkey patch, expose with a tag the usage of a fake home directory in a scenario.
This commit is contained in:
commit
601e330c04
@ -12,6 +12,7 @@ Feature: SSH settings
|
|||||||
When I successfully execute the recipe
|
When I successfully execute the recipe
|
||||||
Then the output must contain my current login name
|
Then the output must contain my current login name
|
||||||
|
|
||||||
|
@fake_home
|
||||||
Scenario: uses configured SSH user name for a given host
|
Scenario: uses configured SSH user name for a given host
|
||||||
Given an SSH config with:
|
Given an SSH config with:
|
||||||
"""
|
"""
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# FIXME: our monkey patch currently prevent us from using `must' in step
|
Then /^the output must contain my current login name$/ do
|
||||||
# definitions.
|
assert_partial_output Etc.getlogin, all_output
|
||||||
Then(/^the output should contain my current login name$/) do
|
|
||||||
assert_partial_output(Etc.getlogin, all_output)
|
|
||||||
end
|
end
|
||||||
|
3
features/steps/execution_steps.rb
Normal file
3
features/steps/execution_steps.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the exit status must be (\d+)$/ do |exit_status|
|
||||||
|
assert_exit_status exit_status.to_i
|
||||||
|
end
|
23
features/steps/output_steps.rb
Normal file
23
features/steps/output_steps.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Then /^the output must match \/([^\/]+)\/$/ do |pattern|
|
||||||
|
assert_matching_output pattern, all_output
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must contain "([^"]+)"$/ do |content|
|
||||||
|
assert_partial_output content, all_output
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must contain:$/ do |content|
|
||||||
|
assert_partial_output content, all_output
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must not contain "([^"]+)"$/ do |content|
|
||||||
|
assert_no_partial_output content, all_output
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must contain exactly "([^"]+)"$/ do |content|
|
||||||
|
assert_exact_output content, all_output
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must contain exactly:$/ do |content|
|
||||||
|
assert_exact_output content, all_output
|
||||||
|
end
|
@ -1,16 +1,16 @@
|
|||||||
Given(/^a recipe with:$/) do |recipe_body|
|
Given /^a recipe with:$/ do |recipe_body|
|
||||||
write_file 'recipe.rb', recipe_body
|
write_file 'recipe.rb', recipe_body
|
||||||
end
|
end
|
||||||
|
|
||||||
When(/^I execute the recipe$/) do
|
When /^I execute the recipe$/ do
|
||||||
run_simple('producer recipe.rb', false)
|
run_simple 'producer recipe.rb', false
|
||||||
end
|
end
|
||||||
|
|
||||||
When(/^I successfully execute the recipe$/) do
|
When /^I successfully execute the recipe$/ do
|
||||||
step 'I execute the recipe'
|
step 'I execute the recipe'
|
||||||
assert_exit_status(0)
|
assert_exit_status 0
|
||||||
end
|
end
|
||||||
|
|
||||||
When(/^I execute the recipe interactively$/) do
|
When /^I execute the recipe interactively$/ do
|
||||||
run_interactive('producer recipe.rb')
|
run_interactive 'producer recipe.rb'
|
||||||
end
|
end
|
||||||
|
@ -10,14 +10,14 @@ Given /^a remote file named "([^"]+)" with "([^"]+)"$/ do |file_name, content|
|
|||||||
write_file file_name, content
|
write_file file_name, content
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the remote directory "([^"]+)" should exists$/ do |path|
|
Then /^the remote directory "([^"]+)" must exists$/ do |path|
|
||||||
check_directory_presence([path], true)
|
check_directory_presence [path], true
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the remote file "([^"]+)" should contain "([^"]+)"/ do |path, content|
|
Then /^the remote file "([^"]+)" must contain "([^"]+)"$/ do |path, content|
|
||||||
check_file_content path, content, true
|
check_file_content path, content, true
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the remote file "([^"]+)" should contain exactly "([^"]+)"/ do |path, content|
|
Then /^the remote file "([^"]+)" must contain exactly "([^"]+)"$/ do |path, content|
|
||||||
check_exact_file_content path, content
|
check_exact_file_content path, content
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# FIXME: current home directory shouldn't be changed here, maybe we should use
|
Given /^an SSH config with:$/ do |config|
|
||||||
# a tag for features needing a fake home directory.
|
|
||||||
Given(/^an SSH config with:$/) do |config|
|
|
||||||
ENV['HOME'] = File.expand_path current_dir
|
|
||||||
write_file '.ssh/config', config
|
write_file '.ssh/config', config
|
||||||
end
|
end
|
||||||
|
@ -1,18 +1,2 @@
|
|||||||
module Cucumber
|
|
||||||
class Runtime
|
|
||||||
alias :old_step_match :step_match
|
|
||||||
|
|
||||||
def step_match(step_name, name_to_report = nil)
|
|
||||||
if step_name.include? ' must '
|
|
||||||
name_to_report = step_name.dup
|
|
||||||
step_name.gsub! ' must ', ' should '
|
|
||||||
end
|
|
||||||
|
|
||||||
old_step_match(step_name, name_to_report)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'aruba/cucumber'
|
require 'aruba/cucumber'
|
||||||
|
|
||||||
require 'cucumber/sshd/cucumber'
|
require 'cucumber/sshd/cucumber'
|
||||||
|
3
features/support/env_fake_home.rb
Normal file
3
features/support/env_fake_home.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Before('@fake_home') do
|
||||||
|
ENV['HOME'] = File.expand_path(current_dir)
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user