heirloom 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +6 -0
  5. data/README.md +12 -6
  6. data/heirloom.gemspec +3 -5
  7. data/lib/heirloom/catalog/verify.rb +2 -2
  8. data/lib/heirloom/cli/authorize.rb +1 -2
  9. data/lib/heirloom/cli/catalog.rb +62 -19
  10. data/lib/heirloom/cli/cleanup.rb +1 -2
  11. data/lib/heirloom/cli/destroy.rb +1 -2
  12. data/lib/heirloom/cli/download.rb +2 -3
  13. data/lib/heirloom/cli/formatter/catalog.rb +25 -11
  14. data/lib/heirloom/cli/list.rb +1 -3
  15. data/lib/heirloom/cli/rotate.rb +1 -2
  16. data/lib/heirloom/cli/setup.rb +1 -2
  17. data/lib/heirloom/cli/shared.rb +3 -0
  18. data/lib/heirloom/cli/show.rb +1 -3
  19. data/lib/heirloom/cli/tag.rb +1 -2
  20. data/lib/heirloom/cli/teardown.rb +1 -2
  21. data/lib/heirloom/cli/upload.rb +1 -2
  22. data/lib/heirloom/version.rb +1 -1
  23. data/spec/acl/s3_spec.rb +11 -11
  24. data/spec/archive/authorizer_spec.rb +20 -20
  25. data/spec/archive/builder_spec.rb +13 -13
  26. data/spec/archive/checker_spec.rb +24 -24
  27. data/spec/archive/destroyer_spec.rb +20 -20
  28. data/spec/archive/downloader_spec.rb +30 -30
  29. data/spec/archive/lister_spec.rb +7 -7
  30. data/spec/archive/reader_spec.rb +65 -65
  31. data/spec/archive/setup_spec.rb +27 -27
  32. data/spec/archive/teardowner_spec.rb +19 -19
  33. data/spec/archive/updater_spec.rb +10 -10
  34. data/spec/archive/uploader_spec.rb +26 -26
  35. data/spec/archive/verifier_spec.rb +25 -25
  36. data/spec/archive/writer_spec.rb +11 -11
  37. data/spec/archive_spec.rb +91 -93
  38. data/spec/aws/s3_spec.rb +102 -102
  39. data/spec/aws/simpledb_spec.rb +33 -63
  40. data/spec/catalog/add_spec.rb +12 -12
  41. data/spec/catalog/delete_spec.rb +14 -14
  42. data/spec/catalog/list_spec.rb +8 -8
  43. data/spec/catalog/setup_spec.rb +11 -11
  44. data/spec/catalog/show_spec.rb +13 -13
  45. data/spec/catalog/verify_spec.rb +16 -16
  46. data/spec/catalog_spec.rb +36 -36
  47. data/spec/cipher/data_spec.rb +19 -19
  48. data/spec/cipher/file_spec.rb +11 -11
  49. data/spec/cli/authorize_spec.rb +16 -16
  50. data/spec/cli/catalog_spec.rb +18 -34
  51. data/spec/cli/destroy_spec.rb +13 -13
  52. data/spec/cli/download_spec.rb +31 -31
  53. data/spec/cli/formatter/catalog_spec.rb +19 -17
  54. data/spec/cli/list_spec.rb +14 -14
  55. data/spec/cli/rotate_spec.rb +9 -9
  56. data/spec/cli/setup_spec.rb +29 -29
  57. data/spec/cli/shared_spec.rb +119 -119
  58. data/spec/cli/show_spec.rb +20 -20
  59. data/spec/cli/tag_spec.rb +18 -18
  60. data/spec/cli/teardown_spec.rb +28 -28
  61. data/spec/cli/upload_spec.rb +38 -38
  62. data/spec/config_spec.rb +21 -21
  63. data/spec/destroyer/s3_spec.rb +6 -6
  64. data/spec/directory/directory_spec.rb +19 -19
  65. data/spec/downloader/s3_spec.rb +18 -18
  66. data/spec/logger_spec.rb +9 -9
  67. data/spec/spec_helper.rb +4 -80
  68. data/spec/uploader/s3_spec.rb +35 -35
  69. metadata +23 -56
  70. data/spec/integration/authorize_spec.rb +0 -79
  71. data/spec/integration/cleanup_spec.rb +0 -77
  72. data/watchr.rb +0 -101
