acceptance/tests/stub_host.rb in beaker-puppet-1.29.0 vs acceptance/tests/stub_host.rb in beaker-puppet-2.0.0

- old
+ new

@@ -1,49 +1,50 @@ require 'beaker-puppet' -test_name "validate host stubbing behavior" +test_name 'validate host stubbing behavior' def get_hosts_file(host) if host['platform'] =~ /win/ - hosts_file = "C:\\\\Windows\\\\System32\\\\Drivers\\\\etc\\\\hosts" + 'C:\\\\Windows\\\\System32\\\\Drivers\\\\etc\\\\hosts' else - hosts_file = '/etc/hosts' + '/etc/hosts' end - return hosts_file end step 'verify stub_host_on' do step 'should add entry to hosts file' do hosts.each do |host| - stub_hosts_on(host, { 'foo' => '1.1.1.1' }, { 'foo' => [ 'bar', 'baz' ] }) + stub_hosts_on(host, { 'foo' => '1.1.1.1' }, { 'foo' => %w[bar baz] }) hosts_file = get_hosts_file(host) result = on host, "cat #{hosts_file}" - assert_match %r{foo}, result.stdout + assert_match(/foo/, result.stdout) end end step 'stubbed value should be available for other steps in the test' do hosts.each do |host| hosts_file = get_hosts_file(host) result = on host, "cat #{hosts_file}" - assert_match %r{foo}, result.stdout + assert_match(/foo/, result.stdout) end end end step 'verify with_stub_host_on' do step 'should add entry to hosts file' do hosts.each do |host| hosts_file = get_hosts_file(host) - result = with_host_stubbed_on(host, { 'sleepy' => '1.1.1.2' }, { 'sleepy' => [ 'grumpy', 'dopey' ] }) { on host, "cat #{hosts_file}" } - assert_match %r{sleepy}, result.stdout + result = with_host_stubbed_on(host, { 'sleepy' => '1.1.1.2' }, { 'sleepy' => %w[grumpy dopey] }) do + on host, "cat #{hosts_file}" + end + assert_match(/sleepy/, result.stdout) end end step 'stubbed value should be reverted after the execution of the block' do hosts.each do |host| hosts_file = get_hosts_file(host) result = on host, "cat #{hosts_file}" - assert_no_match %r{sleepy}, result.stdout + assert_no_match(/sleepy/, result.stdout) end end end