cuken 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +8 -8
  3. data/VERSION +1 -1
  4. data/cuken.gemspec +19 -5
  5. data/features/about.md +110 -27
  6. data/features/chef_examples/cookbooks_cookbook.feature +2 -2
  7. data/features/chef_examples/zenoss/01_chef_server_setup.feature +205 -0
  8. data/features/chef_examples/zenoss/02_monitor_vm_setup.feature +139 -0
  9. data/features/chef_examples/zenoss/03_monitor_chef_setup.feature +109 -0
  10. data/features/step_definitions/cuken_steps.rb +16 -0
  11. data/features/support/env.rb +1 -0
  12. data/lib/cuken/api/chef/common.rb +20 -0
  13. data/lib/cuken/api/chef/cookbook.rb +62 -1
  14. data/lib/cuken/api/chef/data_bag.rb +89 -0
  15. data/lib/cuken/api/chef/knife.rb +16 -0
  16. data/lib/cuken/api/chef/role.rb +71 -0
  17. data/lib/cuken/api/chef.rb +51 -9
  18. data/lib/cuken/api/file.rb +68 -0
  19. data/lib/cuken/api/vagrant/common.rb +85 -0
  20. data/lib/cuken/api/vagrant/v_m.rb +125 -0
  21. data/lib/cuken/api/vagrant.rb +83 -0
  22. data/lib/cuken/chef.rb +16 -0
  23. data/lib/cuken/cucumber/chef/common.rb +4 -0
  24. data/lib/cuken/cucumber/chef/cookbook.rb +16 -2
  25. data/lib/cuken/cucumber/chef/data_bag.rb +48 -16
  26. data/lib/cuken/cucumber/chef/role.rb +30 -0
  27. data/lib/cuken/cucumber/chef.rb +16 -5
  28. data/lib/cuken/cucumber/cmd.rb +16 -0
  29. data/lib/cuken/cucumber/common.rb +16 -0
  30. data/lib/cuken/cucumber/file.rb +52 -0
  31. data/lib/cuken/cucumber/git/hooks.rb +28 -0
  32. data/lib/cuken/cucumber/rvm.rb +16 -0
  33. data/lib/cuken/cucumber/ssh/hooks.rb +31 -0
  34. data/lib/cuken/cucumber/ssh.rb +16 -0
  35. data/lib/cuken/cucumber/vagrant/common.rb +93 -0
  36. data/lib/cuken/cucumber/vagrant/hooks.rb +35 -0
  37. data/lib/cuken/cucumber/vagrant.rb +26 -0
  38. data/lib/cuken/vagrant.rb +19 -0
  39. metadata +18 -4
@@ -69,6 +69,74 @@ module Cuken
69
69
  end
70
70
  end
71
71
 
72
+ def place_file(src, dst)
73
+ dest = Pathname(dst).expand_path.realdirpath
74
+ FileUtils.mkdir_p((dest+src).dirname.to_s)
75
+ in_current_dir do
76
+ opts = {:verbose => true, :preserve => true, :remove_destination => true}
77
+ FileUtils.cp_r(src, (dest+src).to_s, opts).should be_nil
78
+ FileUtils.compare_file(src, (dest+src).to_s).should be_true
79
+ end
80
+ end
81
+
82
+ def place_folder_contents(dest_dir_name, src_dir_name)
83
+ dest = Pathname(dest_dir_name).expand_path.realdirpath
84
+ dest_parent = dest.dirname.to_s
85
+ FileUtils.mkdir_p((dest+src_dir_name).to_s)
86
+ in_current_dir do
87
+ opts = {:verbose => true, :preserve => true, :remove_destination => true}
88
+ FileUtils.cp_r(src_dir_name+'/.', dest.to_s, opts).should be_nil
89
+ end
90
+ Dir.glob("#{src_dir_name}/**/*").each do |fn|
91
+ if File.file?(fn)
92
+ fn2 = File.join(dest_parent, fn)
93
+ FileUtils.compare_file(fn, fn2).should be_true
94
+ end
95
+ end
96
+ end
97
+
98
+ def check_placed_file_content(file, partial_content, expect_match)
99
+ prep_for_placed_fs_check do
100
+ content = IO.read(file)
101
+ if expect_match
102
+ content.should include partial_content
103
+ else
104
+ content.should_not include partial_content
105
+ end
106
+ end
107
+ end
108
+
109
+ def prep_for_placed_fs_check(&block)
110
+ stop_processes!
111
+ block.call
112
+ end
113
+
114
+ def check_placed_file_presence(paths, expect_presence)
115
+ prep_for_placed_fs_check do
116
+ paths.each do |path|
117
+ if expect_presence
118
+ ::File.should be_file(path)
119
+ else
120
+ ::File.should_not be_file(path)
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+ def check_placed_directory_presence(paths, expect_presence)
127
+ prep_for_placed_fs_check do
128
+ paths.each do |path|
129
+ if expect_presence
130
+ dest = Pathname(path).expand_path.realdirpath
131
+ Pathname(dest).mkpath
132
+ Pathname(path).should be_directory
133
+ else
134
+ Pathname(path).should_not be_directory
135
+ end
136
+ end
137
+ end
138
+ end
139
+
72
140
  end