@@ -3,37 +3,37 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @logger_stub = stub 'logger', :debug => true, :info => true
7
- @config_mock = mock 'config'
8
- @config_mock.stub :logger => @logger_stub, :metadata_region => 'us-west-1'
9
- @verifier_mock = mock 'verifier'
6
+ @logger_double = double 'logger', :debug => true, :info => true
7
+ @config_double = double 'config'
8
+ @config_double.stub :logger => @logger_double, :metadata_region => 'us-west-1'
9
+ @verifier_double = double 'verifier'
10
10
  Heirloom::Verifier.should_receive(:new).
11
- with(:config => @config_mock,
11
+ with(:config => @config_double,
12
12
  :name => 'archive').
13
- and_return @verifier_mock
14
- @setuper = Heirloom::Setuper.new :config => @config_mock,
13
+ and_return @verifier_double
14
+ @setuper = Heirloom::Setuper.new :config => @config_double,
15
15
  :name => 'archive'
16
16
  end
17
17
 
18
18
  context "creating domains" do
19
19
  before do
20
- @verifier_mock.stub :bucket_exists? => true
20
+ @verifier_double.stub :bucket_exists? => true
21
21
  end
22
22
 
23
23
  it "should create the domain if it does not exist" do
24
- @sdb_mock = mock 'sdb'
24
+ @sdb_double = double 'sdb'
25
25
  Heirloom::AWS::SimpleDB.should_receive(:new).
26
- with(:config => @config_mock).
27
- and_return @sdb_mock
28
- @verifier_mock.stub :domain_exists? => false
29
- @sdb_mock.should_receive(:create_domain).with 'heirloom_archive'
26
+ with(:config => @config_double).
27
+ and_return @sdb_double
28
+ @verifier_double.stub :domain_exists? => false
29
+ @sdb_double.should_receive(:create_domain).with 'heirloom_archive'
30
30
  @setuper.setup :regions => ['us-west-1'],
31
31
  :bucket_prefix => 'bp'
32
-
32
+
33
33
  end
34
34
 
35
35
  it "should not create the domain if alrady exists" do
36
- @verifier_mock.stub :domain_exists? => true
36
+ @verifier_double.stub :domain_exists? => true
37
37
  @setuper.setup :regions => ['us-west-1'],
38
38
  :bucket_prefix => 'bp'
39
39
  end
@@ -41,23 +41,23 @@ describe Heirloom do
41
41
 
42
42
  context "creating buckets" do
43
43
  before do
44
- @verifier_mock.stub :domain_exists? => true
44
+ @verifier_double.stub :domain_exists? => true
45
45
  end
46
46
 
47
47
  it "should create required buckets that don't exist" do
48
- @verifier_mock.should_receive(:bucket_exists?).
49
- with(:region => "us-west-1", :bucket_prefix => "bp").
50
- and_return true
51
- @verifier_mock.should_receive(:bucket_exists?).
52
- with(:region => "us-east-1", :bucket_prefix => "bp").
53
- and_return false
54
- @s3_mock = mock 's3'
48
+ @verifier_double.should_receive(:bucket_exists?).
49
+ with(:region => "us-west-1", :bucket_prefix => "bp").
50
+ and_return true
51
+ @verifier_double.should_receive(:bucket_exists?).
52
+ with(:region => "us-east-1", :bucket_prefix => "bp").
53
+ and_return false
54
+ @s3_double = double 's3'
55
55
  Heirloom::AWS::S3.should_receive(:new).
56
- with(:config => @config_mock,
56
+ with(:config => @config_double,
57
57
  :region => 'us-east-1').
58
- and_return @s3_mock
59
- @s3_mock.should_receive(:put_bucket).
60
- with 'bp-us-east-1', 'us-east-1'
58
+ and_return @s3_double
59
+ @s3_double.should_receive(:put_bucket).
60
+ with 'bp-us-east-1', 'us-east-1'
61
61
  @setuper.setup :regions => ['us-west-1', 'us-east-1'],
62
62
  :bucket_prefix => 'bp'
63
63
  end
@@ -3,39 +3,39 @@ require 'spec_helper'
3
3
  describe Heirloom::Teardowner do
4
4
  before do
5
5
  @regions = ['us-west-1', 'us-west-2']
6
- @logger_stub = stub 'logger', :info => true, :debug => true
7
- @config_stub = stub 'config', :logger => @logger_stub,
8
- :metadata_region => 'us-west-1'
9
- @verifier_stub = stub :bucket_exists? => true,
10
- :domain_exists? => true
11
- @teardowner = Heirloom::Teardowner.new :config => @config_stub,
6
+ @logger_double = double 'logger', :info => true, :debug => true
7
+ @config_double = double 'config', :logger => @logger_double,
8
+ :metadata_region => 'us-west-1'
9
+ @verifier_double = double :bucket_exists? => true,
10
+ :domain_exists? => true
11
+ @teardowner = Heirloom::Teardowner.new :config => @config_double,
12
12
  :name => 'archive'
13
- Heirloom::Verifier.stub :new => @verifier_stub
13
+ Heirloom::Verifier.stub :new => @verifier_double
14
14
  end
15
15
 
16
16
  it "should delete the buckets" do
17
- @s3_mock1 = mock 's31'
18
- @s3_mock2 = mock 's32'
17
+ @s3_double1 = double 's31'
18
+ @s3_double2 = double 's32'
19
19
  Heirloom::AWS::S3.should_receive(:new).
20
- with(:config => @config_stub,
20
+ with(:config => @config_double,
21
21
  :region => 'us-west-1').
22
- and_return @s3_mock1
22
+ and_return @s3_double1
23
23
  Heirloom::AWS::S3.should_receive(:new).
24
- with(:config => @config_stub,
24
+ with(:config => @config_double,
25
25
  :region => 'us-west-2').
26
- and_return @s3_mock2
27
- @s3_mock1.should_receive(:delete_bucket).with('bp-us-west-1')
28
- @s3_mock2.should_receive(:delete_bucket).with('bp-us-west-2')
26
+ and_return @s3_double2
27
+ @s3_double1.should_receive(:delete_bucket).with('bp-us-west-1')
28
+ @s3_double2.should_receive(:delete_bucket).with('bp-us-west-2')
29
29
  @teardowner.delete_buckets :regions => @regions,
30
30
  :bucket_prefix => 'bp'
31
31
  end
32
32
 
33
33
  it "should delete the domain" do
34
- @sdb_mock = mock 'sdb'
34
+ @sdb_double = double 'sdb'
35
35
  Heirloom::AWS::SimpleDB.should_receive(:new).
36
- with(:config => @config_stub).
37
- and_return @sdb_mock
38
- @sdb_mock.should_receive(:delete_domain).
36
+ with(:config => @config_double).
37
+ and_return @sdb_double
38
+ @sdb_double.should_receive(:delete_domain).
39
39
  with 'heirloom_archive'
40
40
  @teardowner.delete_domain
41
41
  end
@@ -3,22 +3,22 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = double 'config'
7
- @logger_mock = double 'logger'
8
- @config_mock.should_receive(:logger).and_return(@logger_mock)
9
- @updater = Heirloom::Updater.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger'
8
+ @config_double.should_receive(:logger).and_return(@logger_double)
9
+ @updater = Heirloom::Updater.new :config => @config_double,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
12
  end
13
13
 
14
14
  it "should test an attribute is updated" do
15
- sdb_mock = mock 'sdb mock'
16
- @logger_mock.should_receive(:info)
15
+ sdb_double = double 'sdb mock'
16
+ @logger_double.should_receive(:info)
17
17
  Heirloom::AWS::SimpleDB.should_receive(:new).
18
- with(:config => @config_mock).
19
- and_return sdb_mock
20
- sdb_mock.should_receive(:put_attributes).
21
- with('heirloom_tim', '123', { 'attr' => 'val' }, { :replace => 'attr' })
18
+ with(:config => @config_double).
19
+ and_return sdb_double
20
+ sdb_double.should_receive(:put_attributes).
21
+ with('heirloom_tim', '123', { 'attr' => 'val' }, { :replace => 'attr' })
22
22
  @updater.update :attribute => 'attr',
23
23
  :value => 'val'
24
24
  end
@@ -3,22 +3,22 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = mock 'config'
7
- @logger_stub = stub 'logger', :info => true
8
- @config_mock.stub :logger => @logger_stub
9
- @uploader = Heirloom::Uploader.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger', :info => true
8
+ @config_double.stub :logger => @logger_double
9
+ @uploader = Heirloom::Uploader.new :config => @config_double,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
- @s3_mock = mock 's3'
12
+ @s3_double = double 's3'
13
13
  end
14
14
 
15
15
  it "should upload a new archive" do
16
16
  Heirloom::Uploader::S3.should_receive(:new).
17
- with(:config => @config_mock,
18
- :logger => @logger_stub,
17
+ with(:config => @config_double,
18
+ :logger => @logger_double,
19
19
  :region => 'us-west-1').
20
- and_return @s3_mock
21
- @s3_mock.should_receive(:upload_file).
20
+ and_return @s3_double
21
+ @s3_double.should_receive(:upload_file).
22
22
  with(:bucket => 'prefix-us-west-1',
23
23
  :file => '/tmp/file',
24
24
  :id => '123',
@@ -26,7 +26,7 @@ describe Heirloom do
26
26
  :key_name => "123.tar.gz",
27
27
  :name => 'tim',
28
28
  :public_readable => true)
29
- @s3_mock.should_receive(:add_endpoint_attributes).
29
+ @s3_double.should_receive(:add_endpoint_attributes).
30
30
  with(:bucket => 'prefix-us-west-1',
31
31
  :id => '123',
32
32
  :key_name => '123.tar.gz',
@@ -40,23 +40,23 @@ describe Heirloom do
40
40
 
41
41
  it "should upload a new archive with .gpg if secret provided" do
42
42
  Heirloom::Uploader::S3.should_receive(:new).
43
- with(:config => @config_mock,
44
- :logger => @logger_stub,
43
+ with(:config => @config_double,
44
+ :logger => @logger_double,
45
45
  :region => 'us-west-1').
46
- and_return @s3_mock
47
- @s3_mock.should_receive(:upload_file).
48
- with(:bucket => 'prefix-us-west-1',
49
- :file => '/tmp/file',
50
- :id => '123',
51
- :key_folder => 'tim',
52
- :key_name => "123.tar.gz.gpg",
53
- :name => 'tim',
54
- :public_readable => true)
55
- @s3_mock.should_receive(:add_endpoint_attributes).
56
- with(:bucket => 'prefix-us-west-1',
57
- :id => '123',
58
- :key_name => '123.tar.gz.gpg',
59
- :name => 'tim')
46
+ and_return @s3_double
47
+ @s3_double.should_receive(:upload_file).
48
+ with(:bucket => 'prefix-us-west-1',
49
+ :file => '/tmp/file',
50
+ :id => '123',
51
+ :key_folder => 'tim',
52
+ :key_name => "123.tar.gz.gpg",
53
+ :name => 'tim',
54
+ :public_readable => true)
55
+ @s3_double.should_receive(:add_endpoint_attributes).
56
+ with(:bucket => 'prefix-us-west-1',
57
+ :id => '123',
58
+ :key_name => '123.tar.gz.gpg',
59
+ :name => 'tim')
60
60
  @uploader.upload :file => '/tmp/file',
61
61
  :bucket_prefix => 'prefix',
62
62
  :regions => ['us-west-1'],
@@ -3,41 +3,41 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = double 'config'
7
- @logger_stub = stub 'logger', :debug => true, :info => true
8
- @s3_mock = double 's3_mock'
9
- @config_mock.stub :logger => @logger_stub
10
- @verifier = Heirloom::Verifier.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger', :debug => true, :info => true
8
+ @s3_double = double 's3_double'
9
+ @config_double.stub :logger => @logger_double
10
+ @verifier = Heirloom::Verifier.new :config => @config_double,
11
11
  :name => 'heirloom-name'
12
12
  end
13
13
 
14
14
  context "verifying all buckets exist" do
15
15
  before do
16
16
  Heirloom::AWS::S3.should_receive(:new).
17
- with(:config => @config_mock,
17
+ with(:config => @config_double,
18
18
  :region => 'us-west-1').
19
- and_return @s3_mock
19
+ and_return @s3_double
20
20
  Heirloom::AWS::S3.should_receive(:new).
21
- with(:config => @config_mock,
21
+ with(:config => @config_double,
22
22
  :region => 'us-east-1').
23
- and_return @s3_mock
23
+ and_return @s3_double
24
24
  end
25
25
 
26
26
  it "should return false if a bucket does not exist in a region" do
27
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-west-1').
28
- and_return nil
29
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-east-1').
30
- and_return 'an s3 bucket'
27
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-west-1').
28
+ and_return nil
29
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-east-1').
30
+ and_return 'an s3 bucket'
31
31
  @verifier.buckets_exist?(:bucket_prefix => 'bucket123',
32
32
  :regions => ['us-west-1', 'us-east-1']).
33
33
  should be_false
34
34
  end
35
35
 
36
36
  it "should true if all buckets exist" do
37
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-west-1').
38
- and_return 'an s3 bucket'
39
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-east-1').
40
- and_return 'an s3 bucket'
37
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-west-1').
38
+ and_return 'an s3 bucket'
39
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-east-1').
40
+ and_return 'an s3 bucket'
41
41
  @verifier.buckets_exist?(:bucket_prefix => 'bucket123',
42
42
  :regions => ['us-west-1', 'us-east-1']).
43
43
  should be_true
@@ -47,22 +47,22 @@ describe Heirloom do
47
47
  context "verifying a single bucket exist" do
48
48
  it "should return true if the given bucket does not exist in the region" do
49
49
  Heirloom::AWS::S3.should_receive(:new).
50
- with(:config => @config_mock,
50
+ with(:config => @config_double,
51
51
  :region => 'us-west-1').
52
- and_return @s3_mock
53
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-west-1').
54
- and_return 'an s3 bucket'
52
+ and_return @s3_double
53
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-west-1').
54
+ and_return 'an s3 bucket'
55
55
  @verifier.bucket_exists?(:bucket_prefix => 'bucket123',
56
56
  :region => 'us-west-1').should be_true
57
57
  end
58
58
 
59
59
  it "should return false if the given bucket does not exist in the region" do
60
60
  Heirloom::AWS::S3.should_receive(:new).
61
- with(:config => @config_mock,
61
+ with(:config => @config_double,
62
62
  :region => 'us-west-1').
63
- and_return @s3_mock
64
- @s3_mock.should_receive(:get_bucket).with('bucket123-us-west-1').
65
- and_return 'an s3 bucket'
63
+ and_return @s3_double
64
+ @s3_double.should_receive(:get_bucket).with('bucket123-us-west-1').
65
+ and_return 'an s3 bucket'
66
66
  @verifier.bucket_exists?(:bucket_prefix => 'bucket123',
67
67
  :region => 'us-west-1').should be_true
68
68
  end
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @logger_mock = mock 'logger'
7
- @logger_mock.stub :info => true, :debug => true
8
- @config_mock = mock 'config'
9
- @config_mock.stub :logger => @logger_mock
10
- @tempfile_stub = stub 'tempfile', :path => '/tmp/tempfile'
11
- Tempfile.stub :new => @tempfile_stub
12
- @writer = Heirloom::Writer.new :config => @config_mock
6
+ @logger_double = double 'logger'
7
+ @logger_double.stub :info => true, :debug => true
8
+ @config_double = double 'config'
9
+ @config_double.stub :logger => @logger_double
10
+ @tempfile_double = double 'tempfile', :path => '/tmp/tempfile'
11
+ Tempfile.stub :new => @tempfile_double
12
+ @writer = Heirloom::Writer.new :config => @config_double
13
13
  end
14
14
 
15
15
  context "extract is set to true" do
@@ -18,7 +18,7 @@ describe Heirloom do
18
18
  Heirloom::Writer.any_instance.should_receive(:`).
19
19
  with('tar xzf /tmp/tempfile -C /output')
20
20
  $?.stub :success? => true
21
- @writer.save_archive(:archive => 'archive_data',
21
+ @writer.save_archive(:archive => 'archive_data',
22
22
  :output => '/output',
23
23
  :file => 'id.tar.gz',
24
24
  :extract => true).should be_true
@@ -29,8 +29,8 @@ describe Heirloom do
29
29
  Heirloom::Writer.any_instance.should_receive(:`).
30
30
  with('tar xzf /tmp/tempfile -C /output')
31
31
  $?.stub :success? => false
32
- @logger_mock.should_receive(:error)
33
- @writer.save_archive(:archive => 'archive_data',
32
+ @logger_double.should_receive(:error)
33
+ @writer.save_archive(:archive => 'archive_data',
34
34
  :output => '/output',
35
35
  :file => 'id.tar.gz',
36
36
  :extract => true).should be_false
@@ -41,7 +41,7 @@ describe Heirloom do
41
41
  it "should save the given archive object into the output directory" do
42
42
  File.should_receive(:open).with('/output/id.tar.gz', 'w').
43
43
  and_return true
44
- @writer.save_archive :archive => 'archive_data',
44
+ @writer.save_archive :archive => 'archive_data',
45
45
  :output => '/output',
46
46
  :file => 'id.tar.gz',
47
47
  :extract => false
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @logger_mock = mock 'logger', :info => true, :debug => true, :error => true
7
- @config_mock = mock 'config', :logger => @logger_mock
8
- @archive = Heirloom::Archive.new :config => @config_mock,
6
+ @logger_double = double 'logger', :info => true, :debug => true, :error => true
7
+ @config_double = double 'config', :logger => @logger_mock
8
+ @archive = Heirloom::Archive.new :config => @config_double,
9
9
  :name => 'chef',
10
10
  :id => '123'
11
11
  end
@@ -14,212 +14,210 @@ describe Heirloom do
14
14
  context "test public methods" do
15
15
 
16
16
  it "should call build with given args" do
17
- mock = double('Mock')
17
+ double = double('Mock')
18
18
  Heirloom::Builder.should_receive(:new).
19
- with(:config => @config_mock,
19
+ with(:config => @config_double,
20
20
  :name => 'chef',
21
21
  :id => '123').
22
- and_return mock
23
- mock.should_receive(:build).with('args')
22
+ and_return double
23
+ double.should_receive(:build).with('args')
24
24
  @archive.build('args')
25
25
  end
26
26
 
27
27
  it "should call download method with given args" do
28
- mock = double('Mock')
28
+ double = double('Mock')
29
29
  Heirloom::Downloader.should_receive(:new).
30
- with(:config => @config_mock,
30
+ with(:config => @config_double,
31
31
  :name => 'chef',
32
32
  :id => '123').
33
- and_return mock
34
- mock.should_receive(:download).with('args')
33
+ and_return double
34
+ double.should_receive(:download).with('args')
35
35
  @archive.download('args')
36
36
  end
37
37
 
38
38
  it "should call update archive method with given args" do
39
- mock = double('Mock')
39
+ double = double('Mock')
40
40
  Heirloom::Updater.should_receive(:new).
41
- with(:config => @config_mock,
41
+ with(:config => @config_double,
42
42
  :name => 'chef',
43
43
  :id => '123').
44
- and_return mock
45
- mock.should_receive(:update).with('args')
44
+ and_return double
45
+ double.should_receive(:update).with('args')
46
46
  @archive.update('args')
47
47
  end
48
48
 
49
49
  it "should call upload archive method with given args" do
50
- mock = double('Mock')
51
- reader_mock = double('reader mock')
50
+ double = double('Mock')
51
+ reader_double = double('reader double')
52
52
  Heirloom::Reader.should_receive(:new).
53
- with(:config => @config_mock,
53
+ with(:config => @config_double,
54
54
  :name => 'chef',
55
55
  :id => '123').
56
- and_return reader_mock
57
- reader_mock.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
56
+ and_return reader_double
57
+ reader_double.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
58
58
  Heirloom::Uploader.should_receive(:new).
59
- with(:config => @config_mock,
59
+ with(:config => @config_double,
60
60
  :name => 'chef',
61
61
  :id => '123').
62
- and_return mock
63
- mock.should_receive(:upload).with('arg' => 'val', :regions => ['us-west-1', 'us-west-2'])
62
+ and_return double
63
+ double.should_receive(:upload).with('arg' => 'val', :regions => ['us-west-1', 'us-west-2'])
64
64
  @archive.upload('arg' => 'val')
65
65
  end
66
66
 
67
67
  it "should call authorize method" do
68
- mock = double('Mock')
69
- reader_mock = double('reader mock')
68
+ double = double('Mock')
69
+ reader_double = double('reader double')
70
70
  Heirloom::Reader.should_receive(:new).
71
- with(:config => @config_mock,
71
+ with(:config => @config_double,
72
72
  :name => 'chef',
73
73
  :id => '123').
74
- and_return reader_mock
75
- reader_mock.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
74
+ and_return reader_double
75
+ reader_double.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
76
76
  Heirloom::Authorizer.should_receive(:new).
77
- with(:config => @config_mock,
77
+ with(:config => @config_double,
78
78
  :name => 'chef',
79
79
  :id => '123').
80
- and_return mock
81
- mock.should_receive(:authorize).with :regions => ['us-west-1', 'us-west-2'],
82
- :accounts => ['acct1', 'acct2']
80
+ and_return double
81
+ double.should_receive(:authorize).with :regions => ['us-west-1', 'us-west-2'],
82
+ :accounts => ['acct1', 'acct2']
83
83
  @archive.authorize ['acct1', 'acct2']
84
84
  end
85
85
 
86
86
  it "should call archive exists method and return true if archive exists" do
87
- mock = double('Mock')
87
+ double = double('Mock')
88
88
  Heirloom::Reader.should_receive(:new).
89
- with(:config => @config_mock,
89
+ with(:config => @config_double,
90
90
  :name => 'chef',
91
91
  :id => '123').
92
- and_return mock
93
- mock.should_receive(:exists?).and_return true
92
+ and_return double
93
+ double.should_receive(:exists?).and_return true
94
94
  @archive.exists?.should be_true
95
95
  end
96
96
 
97
97
  it "should call archive exists method and return fasle if archive doesnt exists" do
98
- mock = double('Mock')
98
+ double = double('Mock')
99
99
  Heirloom::Reader.should_receive(:new).
100
- with(:config => @config_mock,
100
+ with(:config => @config_double,
101
101
  :name => 'chef',
102
102
  :id => '123').
103
- and_return mock
104
- mock.should_receive(:exists?).and_return false
103
+ and_return double
104
+ double.should_receive(:exists?).and_return false
105
105
  @archive.exists?.should be_false
106
106
  end
107
107
 
108
108
  it "should call show method" do
109
- reader_mock = mock 'reader'
109
+ reader_double = double 'reader'
110
110
  show_data = { 'id' => '0.0.7',
111
111
  'encrypted' => 'true',
112
112
  'bucket_prefix' => 'rickybobby',
113
- 'us-west-2-s3-url' => 's3://rickybobby-us-west-2/demo2/0.0.7.tar.gz.gpg'
114
- }
113
+ 'us-west-2-s3-url' => 's3://rickybobby-us-west-2/demo2/0.0.7.tar.gz.gpg' }
115
114
  object_acls_data = { 'us-west-2-perms' => 'rickybobby:read, lc:full_control',
116
- 'us-west-1-perms' => 'rickybobby:read, lc:full_control'
117
- }
115
+ 'us-west-1-perms' => 'rickybobby:read, lc:full_control' }
118
116
  merge_data = show_data.merge object_acls_data
119
-
117
+
120
118
  Heirloom::Reader.should_receive(:new).
121
- with(:config => @config_mock,
119
+ with(:config => @config_double,
122
120
  :name => 'chef',
123
121
  :id => '123').
124
- and_return reader_mock
125
-
126
- reader_mock.stub(:show).and_return(show_data)
127
- reader_mock.stub(:object_acls).and_return(object_acls_data)
122
+ and_return reader_double
123
+
124
+ reader_double.stub(:show).and_return(show_data)
125
+ reader_double.stub(:object_acls).and_return(object_acls_data)
128
126
  @archive.show.should == merge_data
129
127
  end
130
128
 
131
129
  it "should call list method" do
132
- mock = double('Mock')
130
+ double = double('Mock')
133
131
  Heirloom::Lister.should_receive(:new).
134
- with(:config => @config_mock,
132
+ with(:config => @config_double,
135
133
  :name => 'chef').
136
- and_return mock
137
- mock.should_receive(:list)
134
+ and_return double
135
+ double.should_receive(:list)
138
136
  @archive.list
139
137
  end
140
138
 
141
139
  it "should return true if the required buckets exist" do
142
- mock = double('Mock')
140
+ double = double('Mock')
143
141
  Heirloom::Verifier.should_receive(:new).
144
- with(:config => @config_mock,
142
+ with(:config => @config_double,
145
143
  :name => 'chef').
146
- and_return mock
147
- mock.should_receive(:buckets_exist?).
148
- with(:bucket_prefix => 'test-123').and_return true
144
+ and_return double
145
+ double.should_receive(:buckets_exist?).
146
+ with(:bucket_prefix => 'test-123').and_return true
149
147
  @archive.buckets_exist?(:bucket_prefix => 'test-123').
150
148
  should be_true
151
149
  end
152
150
 
153
151
  it "should return false if the required buckets don't exist" do
154
- mock = double('Mock')
152
+ double = double('Mock')
155
153
  Heirloom::Verifier.should_receive(:new).
156
- with(:config => @config_mock,
154
+ with(:config => @config_double,
157
155
  :name => 'chef').
158
- and_return mock
159
- mock.should_receive(:buckets_exist?).
160
- with(:bucket_prefix => 'test-123').and_return false
156
+ and_return double
157
+ double.should_receive(:buckets_exist?).
158
+ with(:bucket_prefix => 'test-123').and_return false
161
159
  @archive.buckets_exist?(:bucket_prefix => 'test-123').
162
160
  should be_false
163
161
  end
164
162
 
165
163
  it "should call the destroy method" do
166
- destroyer_mock = double('destroyer mock')
167
- reader_mock = double('reader mock')
164
+ destroyer_double = double('destroyer double')
165
+ reader_double = double('reader double')
168
166
  Heirloom::Reader.should_receive(:new).
169
- with(:config => @config_mock,
167
+ with(:config => @config_double,
170
168
  :name => 'chef',
171
169
  :id => '123').
172
- and_return reader_mock
173
- reader_mock.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
170
+ and_return reader_double
171
+ reader_double.should_receive(:regions).and_return ['us-west-1', 'us-west-2']
174
172
  Heirloom::Destroyer.should_receive(:new).
175
- with(:config => @config_mock,
173
+ with(:config => @config_double,
176
174
  :name => 'chef',
177
175
  :id => '123').
178
- and_return destroyer_mock
179
- destroyer_mock.should_receive(:destroy).
180
- with :regions => ['us-west-1', 'us-west-2']
176
+ and_return destroyer_double
177
+ destroyer_double.should_receive(:destroy).
178
+ with :regions => ['us-west-1', 'us-west-2']
181
179
  @archive.destroy
182
180
  end
183
181
 
184
182
  it "should call the regions method for an archive" do
185
- mock = double('Mock')
183
+ double = double('Mock')
186
184
  Heirloom::Reader.should_receive(:new).
187
- with(:config => @config_mock,
185
+ with(:config => @config_double,
188
186
  :name => 'chef',
189
187
  :id => '123').
190
- and_return mock
191
- mock.should_receive(:regions)
188
+ and_return double
189
+ double.should_receive(:regions)
192
190
  @archive.regions
193
191
  end
194
192
 
195
193
  it "should call the count method for an archive" do
196
- mock = double('Mock')
194
+ double = double('Mock')
197
195
  Heirloom::Reader.should_receive(:new).
198
- with(:config => @config_mock,
196
+ with(:config => @config_double,
199
197
  :name => 'chef',
200
198
  :id => '123').
201
- and_return mock
202
- mock.should_receive(:count)
199
+ and_return double
200
+ double.should_receive(:count)
203
201
  @archive.count
204
202
  end
205
203
 
206
204
  it "should call the delete_buckets on teardowner" do
207
- mock = double('Mock')
205
+ double = double('Mock')
208
206
  Heirloom::Teardowner.should_receive(:new).
209
- with(:config => @config_mock,
207
+ with(:config => @config_double,
210
208
  :name => 'chef').
211
- and_return mock
212
- mock.should_receive(:delete_buckets).with :regions => ['us-west-1']
209
+ and_return double
210
+ double.should_receive(:delete_buckets).with :regions => ['us-west-1']
213
211
  @archive.delete_buckets :regions => ['us-west-1']
214
212
  end
215
213
 
216
214
  it "should call the delete_domain on teardowner" do
217
- mock = double('Mock')
215
+ double = double('Mock')
218
216
  Heirloom::Teardowner.should_receive(:new).
219
- with(:config => @config_mock,
217
+ with(:config => @config_double,
220
218
  :name => 'chef').
221
- and_return mock
222
- mock.should_receive(:delete_domain)
219
+ and_return double
220
+ double.should_receive(:delete_domain)
223
221
  @archive.delete_domain
224
222
  end
225
223
 
@@ -231,7 +229,7 @@ describe Heirloom do
231
229
  @tmp_dir = '/path/to/temp/dir'
232
230
  Dir.stub(:mktmpdir).and_return @tmp_dir
233
231
 
234
- @tmp_file = mock 'file'
232
+ @tmp_file = double 'file'
235
233
  @tmp_file.stub :path => '/path/to/tmp/file', :close! => true
236
234
  Tempfile.stub :new => @tmp_file
237
235
  FileUtils.stub :remove_entry => true
@@ -263,7 +261,7 @@ describe Heirloom do
263
261
  before do
264
262
  @archive.stub :download => false, :build => true, :destroy => nil, :upload => true
265
263
  end
266
-
264
+
267
265
  it "should raise an exception when download fails" do
268
266
  expect {
269
267
  @archive.rotate({ :new_secret => "new", :old_secret => "old" })
@@ -285,7 +283,7 @@ describe Heirloom do
285
283
  before do
286
284
  @archive.stub :download => true, :build => false, :destroy => nil, :upload => true
287
285
  end
288
-
286
+
289
287
  it "should raise an exception when build fails" do
290
288
  expect {
291
289
  @archive.rotate({ :new_secret => "new", :old_secret => "old" })