aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
Diffstat (limited to 'spec/acceptance')
-rw-r--r--spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed.rb21
-rw-r--r--spec/acceptance/tests/should_create.rb18
-rw-r--r--spec/acceptance/tests/should_create_aliases.rb22
-rw-r--r--spec/acceptance/tests/should_destroy.rb20
-rw-r--r--spec/acceptance/tests/should_modify_alias.rb20
-rw-r--r--spec/acceptance/tests/should_modify_ip.rb20
-rw-r--r--spec/acceptance/tests/should_not_create_existing.rb16
-rw-r--r--spec/acceptance/tests/should_query_all.rb24
-rw-r--r--spec/acceptance/tests/ticket_4131_should_not_create_without_ip.rb22
9 files changed, 92 insertions, 91 deletions
diff --git a/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed.rb b/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed.rb
index 670651d..95cf6ed 100644
--- a/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed.rb
+++ b/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed.rb
@@ -1,32 +1,31 @@
-test_name "should not delete data when existing content is malformed"
+test_name 'should not delete data when existing content is malformed'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('host-not-delete-data')
teardown do
- on(agent, "rm -f #{file}", :acceptable_exit_codes => (0..255))
+ on(agent, "rm -f #{file}", acceptable_exit_codes: (0..255))
end
- step "(setup) populate test file with host information"
+ step '(setup) populate test file with host information'
on(agent, "printf '127.0.0.2 existing alias\n' > #{file}")
- step "(setup) populate test file with a malformed line"
+ step '(setup) populate test file with a malformed line'
on(agent, "printf '==\n' >> #{file}")
- step "tell puppet to add another host entry"
+ step 'tell puppet to add another host entry'
on(agent, puppet_resource('host', 'test', "target=#{file}",
- 'ensure=present', 'ip=127.0.0.3', 'host_aliases=foo'))
+ 'ensure=present', 'ip=127.0.0.3', 'host_aliases=foo'))
- step "verify that the initial host entry was not deleted"
+ step 'verify that the initial host entry was not deleted'
on(agent, "cat #{file}") do |res|
- fail_test "existing host data was deleted" unless
+ fail_test 'existing host data was deleted' unless
res.stdout.include? 'existing'
end
-
end
diff --git a/spec/acceptance/tests/should_create.rb b/spec/acceptance/tests/should_create.rb
index b590f85..3ce34e8 100644
--- a/spec/acceptance/tests/should_create.rb
+++ b/spec/acceptance/tests/should_create.rb
@@ -1,23 +1,23 @@
-test_name "host should create"
+test_name 'host should create'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
target = agent.tmpfile('host-create')
- step "clean up for the test"
+ step 'clean up for the test'
on agent, "rm -f #{target}"
- step "create the host record"
- on(agent, puppet_resource("host", "test", "ensure=present",
- "ip=127.0.0.1", "target=#{target}"))
+ step 'create the host record'
+ on(agent, puppet_resource('host', 'test', 'ensure=present',
+ 'ip=127.0.0.1', "target=#{target}"))
- step "verify that the record was created"
+ step 'verify that the record was created'
on(agent, "cat #{target} ; rm -f #{target}") do
- fail_test "record was not present" unless stdout =~ /^127\.0\.0\.1[[:space:]]+test/
+ fail_test 'record was not present' unless stdout =~ %r{^127\.0\.0\.1[[:space:]]+test}
end
end
diff --git a/spec/acceptance/tests/should_create_aliases.rb b/spec/acceptance/tests/should_create_aliases.rb
index be4a134..a76263a 100644
--- a/spec/acceptance/tests/should_create_aliases.rb
+++ b/spec/acceptance/tests/should_create_aliases.rb
@@ -1,24 +1,24 @@
-test_name "host should create aliases"
+test_name 'host should create aliases'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
- target = agent.tmpfile('host-create-aliases')
+ target = agent.tmpfile('host-create-aliases')
- step "clean up the system for testing"
+ step 'clean up the system for testing'
on agent, "rm -f #{target}"
- step "create the record"
- on(agent, puppet_resource('host', 'test', "ensure=present",
- "ip=127.0.0.7", "target=#{target}", "host_aliases=alias"))
+ step 'create the record'
+ on(agent, puppet_resource('host', 'test', 'ensure=present',
+ 'ip=127.0.0.7', "target=#{target}", 'host_aliases=alias'))
- step "verify that the aliases were added"
+ step 'verify that the aliases were added'
on(agent, "cat #{target} ; rm -f #{target}") do
- fail_test "alias was missing" unless
- stdout =~ /^127\.0\.0\.7[[:space:]]+test[[:space:]]alias/
+ fail_test 'alias was missing' unless
+ stdout =~ %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias}
end
end
diff --git a/spec/acceptance/tests/should_destroy.rb b/spec/acceptance/tests/should_destroy.rb
index 97f1477..f55c24b 100644
--- a/spec/acceptance/tests/should_destroy.rb
+++ b/spec/acceptance/tests/should_destroy.rb
@@ -1,27 +1,27 @@
-test_name "should be able to remove a host record"
+test_name 'should be able to remove a host record'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('host-destroy')
- line = "127.0.0.7 test1"
+ line = '127.0.0.7 test1'
- step "set up files for the test"
+ step 'set up files for the test'
on agent, "printf '#{line}\n' > #{file}"
- step "delete the resource from the file"
+ step 'delete the resource from the file'
on(agent, puppet_resource('host', 'test1', "target=#{file}",
- 'ensure=absent', 'ip=127.0.0.7'))
+ 'ensure=absent', 'ip=127.0.0.7'))
- step "verify that the content was removed"
+ step 'verify that the content was removed'
on(agent, "cat #{file}; rm -f #{file}") do
- fail_test "the content was still present" if stdout.include? line
+ fail_test 'the content was still present' if stdout.include? line
end
- step "clean up after the test"
+ step 'clean up after the test'
on agent, "rm -f #{file}"
end
diff --git a/spec/acceptance/tests/should_modify_alias.rb b/spec/acceptance/tests/should_modify_alias.rb
index 07198b1..f2171f0 100644
--- a/spec/acceptance/tests/should_modify_alias.rb
+++ b/spec/acceptance/tests/should_modify_alias.rb
@@ -1,27 +1,27 @@
-test_name "should be able to modify a host alias"
+test_name 'should be able to modify a host alias'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('host-modify-alias')
- step "set up files for the test"
+ step 'set up files for the test'
on agent, "printf '127.0.0.8 test alias\n' > #{file}"
- step "modify the resource"
+ step 'modify the resource'
on(agent, puppet_resource('host', 'test', "target=#{file}",
- 'ensure=present', 'ip=127.0.0.8', 'host_aliases=banzai'))
+ 'ensure=present', 'ip=127.0.0.8', 'host_aliases=banzai'))
- step "verify that the content was updated"
+ step 'verify that the content was updated'
on(agent, "cat #{file}; rm -f #{file}") do
- fail_test "the alias was not updated" unless
- stdout =~ /^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$/
+ fail_test 'the alias was not updated' unless
+ stdout =~ %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}
end
- step "clean up after the test"
+ step 'clean up after the test'
on agent, "rm -f #{file}"
end
diff --git a/spec/acceptance/tests/should_modify_ip.rb b/spec/acceptance/tests/should_modify_ip.rb
index 10c5adf..22019b7 100644
--- a/spec/acceptance/tests/should_modify_ip.rb
+++ b/spec/acceptance/tests/should_modify_ip.rb
@@ -1,27 +1,27 @@
-test_name "should be able to modify a host address"
+test_name 'should be able to modify a host address'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('host-modify-ip')
- step "set up files for the test"
+ step 'set up files for the test'
on agent, "printf '127.0.0.9 test alias\n' > #{file}"
- step "modify the resource"
+ step 'modify the resource'
on(agent, puppet_resource('host', 'test', "target=#{file}",
- 'ensure=present', 'ip=127.0.0.10', 'host_aliases=alias'))
+ 'ensure=present', 'ip=127.0.0.10', 'host_aliases=alias'))
- step "verify that the content was updated"
+ step 'verify that the content was updated'
on(agent, "cat #{file}; rm -f #{file}") do
- fail_test "the address was not updated" unless
- stdout =~ /^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$/
+ fail_test 'the address was not updated' unless
+ stdout =~ %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$}
end
- step "clean up after the test"
+ step 'clean up after the test'
on agent, "rm -f #{file}"
end
diff --git a/spec/acceptance/tests/should_not_create_existing.rb b/spec/acceptance/tests/should_not_create_existing.rb
index 0cdc87b..31686bc 100644
--- a/spec/acceptance/tests/should_not_create_existing.rb
+++ b/spec/acceptance/tests/should_not_create_existing.rb
@@ -1,24 +1,24 @@
-test_name "should not create host if it exists"
+test_name 'should not create host if it exists'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('host-not-create-existing')
- step "set up the system for the test"
+ step 'set up the system for the test'
on agent, "printf '127.0.0.2 test alias\n' > #{file}"
- step "tell puppet to ensure the host exists"
+ step 'tell puppet to ensure the host exists'
on(agent, puppet_resource('host', 'test', "target=#{file}",
- 'ensure=present', 'ip=127.0.0.2', 'host_aliases=alias')) do
- fail_test "darn, we created the host record" if
+ 'ensure=present', 'ip=127.0.0.2', 'host_aliases=alias')) do
+ fail_test 'darn, we created the host record' if
stdout.include? '/Host[test1]/ensure: created'
end
- step "clean up after we created things"
+ step 'clean up after we created things'
on agent, "rm -f #{file}"
end
diff --git a/spec/acceptance/tests/should_query_all.rb b/spec/acceptance/tests/should_query_all.rb
index e60756d..cc92566 100644
--- a/spec/acceptance/tests/should_query_all.rb
+++ b/spec/acceptance/tests/should_query_all.rb
@@ -1,34 +1,34 @@
-test_name "should query all hosts from hosts file"
+test_name 'should query all hosts from hosts file'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
-content = %q{127.0.0.1 test1 test1.local
+content = '127.0.0.1 test1 test1.local
127.0.0.2 test2 test2.local
127.0.0.3 test3 test3.local
127.0.0.4 test4 test4.local
-}
+'
agents.each do |agent|
backup = agent.tmpfile('host-query-all')
- step "configure the system for testing (including file backups)"
+ step 'configure the system for testing (including file backups)'
on agent, "cp /etc/hosts #{backup}"
- on agent, "cat > /etc/hosts", :stdin => content
+ on agent, 'cat > /etc/hosts', stdin: content
- step "query all host records using puppet"
+ step 'query all host records using puppet'
on(agent, puppet_resource('host')) do
- found = stdout.scan(/host \{ '([^']+)'/).flatten.sort
+ found = stdout.scan(%r{host \{ '([^']+)'}).flatten.sort
fail_test "the list of returned hosts was wrong: #{found.join(', ')}" unless
- found == %w{test1 test2 test3 test4}
+ found == ['test1', 'test2', 'test3', 'test4']
- count = stdout.scan(/ensure\s+=>\s+'present'/).length
+ count = stdout.scan(%r{ensure\s+=>\s+'present'}).length
fail_test "found #{count} records, wanted 4" unless count == 4
end
- step "clean up the system afterwards"
+ step 'clean up the system afterwards'
on agent, "cat #{backup} > /etc/hosts && rm -f #{backup}"
end
diff --git a/spec/acceptance/tests/ticket_4131_should_not_create_without_ip.rb b/spec/acceptance/tests/ticket_4131_should_not_create_without_ip.rb
index 867ff6c..a26faee 100644
--- a/spec/acceptance/tests/ticket_4131_should_not_create_without_ip.rb
+++ b/spec/acceptance/tests/ticket_4131_should_not_create_without_ip.rb
@@ -1,29 +1,31 @@
-test_name "#4131: should not create host without IP attribute"
+test_name '#4131: should not create host without IP attribute'
tag 'audit:low',
'audit:refactor', # Use block style `test_name`
'audit:acceptance' # Could be done at the integration (or unit) layer though
- # actual changing of resources could irreparably damage a
- # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
agents.each do |agent|
file = agent.tmpfile('4131-require-ip')
- step "configure the target system for the test"
+ step 'configure the target system for the test'
on agent, "rm -rf #{file} ; touch #{file}"
- step "try to create the host, which should fail"
+ step 'try to create the host, which should fail'
# REVISIT: This step should properly need to handle the non-zero exit code,
# and #5668 has been filed to record that. When it is fixed this test will
# start to fail, and this comment will tell you why. --daniel 2010-12-24
on(agent, puppet_resource('host', 'test', "target=#{file}",
- "host_aliases=alias")) do
- fail_test "puppet didn't complain about the missing attribute" unless
- stderr.include? 'ip is a required attribute for hosts' unless agent['locale'] == 'ja'
+ 'host_aliases=alias')) do
+ unless agent['locale'] == 'ja'
+ fail_test "puppet didn't complain about the missing attribute" unless
+ stderr.include? 'ip is a required attribute for hosts'
+ end
end
- step "verify that the host was not added to the file"
+ step 'verify that the host was not added to the file'
on(agent, "cat #{file} ; rm -f #{file}") do
- fail_test "the host was apparently added to the file" if stdout.include? 'test'
+ fail_test 'the host was apparently added to the file' if stdout.include? 'test'
end
end