73
141
  end
74
142
  end
@@ -0,0 +1,85 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module ::Cuken
18
+ module Api
19
+ module Vagrant
20
+ module Common
21
+
22
+ def establish_vm_interactive_ssh(boxname)
23
+ cmd = vagrant.vm[boxname.to_sym].ssh.ssh_connect_command
24
+ run_interactive(unescape(cmd))
25
+ end
26
+
27
+ def load_vagrant_file(path, expect_presence = true)
28
+ vagrant.path = Pathname(path).expand_path.realdirpath
29
+ if expect_presence
30
+ vagrant.path.exist?.should be_true
31
+ else
32
+ vagrant.path.exist?.should be_false
33
+ end
34
+ end
35
+
36
+ def check_vagrant_file_presence(path, expect_presence = true)
37
+ if Pathname(chef.root_dir).exist?
38
+ in_chef_root do
39
+ if expect_presence
40
+ load_vagrant_file(path)
41
+ end
42
+ end
43
+ else
44
+ in_current_dir do
45
+ if expect_presence
46
+ load_vagrant_file(path)
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def check_vm_active(name, expect_active = true )
53
+ in_chef_root do
54
+ if expect_active
55
+ if vagrant.environment.local_data[:active][name].nil?
56
+ vagrant.up(name)
57
+ end
58
+ vagrant.environment.local_data[:active][name].should_not be_nil
59
+ else
60
+ if vagrant.environment.local_data[:active][name]
61
+ vagrant.halt(name)
62
+ end
63
+ vagrant.environment.local_data[:active][name].should be_nil
64
+ end
65
+ end
66
+ end
67
+
68
+ def check_vm_state(name, state, expect_state = true )
69
+ in_chef_root do
70
+ if expect_state
71
+ vagrant.vm[name.to_sym].vm.state.should == state
72
+ else
73
+ vagrant.vm[name.to_sym].vm.state.should_not == state
74
+ end
75
+ end
76
+ end
77
+
78
+ def run_vm_manager_command(cmd, vm_name, vm_manager = :vagrant)
79
+ method(vm_manager).call.send(cmd, vm_name)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+
@@ -0,0 +1,125 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module ::Cuken
18
+ module Api
19
+ module Vagrant
20
+ module VM
21
+ attr_accessor :name
22
+ attr_writer :path
23
+ attr_reader :vm, :vagrant_vm
24
+
25
+ def initialize(name)
26
+ e = environment
27
+ @vagrant_vm = ::Vagrant::VM.new(:env => e, :name => name)
28
+ @vm = {}
29
+ @name = name
30
+ environment.vm = {}
31
+ get_vm(name)
32
+ @vagrant_vm
33
+ end
34
+
35
+ def vm_config
36
+ @vm_config ||= environment.instance_variable_get(:@config).instance_variable_get(:@vm)
37
+ end
38
+
39
+ def vms
40
+ @vms = environment.instance_variable_get(:@vms)
41
+ end
42
+
43
+ # def name
44
+ # @name ||= 'cuken'
45
+ # end
46
+
47
+ def uuid
48
+ @vm.uuid
49
+ end
50
+
51
+ def path
52
+ @path ||= Pathname.pwd
53
+ end
54
+
55
+ def vagrantfile
56
+ vf = path + 'Vagrantfile'
57
+ vf.exist? ? vf : nil
58
+ end
59
+
60
+ def environment
61
+ @environment = ::Vagrant::Environment.new(:cwd => path).reload_config!
62
+ end
63
+
64
+ def get_vm(box_name)
65
+ unless environment.multivm?
66
+ @vm[:primary] = environment.primary_vm
67
+ else
68
+ if box_name
69
+ @vm[box_name.to_sym] = environment.vms[box_name.to_sym]
70
+ else
71
+ tmpvm = environment.vms.first
72
+ @vm[tmpvm[0]] = tmpvm[1]
73
+ end
74
+ end
75
+ environment.vm = @vm
76
+ end
77
+
78
+ def configuration
79
+ @configuration ||= instance_variable_get :@config
80
+ end
81
+
82
+ def state(name)
83
+ vm[name.to_sym].vm.state
84
+ end
85
+
86
+ def run_vagrant_cli(cmd, vm_name)
87
+ ::Vagrant::CLI.start([cmd, vm_name], :env => environment)
88
+ end
89
+
90
+ def up(vm_name = name)
91
+ run_vagrant_cli(__method__.to_s, vm_name)
92
+ end
93
+
94
+ def destroy(vm_name = name)
95
+ run_vagrant_cli(__method__.to_s, vm_name)
96
+ end
97
+
98
+ def halt(vm_name = name)
99
+ run_vagrant_cli(__method__.to_s, vm_name)
100
+ end
101
+
102
+ def provision(vm_name = name)
103
+ run_vagrant_cli(__method__.to_s, vm_name)
104
+ end
105
+
106
+ def status(vm_name = name)
107
+ run_vagrant_cli(__method__.to_s, vm_name)
108
+ end
109
+
110
+ def suspend(vm_name = name)
111
+ run_vagrant_cli(__method__.to_s, vm_name)
112
+ end
113
+
114
+ def resume(vm_name = name)
115
+ run_vagrant_cli(__method__.to_s, vm_name)
116
+ end
117
+
118
+ def reload(vm_name = name)
119
+ run_vagrant_cli(__method__.to_s, vm_name)
120
+ end
121
+
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,83 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ require 'vagrant' unless defined? ::Vagrant
18
+
19
+ require 'cuken/api/common'
20
+ require 'cuken/api/vagrant/common'
21
+ require 'cuken/api/vagrant/v_m'
22
+
23
+ module ::Cuken
24
+ module Api
25
+ module Vagrant
26
+
27
+ include ::Cuken::Api::Vagrant::Common
28
+
29
+ class VVM
30
+ include ::Cuken::Api::Vagrant::VM
31
+ end
32
+
33
+ def vagrant(box_name = nil)
34
+ @vagrant ||= VVM.new(box_name)
35
+ end
36
+
37
+ def switch_vagrant_environment
38
+ @vagrant = nil
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+
45
+ module ::Vagrant
46
+ class SSH
47
+
48
+ # In order to run Aruba's 'When I type "..."' steps:
49
+ # Returns a Vagrant SSH connection string for the environment's virtual machine,
50
+ # This method optionally takes a hash of options which override the configuration values.
51
+ def ssh_connect_command(opts={})
52
+ if Mario::Platform.windows?
53
+ raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path,
54
+ :ssh_port => port(opts)
55
+ end
56
+
57
+ raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1")
58
+
59
+ options = {}
60
+ options[:port] = port(opts)
61
+ [:host, :username, :private_key_path].each do |param|
62
+ options[param] = opts[param] || env.config.ssh.send(param)
63
+ end
64
+
65
+ check_key_permissions(options[:private_key_path])
66
+
67
+ # Command line options
68
+ command_options = ["-p #{options[:port]}", "-o UserKnownHostsFile=/dev/null",
69
+ "-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes",
70
+ "-i #{options[:private_key_path]}"]
71
+ command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent
72
+
73
+ if env.config.ssh.forward_x11
74
+ # Both are required so that no warnings are shown regarding X11
75
+ command_options << "-o ForwardX11=yes"
76
+ command_options << "-o ForwardX11Trusted=yes"
77
+ end
78
+
79
+ "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}".strip
80
+ end
81
+
82
+ end
83
+ end
data/lib/cuken/chef.rb CHANGED
@@ -1,3 +1,19 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
1
17
  require 'grit'
