auser-poolparty 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/Manifest.txt +201 -0
  2. data/PostInstall.txt +17 -0
  3. data/Rakefile +22 -1
  4. data/bin/cloud-add-keypair +0 -0
  5. data/bin/cloud-osxcopy +22 -0
  6. data/bin/cloud-provision +1 -0
  7. data/bin/cloud-start +17 -15
  8. data/bin/cloud-terminate +23 -0
  9. data/bin/pool-start +14 -14
  10. data/bin/pool-start-monitor +1 -0
  11. data/config/hoe.rb +114 -0
  12. data/config/requirements.rb +15 -0
  13. data/lib/poolparty.rb +1 -0
  14. data/lib/poolparty/base_packages/haproxy.rb +32 -31
  15. data/lib/poolparty/base_packages/heartbeat.rb +2 -2
  16. data/lib/poolparty/base_packages/poolparty.rb +9 -3
  17. data/lib/poolparty/base_packages/ruby.rb +10 -0
  18. data/lib/poolparty/core/proc.rb +5 -0
  19. data/lib/poolparty/core/string.rb +1 -1
  20. data/lib/poolparty/helpers/binary.rb +6 -5
  21. data/lib/poolparty/helpers/display.rb +11 -2
  22. data/lib/poolparty/helpers/optioner.rb +6 -3
  23. data/lib/poolparty/helpers/provisioner_base.rb +9 -7
  24. data/lib/poolparty/helpers/provisioners/master.rb +38 -4
  25. data/lib/poolparty/helpers/provisioners/slave.rb +2 -2
  26. data/lib/poolparty/modules/cloud_resourcer.rb +20 -3
  27. data/lib/poolparty/modules/definable_resource.rb +1 -1
  28. data/lib/poolparty/modules/method_missing_sugar.rb +12 -4
  29. data/lib/poolparty/modules/pretty_printer.rb +2 -1
  30. data/lib/poolparty/net/remote.rb +1 -1
  31. data/lib/poolparty/net/remote_bases/ec2.rb +13 -10
  32. data/lib/poolparty/net/remote_instance.rb +3 -2
  33. data/lib/poolparty/net/remoter.rb +33 -18
  34. data/lib/poolparty/net/remoter_base.rb +3 -3
  35. data/lib/poolparty/plugins/gem_package.rb +6 -29
  36. data/lib/poolparty/plugins/git.rb +22 -0
  37. data/lib/poolparty/pool/base.rb +7 -6
  38. data/lib/poolparty/pool/cloud.rb +34 -5
  39. data/lib/poolparty/pool/custom_resource.rb +4 -4
  40. data/lib/poolparty/pool/plugin.rb +13 -14
  41. data/lib/poolparty/pool/resource.rb +19 -10
  42. data/lib/poolparty/pool/resources/class_package.rb +10 -6
  43. data/lib/poolparty/pool/resources/conditional.rb +41 -0
  44. data/lib/poolparty/pool/resources/gem.rb +2 -2
  45. data/lib/poolparty/pool/script.rb +25 -2
  46. data/lib/poolparty/templates/haproxy.conf +1 -1
  47. data/lib/poolparty/templates/puppet.conf +4 -2
  48. data/lib/poolparty/version.rb +1 -1
  49. data/poolparty.gemspec +60 -0
  50. data/setup.rb +1585 -0
  51. data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
  52. data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
  53. data/spec/poolparty/bin/console_spec.rb +80 -0
  54. data/spec/poolparty/core/array_spec.rb +26 -0
  55. data/spec/poolparty/core/float.rb +13 -0
  56. data/spec/poolparty/core/hash_spec.rb +63 -0
  57. data/spec/poolparty/core/kernel_spec.rb +24 -0
  58. data/spec/poolparty/core/module_spec.rb +15 -0
  59. data/spec/poolparty/core/object_spec.rb +40 -0
  60. data/spec/poolparty/core/string_spec.rb +152 -0
  61. data/spec/poolparty/core/time_spec.rb +52 -0
  62. data/spec/poolparty/helpers/binary_spec.rb +26 -0
  63. data/spec/poolparty/helpers/display_spec.rb +13 -0
  64. data/spec/poolparty/helpers/optioner_spec.rb +39 -0
  65. data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
  66. data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
  67. data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
  68. data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
  69. data/spec/poolparty/modules/configurable_spec.rb +26 -0
  70. data/spec/poolparty/modules/definable_resource.rb +9 -0
  71. data/spec/poolparty/modules/file_writer_spec.rb +49 -0
  72. data/spec/poolparty/modules/s3_string_spec.rb +15 -0
  73. data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
  74. data/spec/poolparty/net/remote_instance_spec.rb +70 -0
  75. data/spec/poolparty/net/remote_spec.rb +286 -0
  76. data/spec/poolparty/net/remoter_base_spec.rb +80 -0
  77. data/spec/poolparty/net/remoter_spec.rb +191 -0
  78. data/spec/poolparty/plugins/git_spec.rb +19 -0
  79. data/spec/poolparty/plugins/line_spec.rb +16 -0
  80. data/spec/poolparty/plugins/svn_spec.rb +16 -0
  81. data/spec/poolparty/pool/base_spec.rb +108 -0
  82. data/spec/poolparty/pool/cloud_spec.rb +299 -0
  83. data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
  84. data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
  85. data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
  86. data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
  87. data/spec/poolparty/pool/example_spec.rb +112 -0
  88. data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
  89. data/spec/poolparty/pool/plugin_spec.rb +85 -0
  90. data/spec/poolparty/pool/pool_spec.rb +83 -0
  91. data/spec/poolparty/pool/resource_spec.rb +224 -0
  92. data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
  93. data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
  94. data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
  95. data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
  96. data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
  97. data/spec/poolparty/pool/resources/file_spec.rb +40 -0
  98. data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
  99. data/spec/poolparty/pool/resources/host_spec.rb +28 -0
  100. data/spec/poolparty/pool/resources/package_spec.rb +44 -0
  101. data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
  102. data/spec/poolparty/pool/resources/service_spec.rb +45 -0
  103. data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
  104. data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
  105. data/spec/poolparty/pool/script_spec.rb +51 -0
  106. data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
  107. data/spec/poolparty/pool/test_plugins/virtual_host_template.erb +0 -0
  108. data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
  109. data/spec/poolparty/poolparty_spec.rb +33 -0
  110. data/spec/poolparty/spec_helper.rb +120 -0
  111. data/test/test_generator_helper.rb +29 -0
  112. data/test/test_helper.rb +2 -0
  113. data/test/test_pool_spec_generator.rb +47 -0
  114. data/test/test_poolparty.rb +11 -0
  115. data/website/index.html +81 -0
  116. data/website/index.txt +72 -0
  117. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  118. data/website/stylesheets/screen.css +138 -0
  119. data/website/template.html.erb +48 -0
  120. metadata +178 -60
