summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/util/ec2.rb
diff options
context:
space:
mode:
authorDan Bode <dan@puppetlabs.com>2010-06-21 09:30:30 -0700
committerDan Bode <dan@puppetlabs.com>2010-06-21 09:30:30 -0700
commitfe6b50e0383af01023f010b26cd1cf2fa2f3c9c4 (patch)
tree00ddb55d3da661be666105cdfa9b7bdc8629f056 /spec/unit/puppet/util/ec2.rb
parent38e373fc67ff7447eb1052a40979d1e9df5934ba (diff)
just getting started with unit tests for sudo.
Diffstat (limited to 'spec/unit/puppet/util/ec2.rb')
-rw-r--r--spec/unit/puppet/util/ec2.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/puppet/util/ec2.rb b/spec/unit/puppet/util/ec2.rb
new file mode 100644
index 0000000..c8757ee
--- /dev/null
+++ b/spec/unit/puppet/util/ec2.rb
@@ -0,0 +1,34 @@
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/util/ec2'
+
+class Ec2Helper
+ include Puppet::Util::Ec2
+end
+
+# LAK: This way the constants exist, but I expect we'll regret this
+unless Puppet.features.aws?
+ class AWS
+ class EC2
+ class Base
+ end
+ end
+ end
+end
+
+describe Puppet::Util::Ec2 do
+ before do
+ @helper = Ec2Helper.new
+ end
+
+ it "should use AWS::Base to create an EC2 connection" do
+ AWS::EC2::Base.expects(:new).with(:access_key_id => "myuser", :secret_access_key => "mypass")
+ @helper.ec2_connection("myuser", "mypass")
+ end
+
+ it "should call foo and bar when calling baz" do
+ @helper.stubs(:foo).returns "yay"
+ @helper.expects(:bar).with("yay").returns "yip"
+ @helper.baz.should == "yip"
+ end
+end