2
18
 
3
19
  require 'cuken/common'
@@ -16,6 +16,10 @@
16
16
  #
17
17
  World(::Cuken::Api::Chef)
18
18
 
19
+ Given /^the Chef root directory "([^"]*)" exists$/ do |directory|
20
+ check_chef_root_presence(directory)
21
+ end
22
+
19
23
  Given /^the Chef server URI "([^"]*)"$/ do |uri|
20
24
  chef.uri = uri
21
25
  end
@@ -24,6 +24,18 @@
24
24
  #
25
25
  World(::Cuken::Api::Chef::Cookbook)
26
26
 
27
+ When /^I load the Cookbooks:$/ do |table|
28
+ cookbooks_load(table)
29
+ end
30
+
31
+ Then /^these remote Cookbooks exist:$/ do |table|
32
+ check_remote_cookbook_table_presence(table)
33
+ end
34
+
35
+ Then /^these remote Cookbooks do not exist:$/ do |table|
36
+ check_remote_cookbook_table_presence(table, false)
37
+ end
38
+
27
39
  Given /^the remote Cookbook repository "([^"]*)"$/ do |ckbk_repo|
28
40
  in_current_dir do
29
41
  repo = Dir.exist?(ckbk_repo) ? Pathname(ckbk_repo).expand_path.realdirpath : ckbk_repo