@@ -0,0 +1,52 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Time" do
4
+ describe "parsing" do
5
+ it "should be able to parse seconds" do
6
+ 10.seconds.should == 10
7
+ end
8
+ it "should be able to parse minutes" do
9
+ 80.minutes.should == 4800
10
+ end
11
+ it "should be able to parse hours" do
12
+ 2.hours.should == 7200
13
+ end
14
+ it "should be able to parse days" do
15
+ 1.days.should == 86400
16
+ end
17
+ it "should be able to parse weeks" do
18
+ 2.weeks.should == 1209600
19
+ end
20
+ it "should be able to parse months" do
21
+ 1.month.should == 2678400
22
+ end
23
+ end
24
+ describe "from" do
25
+ it "should be able to find minutes ago" do
26
+ 10.minutes.ago.to_s.should == (Time.new - 10.minutes).to_s
27
+ end
28
+ it "should be able to find from now" do
29
+ 10.minutes.from_now.to_s.should == (Time.now + 10.minutes).to_s
30
+ end
31
+ end
32
+ describe "time_ago string" do
33
+ it "should be able to turn 10.minutes.ago into a string" do
34
+ 10.minutes.time_ago.should == "10 minutes ago"
35
+ end
36
+ it "should be able to turn 30.seconds into Less than a minute ago" do
37
+ 30.seconds.time_ago.should == "Less than a minute ago"
38
+ end
39
+ it "should turn 1.year.ago into 1 year ago" do
40
+ 2.years.time_ago.should == "2 years ago"
41
+ end
42
+ it "should turn 35.days into 35 days ago" do
43
+ 29.days.time_ago.should == "4 weeks ago"
44
+ end
45
+ it "should turn 45.days into 1 month ago" do
46
+ 45.days.time_ago.should == "1 month ago"
47
+ end
48
+ it "should turn 70.days into 2 months ago" do
49
+ 70.days.time_ago.should == "2 months ago"
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/binary'
3
+
4
+ describe "Binary" do
5
+ before(:each) do
6
+ Dir.stub!(:[]).and_return %w(init console)
7
+ end
8
+ it "should have the binary location set on Binary" do
9
+ Binary.binary_directory.should =~ /lib\/poolparty\/helpers\/\.\.\/\.\.\/\.\.\/bin/
10
+ end
11
+ it "should be able to list the binaries in the bin directory" do
12
+ Binary.available_binaries_for("pool").should == %w(console init)
13
+ end
14
+ it "should be able to say the binary is in the binary_directory" do
15
+ Binary.available_binaries_for("pool").include?("console")
16
+ end
17
+ describe "get_existing_spec_location" do
18
+ before(:each) do
19
+ ::File.stub!(:file?).and_return false
20
+ ::File.stub!(:file?).with("#{Base.storage_directory}/pool.spec").and_return true
21
+ end
22
+ it "should be a String" do
23
+ Binary.get_existing_spec_location.class.should == String
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/display'
3
+
4
+ include Display
5
+
6
+ describe "Display" do
7
+ it "should respond to pool_describe" do
8
+ self.respond_to?(:pool_describe).should == true
9
+ end
10
+ it "should be able to get the list of remote bases" do
11
+ self.respond_to?(:available_bases).should == true
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/optioner'
3
+
4
+ describe "Option Parser" do
5
+ describe "options" do
6
+ before(:each) do
7
+ @op = PoolParty::Optioner.new
8
+ @op.parse_options
9
+ end
10
+ it "should set the options as an Hash" do
11
+ @op.options.class.should == Hash
12
+ end
13
+ it "should have the verbose option set to false by default" do
14
+ @op.verbose.should == false
15
+ end
16
+ it "should call a method called on it that is not defined on the options if they exist" do
17
+ @op.options.should_receive(:[]).with(:verbose).once.and_return true
18
+ @op.verbose
19
+ end
20
+ it "should be able to display the version" do
21
+ @op.version.should == PoolParty::VERSION::STRING
22
+ end
23
+ it "should exit after displaying the help message" do
24
+ hide_output do
25
+ lambda {
26
+ @o = PoolParty::Optioner.new(["-h"], {:parse_options => false})
27
+ @o.should_receive(:process_options).once
28
+ @o.parse_options
29
+ }
30
+ end
31
+ end
32
+ end
33
+ it "should be able to take a block and set some options on the block" do
34
+ o = PoolParty::Optioner.new(["-w"], {}) do |opts, optioner|
35
+ opts.on('-w', '--wee') { optioner.wee "wee" }
36
+ end
37
+ o.wee.should == "wee"
38
+ end
39
+ end
@@ -0,0 +1,121 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/provisioner_base'
3
+
4
+ include Provisioner
5
+
6
+ describe "ProvisionerBase" do
7
+ before(:each) do
8
+ @cloud = cloud :app do;end
9
+ @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
10
+ @cloud.stub!(:custom_install_tasks_for).with(@remote_instance).and_return []
11
+ stub_list_from_remote_for(@remote_instance)
12
+ stub_list_from_remote_for(@cloud)
13
+ end
14
+ describe "class methods" do
15
+ it "should have install" do
16
+ ProvisionerBase.respond_to?(:install).should == true
17
+ end
18
+ it "should have configure" do
19
+ ProvisionerBase.respond_to?(:configure).should == true
20
+ end
21
+ end
22
+ describe "tasks" do
23
+ before(:each) do
24
+ class Provisioner::TestProvisioner < Provisioner::ProvisionerBase
25
+ def tasks
26
+ [
27
+ "hello",
28
+ " ",
29
+ "world"
30
+ ]
31
+ end
32
+ end
33
+ @tp = TestProvisioner.new(@remote_instance,@cloud)
34
+ end
35
+ it "should have tasks on the provisioner" do
36
+ ProvisionerBase.new(@remote_instance,@cloud).install_tasks.class.should == Array
37
+ end
38
+ it "should have empty tasks on the provisioner" do
39
+ ProvisionerBase.new(@remote_instance,@cloud).install_tasks.should be_empty
40
+ end
41
+ it "should allow a new class to write tasks that aren't empty upon instantiation" do
42
+ @tp.tasks.should_not be_empty
43
+ end
44
+ it "should have described 3 tasks in the task_list" do
45
+ @tp.tasks.size.should == 3
46
+ end
47
+ end
48
+ it "should return a hash when asking for the installers" do
49
+ ProvisionerBase.installers.class.should == Hash
50
+ end
51
+ it "should not return an empty string when asking for the Ubuntu installer" do
52
+ ProvisionerBase.installers[:ubuntu].should_not be_nil
53
+ end
54
+ it "should be able to fetch the ubuntu installer with the helper method installer" do
55
+ ProvisionerBase.new(@remote_instance,@cloud, "ubuntu").installer_for.should == "apt-get install -y "
56
+ end
57
+ it "should be able to fetch the fedora installer with the helper method installer" do
58
+ ProvisionerBase.new(@remote_instance,@cloud, "fedora").installer_for.should == "yum install "
59
+ end
60
+ describe "install_string" do
61
+ before(:each) do
62
+ class Provisioner::BTestProvisioner < Provisioner::ProvisionerBase
63
+ def install_tasks
64
+ [
65
+ "hello",
66
+ insert_space,
67
+ add_world
68
+ ]
69
+ end
70
+ def insert_space
71
+ " "
72
+ end
73
+ def add_world
74
+ "cruel world"
75
+ end
76
+ def default_install_tasks
77
+ [] << install_tasks
78
+ end
79
+ end
80
+ @provisioner = BTestProvisioner.new(@remote_instance, @cloud)
81
+ end
82
+ it "should not run \"hello\"" do
83
+ @provisioner.should_not_receive(:hello)
84
+ end
85
+ it "should run insert_space" do
86
+ @provisioner.should_receive(:insert_space).once.and_return " "
87
+ end
88
+ it "should run add_world" do
89
+ @provisioner.should_receive(:insert_space).once.and_return "world"
90
+ end
91
+ it "should compound the string to be hello \n \n cruel world" do
92
+ @provisioner.install_string.should == "hello \n \n cruel world"
93
+ end
94
+ after do
95
+ @provisioner.install_string
96
+ end
97
+ describe "processing" do
98
+ before(:each) do
99
+ @provisioner = ProvisionerBase.new(@remote_instance, @cloud)
100
+ stub_list_from_remote_for(@cloud)
101
+ @cloud.stub!(:keypair).and_return "fake_keypair"
102
+ @cloud.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
103
+ Provisioner::Master.stub!(:new).and_return @provisioner
104
+ @cloud.stub!(:copy_file_to_storage_directory).and_return true
105
+ end
106
+ describe "provision_master" do
107
+ it "should call write_install_file" do
108
+ @provisioner.should_receive(:write_install_file).and_return(true)
109
+ end
110
+ it "should call process_install!" do
111
+ @provisioner.should_receive(:process_install!).and_return(true)
112
+ end
113
+ after(:each) do
114
+ hide_output {
115
+ Provisioner.provision_master(@cloud, true)
116
+ }
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../../lib/poolparty/helpers/provisioner_base'
3
+
4
+ include Provisioner
5
+
6
+ describe "Master provisioner" do
7
+ before(:each) do
8
+ @cloud = cloud :app do; end
9
+ stub_list_from_remote_for(@cloud)
10
+ @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
11
+
12
+ @cloud.stub!(:master).and_return @ris.first
13
+ @master = Master.new(@cloud, :ubuntu)
14
+ end
15
+ describe "install_tasks" do
16
+ before(:each) do
17
+ @cloud.stub!(:master).and_return @ris.first
18
+ @master.stub!(:cloud).and_return @cloud
19
+ end
20
+ it "should call install_puppet_master" do
21
+ @master.should_receive(:install_puppet_master)
22
+ end
23
+ it "should call create_local_hosts_entry" do
24
+ @master.should_receive(:create_local_hosts_entry)
25
+ end
26
+ it "should call setup_fileserver" do
27
+ @master.should_receive(:setup_fileserver)
28
+ end
29
+ it "should call create_local_node" do
30
+ @master.should_receive(:create_local_node)
31
+ end
32
+ it "should call the custom_install_tasks" do
33
+ @master.should_receive(:custom_install_tasks)
34
+ end
35
+ after do
36
+ @master.install
37
+ end
38
+ end
39
+ it "should return install_puppet_master as apt-get install puppet factor" do
40
+ @master.install_puppet_master.should =~ /apt-get install -y puppet puppetmaster/
41
+ end
42
+ it "should return setup basic structure" do
43
+ @master.setup_basic_structure.should =~ /puppetmasterd --mkusers/
44
+ end
45
+ it "should return setup_fileserver with the setup" do
46
+ @master.setup_fileserver.should =~ /\[files\]/
47
+ end
48
+ it "should be able to create_local_node" do
49
+ @master.create_local_node.should =~ /ode \"master\"/
50
+ end
51
+ it "should create a node1 node as well" do
52
+ @master.create_local_node.should =~ /ode \"node1\"/
53
+ end
54
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../../../lib/poolparty/helpers/provisioner_base'
3
+
4
+ include Provisioner
5
+
6
+ describe "Slave provisioner" do
7
+ before(:each) do
8
+
9
+ @cloud = cloud :app do; end
10
+ @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
11
+ stub_list_from_remote_for(@cloud)
12
+
13
+ @cloud.stub!(:master).and_return @ris.first
14
+
15
+ @slave = Slave.new(@remote_instance, @cloud, :ubuntu)
16
+ end
17
+ describe "install_tasks" do
18
+ it "should call install_puppet_slave" do
19
+ @slave.should_receive(:install_puppet)
20
+ end
21
+ after do
22
+ @slave.install
23
+ end
24
+ end
25
+ it "should return install_puppet as apt-get install puppet factor" do
26
+ @slave.install_puppet.should =~ / apt-get install -y puppet puppetmaster/
27
+ end
28
+ end
@@ -0,0 +1,135 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ class ResourcerTestClass
4
+ include CloudResourcer
5
+ include Configurable
6
+
7
+ def initialize(&block)
8
+ store_block(&block) if block
9
+ end
10
+
11
+ # Stub keypair
12
+ def keypair
13
+ "rangerbob"
14
+ end
15
+ end
16
+ class TestParentClass
17
+ def options
18
+ {}
19
+ end
20
+ def services
21
+ @services ||= []
22
+ end
23
+ def add_service(s)
24
+ services << s
25
+ end
26
+ end
27
+ describe "CloudResourcer" do
28
+ before(:each) do
29
+ @tc = ResourcerTestClass.new
30
+ end
31
+ it "should have the method instances" do
32
+ @tc.respond_to?(:instances).should == true
33
+ end
34
+ it "should be able to accept a range and set the first to the minimum instances" do
35
+ @tc.instances 4..10
36
+ @tc.minimum_instances.should == 4
37
+ end
38
+ it "should set the max to the maximum instances to the last" do
39
+ @tc.instances 4..10
40
+ @tc.maximum_instances.should == 10
41
+ end
42
+ describe "keypair_path" do
43
+ before(:each) do
44
+ end
45
+ it "should look for the file in the known directories it should reside in" do
46
+ @tc.should_receive(:keypair_paths).once.and_return []
47
+ @tc.keypair_path
48
+ end
49
+ it "should see if the file exists" do
50
+ @t = "#{File.expand_path(Base.base_keypair_path)}"
51
+ ::File.should_receive(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
52
+ ::File.stub!(:exists?).with(@t+"/rangerbob").and_return false
53
+ @tc.should_receive(:keypair_paths).once.and_return [@t]
54
+ @tc.keypair_path
55
+ end
56
+ it "should fallback to the second one if the first doesn't exist" do
57
+ @t = "#{File.expand_path(Base.base_keypair_path)}"
58
+ @q = "#{File.expand_path(Base.base_config_directory)}"
59
+ ::File.stub!(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
60
+ ::File.stub!(:exists?).with(@t+"/rangerbob").and_return false
61
+ ::File.stub!(:exists?).with(@q+"/id_rsa-rangerbob").and_return false
62
+ ::File.should_receive(:exists?).with(@q+"/rangerbob").and_return true
63
+ @tc.should_receive(:keypair_paths).once.and_return [@t, @q]
64
+ @tc.keypair_path.should == "/etc/poolparty/rangerbob"
65
+ end
66
+ describe "exists" do
67
+ before(:each) do
68
+ @t = "#{File.expand_path(Base.base_keypair_path)}"
69
+ ::File.stub!(:exists?).with(@t+"/id_rsa-rangerbob").and_return false
70
+ ::File.stub!(:exists?).with(@t+"/rangerbob").and_return true
71
+ end
72
+ it "should have the keypair_path" do
73
+ @tc.respond_to?(:keypair_path).should == true
74
+ end
75
+ it "should set the keypair to the Base.keypair_path" do
76
+ @tc.keypair_path.should =~ /#{File.expand_path(Base.base_keypair_path)}/
77
+ end
78
+ it "should set the keypair to have the keypair set" do
79
+ @tc.keypair.should =~ /rangerbob/
80
+ end
81
+ it "should set it to the Base keypair_path and the keypair" do
82
+ @tc.keypair_path.should == "#{File.expand_path(Base.base_keypair_path)}/#{@tc.keypair}"
83
+ end
84
+ end
85
+ end
86
+ it "should provide set_parent" do
87
+ @tc.respond_to?(:set_parent).should == true
88
+ end
89
+ describe "parents" do
90
+ before(:each) do
91
+ @testparent = TestParentClass.new
92
+ end
93
+ describe "setting" do
94
+ it "should add the child to its services" do
95
+ @testparent.should_receive(:add_service)
96
+ end
97
+ it "should call configure with options" do
98
+ @tc.should_receive(:configure).with(@testparent.options)
99
+ end
100
+ after do
101
+ @tc.set_parent(@testparent)
102
+ end
103
+ end
104
+ describe "parent's services" do
105
+ before(:each) do
106
+ @tc.set_parent(@testparent)
107
+ end
108
+ it "should set the parent" do
109
+ @tc.parent.should == @testparent
110
+ end
111
+ it "should have one service set" do
112
+ @testparent.services.size.should == 1
113
+ end
114
+ it "should have the child in the parent's services" do
115
+ @testparent.services.first.should == @tc
116
+ end
117
+ end
118
+ describe "storing block" do
119
+ before(:each) do
120
+ @new_tc = ResourcerTestClass.new do
121
+ "hi"
122
+ end
123
+ end
124
+ it "should store the block when creating a new one" do
125
+ @new_tc.store_block.should_not == nil
126
+ end
127
+ it "should have a reference to the stored block" do
128
+ @new_tc.store_block.class.should == Proc
129
+ end
130
+ it "should store the containing block" do
131
+ @new_tc.store_block.call.should == "hi"
132
+ end
133
+ end
134
+ end
135
+ end