auser-poolparty 0.2.70 → 0.2.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +21 -1
- data/PostInstall.txt +1 -1
- data/lib/poolparty/core/class.rb +24 -0
- data/lib/poolparty/core/module.rb +2 -2
- data/lib/poolparty/dependency_resolutions/puppet.rb +9 -2
- data/lib/poolparty/helpers/provisioners/master.rb +1 -6
- data/lib/poolparty/plugins/deploydirectory.rb +5 -1
- data/lib/poolparty/pool/cloud.rb +2 -1
- data/lib/poolparty/pool/resource.rb +8 -5
- data/lib/poolparty/pool/script.rb +1 -1
- data/lib/poolparty/spec/core/string.rb +10 -0
- data/lib/poolparty/spec/matchers/a_spec_extensions_base.rb +24 -0
- data/lib/poolparty/spec/matchers/have_cron.rb +28 -0
- data/lib/poolparty/spec/matchers/have_deploydirectory.rb +15 -0
- data/lib/poolparty/spec/matchers/have_directory.rb +31 -0
- data/lib/poolparty/spec/matchers/have_exec.rb +28 -0
- data/lib/poolparty/spec/matchers/have_file.rb +28 -0
- data/lib/poolparty/spec/matchers/have_gempackage.rb +28 -0
- data/lib/poolparty/spec/matchers/have_git.rb +28 -0
- data/lib/poolparty/spec/matchers/have_host.rb +28 -0
- data/lib/poolparty/spec/matchers/have_mount.rb +28 -0
- data/lib/poolparty/spec/matchers/have_package.rb +28 -0
- data/lib/poolparty/spec/matchers/have_remotefile.rb +28 -0
- data/lib/poolparty/spec/matchers/have_rsyncmirror.rb +28 -0
- data/lib/poolparty/spec/matchers/have_service.rb +28 -0
- data/lib/poolparty/spec/matchers/have_sshkey.rb +28 -0
- data/lib/poolparty/spec/matchers/have_symlink.rb +28 -0
- data/lib/poolparty/spec/matchers/have_variable.rb +32 -0
- data/lib/poolparty/spec/spec/dynamic_matchers.rb +63 -0
- data/lib/poolparty/spec/spec/ensure_matchers_exist.rb +7 -0
- data/lib/poolparty/spec/{have_base.rb → templates/have_base.rb} +5 -6
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolpartyspec.rb +11 -17
- data/poolparty.gemspec +599 -61
- data/website/index.html +1 -1
- metadata +28 -4
@@ -0,0 +1,63 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
require "#{::File.dirname(__FILE__)}/../matchers/a_spec_extensions_base.rb"
|
4
|
+
class Object
|
5
|
+
# For all of the available_resources, write the matcher template
|
6
|
+
# based on the have_base base and write the method have_
|
7
|
+
# for each of the resources available
|
8
|
+
def write_dynamic_matchers
|
9
|
+
PoolParty::Resources::Resource.available_resources.each do |ty|
|
10
|
+
ty.downcase!
|
11
|
+
filename = "#{::File.dirname(__FILE__)}/../matchers/have_#{ty}.rb"
|
12
|
+
unless ::File.file?(filename)
|
13
|
+
str = make_dynamic_matcher_string_for(ty)
|
14
|
+
::File.open(filename, "w+") {|f| f << str}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
# Create a dynamic matcher
|
19
|
+
# Create a matcher for spec based in the context called from
|
20
|
+
# Usage example:
|
21
|
+
# dynamic_matcher_for(:virtualhost) do
|
22
|
+
# set_description "should have virtualhost"
|
23
|
+
# it "should have the directory /var/www" do
|
24
|
+
# have_directory("/var/www")
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# This creates a method by the name of the dynamic matcher
|
28
|
+
# so in the above example for virtualhost, the
|
29
|
+
# method have_virtualhost(name) &block is created in the spec
|
30
|
+
# context and can be called from within the describe/context
|
31
|
+
# in a spec
|
32
|
+
def dynamic_matcher_for(ty, &block)
|
33
|
+
name = "#{ty}".camelcase
|
34
|
+
|
35
|
+
begin
|
36
|
+
const = Object.const_set(name, Spec::Example::SharedExampleGroup.register(name.to_sym, &block))
|
37
|
+
rescue NameError => e
|
38
|
+
raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
described_type = "#{ty.to_s.underscore.downcase}"
|
42
|
+
|
43
|
+
::Spec::Example::ExampleGroupMethods.module_eval <<-EOM
|
44
|
+
def have_#{ty.to_s.underscore.downcase}(*args)
|
45
|
+
include #{const}
|
46
|
+
self.module_eval "@@described_type = args;def #{described_type}; @@described_type; end"
|
47
|
+
end
|
48
|
+
EOM
|
49
|
+
end
|
50
|
+
# Load the have_base file and fill in the variables for the
|
51
|
+
# have_base base template
|
52
|
+
def make_dynamic_matcher_string_for(ty, matcher="is_present?")
|
53
|
+
@basestr ||= open("#{::File.dirname(__FILE__)}/../templates/have_base.rb").read
|
54
|
+
typestring = ty.to_s
|
55
|
+
begin
|
56
|
+
@basestr ^ {:classname => "Have#{typestring.capitalize}",
|
57
|
+
:type => typestring,
|
58
|
+
:matches => matcher,
|
59
|
+
:includer => "SpecExtensions::Have#{typestring.capitalize}.new(name, extra)"}
|
60
|
+
rescue Exception => e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module Spec
|
2
2
|
module Matchers
|
3
3
|
module SpecExtensions
|
4
|
-
class :classname
|
4
|
+
class :classname < SpecExtensionsBase
|
5
5
|
def initialize(expected,extra="")
|
6
6
|
@expected = expected
|
7
7
|
@extra = extra
|
8
8
|
end
|
9
9
|
def matches?(target)
|
10
10
|
@target = target
|
11
|
-
|
12
|
-
# @target =~ :matcher
|
11
|
+
:matches
|
13
12
|
end
|
14
13
|
def failure_message
|
15
14
|
"expected #{@target.inspect} to have :type #{@expected}"
|
@@ -17,13 +16,13 @@ module Spec
|
|
17
16
|
def negative_failure_message
|
18
17
|
"expected #{@target.inspect} not to have :type #{@expected}"
|
19
18
|
end
|
19
|
+
def type
|
20
|
+
":type"
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
def have_:type(name, extra="")
|
23
25
|
:includer
|
24
26
|
end
|
25
|
-
def not_have_:type(name, extra="")
|
26
|
-
:includer
|
27
|
-
end
|
28
27
|
end
|
29
28
|
end
|
data/lib/poolparty/version.rb
CHANGED
data/lib/poolpartyspec.rb
CHANGED
@@ -1,25 +1,12 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "spec"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
PoolParty::Resources::Resource.available_resources.each do |ty|
|
7
|
-
ty.downcase!
|
8
|
-
str = @basestr ^ {:classname => "Have#{ty.capitalize}",
|
9
|
-
:type => ty,
|
10
|
-
:includer => "SpecExtensions::Have#{ty.capitalize}.new(name, extra)"}
|
11
|
-
eval str
|
3
|
+
["core", "spec"].each do |dir|
|
4
|
+
Dir[File.join(File.dirname(__FILE__), "poolparty", "spec", dir, "*.rb")].each {|f| require f}
|
12
5
|
end
|
13
6
|
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
class TestCloudClass < PoolParty::Cloud::Cloud
|
18
|
-
def initialize(name,opts={}, &block)
|
19
|
-
reset_resources!
|
20
|
-
super
|
21
|
-
end
|
7
|
+
class TestCloudClass < PoolParty::Cloud::Cloud
|
22
8
|
def build_test_manifest
|
9
|
+
reset_resources!
|
23
10
|
realize_plugins!(true)
|
24
11
|
|
25
12
|
returning Array.new do |arr|
|
@@ -39,4 +26,11 @@ end
|
|
39
26
|
|
40
27
|
def new_test_cloud(&block)
|
41
28
|
TestCloudClass.new(:test_cloud, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_test_cloud(name, poolfile=nil)
|
32
|
+
PoolParty::Script.inflate_file poolfile
|
33
|
+
blk = cloud(name).stored_block.dup
|
34
|
+
PoolParty::Pool.reset!
|
35
|
+
new_test_cloud &blk
|
42
36
|
end
|