@@ -91,7 +103,7 @@ Then /^the local Site\-Cookbook "([^"]*)" exists$/ do |ckbk|
91
103
  end
92
104
 
93
105
  And /^these local Cookbooks exist:$/ do |table|
94
- check_cookbooks_table_presence(table)
106
+ check_cookbook_table_presence(table)
95
107
  end
96
108
 
97
109
  And /^these local Site\-Cookbooks exist:$/ do |table|
@@ -129,7 +141,9 @@ When /^I clone the Cookbooks:$/ do |table|
129
141
  src['branch'] = hsh['branch'] if hsh['branch']
130
142
  src['tag'] = hsh['tag'] if hsh['tag']
131
143
  src['ref'] = hsh['ref'] if hsh['ref']
132
- local_repo = chef_clone_repo(hsh['destination'], true, chef.cookbooks_uri + hsh['cookbook'] + '.git', src )
144
+ ckbk = hsh['cookbook'] if hsh['cookbook']
145
+ ckbk = hsh['site-cookbook'] if hsh['site-cookbook']
146
+ local_repo = chef_clone_repo(hsh['destination'], true, chef.cookbooks_uri + ckbk + '.git', src )
133
147
  Pathname(local_repo).exist?.should be_true
134
148
  end
135
149
  end
@@ -1,27 +1,59 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Portions of this work are derived from the Chef project
6
+ # The original license header follows:
7
+ #
8
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
9
+ # License:: Apache License, Version 2.0
10
+ #
11
+ # Licensed under the Apache License, Version 2.0 (the "License");
12
+ # you may not use this file except in compliance with the License.
13
+ # You may obtain a copy of the License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the License is distributed on an "AS IS" BASIS,
19
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ # See the License for the specific language governing permissions and
21
+ # limitations under the License.
22
+ #
23
+ World(::Cuken::Api::Chef::DataBag)
24
+
1
25
  ###
2
26
  # Given
3
27
  ###
4
- #Given /^I create the "([^"]*)" Data Bag$/ do |arg1|
5
- # pending # express the regexp above with the code you wish you had
6
- #end
7
28
 
8
29
  ###
9
30
  # When
10
31
  ###
11
- #When /^I add these Cookbook Data Bag items:$/ do |table|
12
- # # table is a Cucumber::Ast::Table
13
- # pending # express the regexp above with the code you wish you had
14
- #end
15
32
 
16
33
  ###
17
34
  # Then
18
35
  ###
19
- #Then /^these Data Bags exist:$/ do |table|
20
- # # table is a Cucumber::Ast::Table
21
- # pending # express the regexp above with the code you wish you had
22
- #end
23
- #
24
- #Then /^the Data Bags contain:$/ do |table|
25
- # # table is a Cucumber::Ast::Table
26
- # pending # express the regexp above with the code you wish you had
27
- #end
36
+
37
+ Given /^I create the Data Bag "([^"]*)"$/ do |data_bag_name|
38
+ data_bag_create(data_bag_name)
39
+ end
40
+
41
+ When /^I add these Cookbook Data Bag items:$/ do |table|
42
+ load_data_bag_item_table(table)
43
+ end
44
+
45
+ Then /^these Data Bags exist:$/ do |table|
46
+ check_data_bag_table_presence(table)
47
+ end
48
+
49
+ Then /^these Data Bags do not exist:$/ do |table|
50
+ check_data_bag_table_presence(table, false)
51
+ end
52
+
53
+ Then /^these Data Bags contain:$/ do |table|
54
+ check_data_bag_content_table(table)
55
+ end
56
+
57
+ Then /^these Data Bags do not contain:$/ do |table|
58
+ check_data_bag_content_table(table, false)
59
+ end
@@ -1,3 +1,33 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ World(::Cuken::Api::Chef::Role)
18
+
19
+ When /^I load the Cookbook Roles:$/ do |table|
20
+ load_role_table(table)
21
+ end
22
+
23
+ And /^these Roles exist:$/ do |table|
24
+ check_role_table_presence(table)
25
+ end
26
+
27
+ And /^these Roles do not exist:$/ do |table|
28
+ check_role_table_presence(table, false)
29
+ end
30
+
1
31
  ###
