spec/archive/setup_spec.rb in heirloom-0.12.1 vs spec/archive/setup_spec.rb in heirloom-0.12.2

- old
+ new

@@ -1,64 +1,64 @@ require 'spec_helper' describe Heirloom do before do - @logger_stub = stub 'logger', :debug => true, :info => true - @config_mock = mock 'config' - @config_mock.stub :logger => @logger_stub, :metadata_region => 'us-west-1' - @verifier_mock = mock 'verifier' + @logger_double = double 'logger', :debug => true, :info => true + @config_double = double 'config' + @config_double.stub :logger => @logger_double, :metadata_region => 'us-west-1' + @verifier_double = double 'verifier' Heirloom::Verifier.should_receive(:new). - with(:config => @config_mock, + with(:config => @config_double, :name => 'archive'). - and_return @verifier_mock - @setuper = Heirloom::Setuper.new :config => @config_mock, + and_return @verifier_double + @setuper = Heirloom::Setuper.new :config => @config_double, :name => 'archive' end context "creating domains" do before do - @verifier_mock.stub :bucket_exists? => true + @verifier_double.stub :bucket_exists? => true end it "should create the domain if it does not exist" do - @sdb_mock = mock 'sdb' + @sdb_double = double 'sdb' Heirloom::AWS::SimpleDB.should_receive(:new). - with(:config => @config_mock). - and_return @sdb_mock - @verifier_mock.stub :domain_exists? => false - @sdb_mock.should_receive(:create_domain).with 'heirloom_archive' + with(:config => @config_double). + and_return @sdb_double + @verifier_double.stub :domain_exists? => false + @sdb_double.should_receive(:create_domain).with 'heirloom_archive' @setuper.setup :regions => ['us-west-1'], :bucket_prefix => 'bp' - + end it "should not create the domain if alrady exists" do - @verifier_mock.stub :domain_exists? => true + @verifier_double.stub :domain_exists? => true @setuper.setup :regions => ['us-west-1'], :bucket_prefix => 'bp' end end context "creating buckets" do before do - @verifier_mock.stub :domain_exists? => true + @verifier_double.stub :domain_exists? => true end it "should create required buckets that don't exist" do - @verifier_mock.should_receive(:bucket_exists?). - with(:region => "us-west-1", :bucket_prefix => "bp"). - and_return true - @verifier_mock.should_receive(:bucket_exists?). - with(:region => "us-east-1", :bucket_prefix => "bp"). - and_return false - @s3_mock = mock 's3' + @verifier_double.should_receive(:bucket_exists?). + with(:region => "us-west-1", :bucket_prefix => "bp"). + and_return true + @verifier_double.should_receive(:bucket_exists?). + with(:region => "us-east-1", :bucket_prefix => "bp"). + and_return false + @s3_double = double 's3' Heirloom::AWS::S3.should_receive(:new). - with(:config => @config_mock, + with(:config => @config_double, :region => 'us-east-1'). - and_return @s3_mock - @s3_mock.should_receive(:put_bucket). - with 'bp-us-east-1', 'us-east-1' + and_return @s3_double + @s3_double.should_receive(:put_bucket). + with 'bp-us-east-1', 'us-east-1' @setuper.setup :regions => ['us-west-1', 'us-east-1'], :bucket_prefix => 'bp' end end