From fe6b50e0383af01023f010b26cd1cf2fa2f3c9c4 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 21 Jun 2010 09:30:30 -0700 Subject: just getting started with unit tests for sudo. --- spec/unit/puppet/util/ec2.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/unit/puppet/util/ec2.rb (limited to 'spec/unit/puppet/util') 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 -- cgit v1.2.3