2
32
  # Given
3
33
  ###
@@ -1,13 +1,24 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
1
17
  load 'aruba/cucumber.rb' unless defined? ::Aruba
2
18
  require 'grit'
3
19
 
4
20
  World(::Cuken::Api::Chef)
5
21
 
6
- Before do
7
- @aruba_timeout_seconds.nil? || @aruba_timeout_seconds < 20 ? @aruba_timeout_seconds = 20 : @aruba_timeout_seconds
8
- ::Grit::Git.git_timeout = 3610
9
- end
10
-
11
22
  require 'cuken/cucumber/chef/common'
12
23
  require 'cuken/cucumber/chef/knife'
13
24
  require 'cuken/cucumber/chef/cookbook'
@@ -1,3 +1,19 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
1
17
  load 'aruba/cucumber.rb' unless defined? ::Aruba
2
18
 
3
19
  World(::Cuken::Api::Cmd)
@@ -1,3 +1,19 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
1
17
 
2
18
  Given /^Assumption: (.*)$/ do |msg|
3
19
  announce_or_puts(msg)
@@ -1,3 +1,19 @@
1
+ #
2
+ # Author:: Hedgehog (<hedgehogshiatus@gmail.com>)
3
+ # Copyright:: Copyright (c) 2011 Hedgehog.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
1
17
  load 'aruba/cucumber.rb' unless defined? ::Aruba
2
18
  World(::Cuken::Api::File)
3
19
 
@@ -91,6 +107,22 @@ Given /^we record the a-mtime of "([^"]*)"$/ do |filename|
91
107
  record_amtimes(filename)
92
108
  end
93
109
 
110
+ #
111
+ # Placing and placed files and folders refer to taking a file for Aruba's scratch folder, moving it
112
+ # outside of that ephemeral area and verifying the contents.
113
+ #
114
+ When /^I place "([^"]*)" in "([^"]*)"$/ do |src, dst|
115
+ place_file(src, dst)
116
+ end
117
+
118
+ And /^the placed directory "([^"]*)" exists$/ do |directory|
119
+ check_placed_directory_presence([directory], true)
120
+ end
121
+
122
+ And /^the placed directory "([^"]*)" does not exist$/ do |directory|
123
+ check_placed_directory_presence([directory], false)
124
+ end
125
+
94
126
  Then /^the directory "([^"]*)" has decimal mode "(\d+)"$/ do |dirname, expected_mode|
95
127
  check_modes(expected_mode, dirname)
96
128
  end
@@ -103,6 +135,26 @@ Then /^the directory "([^"]*)" is owned by "([^"]*)"$/ do |dirname, owner|
103
135
  check_uid(dirname, owner)
104
136
  end
105
137
 
138
+ And /^I place all in "([^"]*)" in "([^"]*)"$/ do |src_dir_name, dest_dir_name|
139
+ place_folder_contents(dest_dir_name, src_dir_name)
140
+ end
141
+
142
+ And /^the placed file "([^"]*)" contains:$/ do |file, partial_content|
143
+ check_placed_file_content(file, partial_content, true)
144
+ end
145
+
146
+ And /^the placed file "([^"]*)" contains "([^"]*)"$/ do |file, partial_content|
147
+ check_placed_file_content(file, partial_content, true)
148
+ end
149
+
150
+ And /^the placed file "([^"]*)" exists$/ do |file|
151
+ check_placed_file_presence([file], true)
152
+ end
153
+
154
+ And /^the placed file "([^"]*)" does not exist$/ do |file|
155
+ check_placed_file_presence([file], false)
156
+ end
157
+
106
158
  Then /^the file "([^"]*)" is owned by "([^"]*)"$/ do |filename, owner|
107
159
  check_uid(filename, owner)
108
160
  end