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,38 +3,38 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = mock 'config'
7
- @logger_mock = mock 'logger'
8
- @logger_mock.stub :info => true, :debug => true
9
- @config_mock.should_receive(:logger).and_return(@logger_mock)
10
- @authorizer = Heirloom::Authorizer.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger'
8
+ @logger_double.stub :info => true, :debug => true
9
+ @config_double.should_receive(:logger).and_return(@logger_double)
10
+ @authorizer = Heirloom::Authorizer.new :config => @config_double,
11
11
  :name => 'tim',
12
12
  :id => '123.tar.gz'
13
13
  end
14
14
 
15
15
  it "should authorize access to an archive in all regions for email or longid" do
16
- s3_acl_mock = mock 's3 acl'
17
- reader_mock = mock 'reader mock'
18
- reader_mock.stub :key_name => '123.tar.gz'
19
- reader_mock.should_receive(:get_bucket).exactly(2).times.
16
+ s3_acl_double = double 's3 acl'
17
+ reader_double = double 'reader mock'
18
+ reader_double.stub :key_name => '123.tar.gz'
19
+ reader_double.should_receive(:get_bucket).exactly(2).times.
20
20
  and_return('the-bucket')
21
21
 
22
22
  accounts = [ "test@a.com", "a@test.com", "test@test.co", "test@test.co.uk","08b21b085ca99e70859487d685191f40d951daa0fbcb5bec51bf5ea6023e445d" ]
23
23
 
24
24
  Heirloom::Reader.should_receive(:new).
25
- with(:config => @config_mock,
25
+ with(:config => @config_double,
26
26
  :name => 'tim',
27
27
  :id => '123.tar.gz').
28
- and_return reader_mock
28
+ and_return reader_double
29
29
  Heirloom::ACL::S3.should_receive(:new).
30
- with(:config => @config_mock,
30
+ with(:config => @config_double,
31
31
  :region => 'us-west-1').
32
- and_return s3_acl_mock
32
+ and_return s3_acl_double
33
33
  Heirloom::ACL::S3.should_receive(:new).
34
- with(:config => @config_mock,
34
+ with(:config => @config_double,
35
35
  :region => 'us-west-2').
36
- and_return s3_acl_mock
37
- s3_acl_mock.should_receive(:allow_read_access_from_accounts).
36
+ and_return s3_acl_double
37
+ s3_acl_double.should_receive(:allow_read_access_from_accounts).
38
38
  exactly(2).times.
39
39
  with(:key_name => '123.tar.gz',
40
40
  :key_folder => 'tim',
@@ -46,28 +46,28 @@ describe Heirloom do
46
46
  end
47
47
 
48
48
  it "should exit when an account is a shortid" do
49
- @logger_mock.should_receive(:error)
49
+ @logger_double.should_receive(:error)
50
50
  @authorizer.authorize(:accounts => [ '123456789_1234', 'good@good.com'],
51
51
  :regions => ['us-west-1', 'us-west-2']).
52
52
  should be_false
53
53
  end
54
54
 
55
55
  it "should exit when a bad email is given" do
56
- @logger_mock.should_receive(:error)
56
+ @logger_double.should_receive(:error)
57
57
  @authorizer.authorize(:accounts => ['bad@bad', 'good@good.com'],
58
58
  :regions => ['us-west-1', 'us-west-2']).
59
59
  should be_false
60
60
  end
61
61
 
62
62
  it "should exit when an id which is not long(64) or short(16)" do
63
- @logger_mock.should_receive(:error)
63
+ @logger_double.should_receive(:error)
64
64
  @authorizer.authorize(:accounts => ['123456789_123456789_1', 'good@good.com'],
65
65
  :regions => ['us-west-1', 'us-west-2']).
66
66
  should be_false
67
67
  end
68
68
 
69
69
  it "should exit even when the first value is valid" do
70
- @logger_mock.should_receive(:error)
70
+ @logger_double.should_receive(:error)
71
71
  @authorizer.authorize(:accounts => ['good@good.com', '123456789_123456789_1'],
72
72
  :regions => ['us-west-1', 'us-west-2']).
73
73
  should be_false
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe Heirloom::Builder do
4
4
  before do
5
- @config_mock = double 'config'
6
- @logger_stub = stub :debug => 'true', :info => 'true', :warn => 'true'
7
- @config_mock.stub(:logger).and_return(@logger_stub)
8
- @simpledb_mock = double 'simple db'
9
- @builder = Heirloom::Builder.new :config => @config_mock,
5
+ @config_double = double 'config'
6
+ @logger_double = double :debug => 'true', :info => 'true', :warn => 'true'
7
+ @config_double.stub(:logger).and_return(@logger_double)
8
+ @simpledb_double = double 'simple db'
9
+ @builder = Heirloom::Builder.new :config => @config_double,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
12
  end
@@ -14,28 +14,28 @@ describe Heirloom::Builder do
14
14
  describe 'build' do
15
15
  context 'when successful' do
16
16
  before do
17
- @author_stub = stub :name => 'weaver'
18
- @directory_stub = stub :build_artifact_from_directory => '/tmp/build_dir',
19
- :local_build => '/var/tmp/file.tar.gz'
17
+ @author_double = double :name => 'weaver'
18
+ @directory_double = double :build_artifact_from_directory => '/tmp/build_dir',
19
+ :local_build => '/var/tmp/file.tar.gz'
20
20
 
21
21
  Heirloom::Directory.should_receive(:new).
22
22
  with(:path => 'path_to_build',
23
23
  :exclude => ['.dir_to_exclude'],
24
24
  :file => '/tmp/file.tar.gz',
25
- :config => @config_mock).
26
- and_return @directory_stub
25
+ :config => @config_double).
26
+ and_return @directory_double
27
27
  @builder.should_receive(:create_artifact_record)
28
28
  end
29
29
 
30
30
  end
31
31
 
32
32
  it "should return false if the build fails" do
33
- directory_stub = stub :build_artifact_from_directory => false
33
+ directory_double = double :build_artifact_from_directory => false
34
34
  Heirloom::Directory.should_receive(:new).with(:path => 'path_to_build',
35
35
  :exclude => ['.dir_to_exclude'],
36
36
  :file => '/tmp/file.tar.gz',
37
- :config => @config_mock).
38
- and_return directory_stub
37
+ :config => @config_double).
38
+ and_return directory_double
39
39
  @builder.build(:exclude => ['.dir_to_exclude'],
40
40
  :directory => 'path_to_build',
41
41
  :file => '/tmp/file.tar.gz').should be_false
@@ -3,50 +3,50 @@ 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,
8
- :info => true,
9
- :warn => true
10
- @config_mock.stub :logger => @logger_stub
11
- @checker = Heirloom::Checker.new :config => @config_mock
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger', :debug => true,
8
+ :info => true,
9
+ :warn => true
10
+ @config_double.stub :logger => @logger_double
11
+ @checker = Heirloom::Checker.new :config => @config_double
12
12
  @regions = ['us-west-1', 'us-west-2']
13
13
  end
14
14
 
15
15
  it "should return true if all bucket names are available" do
16
- s3_mock = mock 's3'
16
+ s3_double = double 's3'
17
17
  Heirloom::AWS::S3.should_receive(:new).
18
- with(:config => @config_mock,
18
+ with(:config => @config_double,
19
19
  :region => 'us-west-1').
20
- and_return s3_mock
20
+ and_return s3_double
21
21
  Heirloom::AWS::S3.should_receive(:new).
22
- with(:config => @config_mock,
22
+ with(:config => @config_double,
23
23
  :region => 'us-west-2').
24
- and_return s3_mock
25
- s3_mock.should_receive(:bucket_name_available?).
26
- with('bp-us-west-1').
27
- and_return true
28
- s3_mock.should_receive(:bucket_name_available?).
29
- with('bp-us-west-2').
30
- and_return true
24
+ and_return s3_double
25
+ s3_double.should_receive(:bucket_name_available?).
26
+ with('bp-us-west-1').
27
+ and_return true
28
+ s3_double.should_receive(:bucket_name_available?).
29
+ with('bp-us-west-2').
30
+ and_return true
31
31
  @checker.bucket_name_available?(:bucket_prefix => 'bp',
32
32
  :regions => @regions).
33
33
  should be_true
34
34
  end
35
35
 
36
36
  it "should return false if any buckets are unavailable" do
37
- s3_mock = mock 's3'
37
+ s3_double = double 's3'
38
38
  Heirloom::AWS::S3.should_receive(:new).
39
- with(:config => @config_mock,
39
+ with(:config => @config_double,
40
40
  :region => 'us-west-1').
41
- and_return s3_mock
41
+ and_return s3_double
42
42
  Heirloom::AWS::S3.should_receive(:new).
43
- with(:config => @config_mock,
43
+ with(:config => @config_double,
44
44
  :region => 'us-west-2').
45
- and_return s3_mock
46
- s3_mock.should_receive(:bucket_name_available?).
45
+ and_return s3_double
46
+ s3_double.should_receive(:bucket_name_available?).
47
47
  with('bp-us-west-1').
48
48
  and_return false
49
- s3_mock.should_receive(:bucket_name_available?).
49
+ s3_double.should_receive(:bucket_name_available?).
50
50
  with('bp-us-west-2').
51
51
  and_return true
52
52
  @checker.bucket_name_available?(:bucket_prefix => 'bp',
@@ -3,37 +3,37 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = double 'config'
7
- @logger_stub = stub 'logger', :info => true, :debug => true
8
- @config_mock.stub :logger => @logger_stub
9
- @destroyer = Heirloom::Destroyer.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger', :info => true, :debug => true
8
+ @config_double.stub :logger => @logger_double
9
+ @destroyer = Heirloom::Destroyer.new :config => @config_double,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
12
  end
13
13
 
14
14
  before do
15
- @reader_mock = mock 'archive reader'
16
- @destroyer.stub :reader => @reader_mock
17
- @reader_mock.should_receive(:get_bucket).
18
- with(:region => 'us-west-1').
19
- and_return 'bucket-us-west-1'
20
- @reader_mock.stub :key_name => '123.tar.gz'
15
+ @reader_double = double 'archive reader'
16
+ @destroyer.stub :reader => @reader_double
17
+ @reader_double.should_receive(:get_bucket).
18
+ with(:region => 'us-west-1').
19
+ and_return 'bucket-us-west-1'
20
+ @reader_double.stub :key_name => '123.tar.gz'
21
21
 
22
- @s3_destroyer_mock = mock 's3 destroyer'
22
+ @s3_destroyer_double = double 's3 destroyer'
23
23
  Heirloom::Destroyer::S3.should_receive(:new).
24
- with(:config => @config_mock,
24
+ with(:config => @config_double,
25
25
  :region => 'us-west-1').
26
- and_return @s3_destroyer_mock
27
- @s3_destroyer_mock.should_receive(:destroy_file).
28
- with :key_name => '123.tar.gz',
29
- :key_folder => 'tim',
30
- :bucket => 'bucket-us-west-1'
31
- @sdb_mock = mock 'sdb'
32
- @destroyer.stub :sdb => @sdb_mock
26
+ and_return @s3_destroyer_double
27
+ @s3_destroyer_double.should_receive(:destroy_file).
28
+ with :key_name => '123.tar.gz',
29
+ :key_folder => 'tim',
30
+ :bucket => 'bucket-us-west-1'
31
+ @sdb_double = double 'sdb'
32
+ @destroyer.stub :sdb => @sdb_double
33
33
  end
34
34
 
35
35
  it "should destroy the given archive" do
36
- @sdb_mock.should_receive(:delete).with 'heirloom_tim', '123'
36
+ @sdb_double.should_receive(:delete).with 'heirloom_tim', '123'
37
37
  @destroyer.destroy :regions => ['us-west-1']
38
38
  end
39
39
 
@@ -3,42 +3,42 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = mock 'config'
7
- @logger_stub = mock 'logger', :info => true, :debug => true
8
- @config_mock.stub :logger => @logger_stub
9
- @downloader = Heirloom::Downloader.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @logger_double = double 'logger', :info => true, :debug => true
8
+ @config_double.stub :logger => @logger_double
9
+ @downloader = Heirloom::Downloader.new :config => @config_double,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
- @s3_downloader_mock = mock 's3 downloader'
12
+ @s3_downloader_double = double 's3 downloader'
13
13
  Heirloom::Downloader::S3.should_receive(:new).
14
- with(:config => @config_mock,
15
- :logger => @logger_stub,
14
+ with(:config => @config_double,
15
+ :logger => @logger_double,
16
16
  :region => 'us-west-1').
17
- and_return @s3_downloader_mock
18
- @cipher_mock = mock 'cipher'
17
+ and_return @s3_downloader_double
18
+ @cipher_double = double 'cipher'
19
19
  end
20
20
 
21
21
  context "no secret given" do
22
22
  context "when succesful" do
23
23
  before do
24
- @writer_mock = mock 'writer'
24
+ @writer_double = double 'writer'
25
25
  Heirloom::Writer.should_receive(:new).
26
- with(:config => @config_mock).
27
- and_return @writer_mock
28
- @s3_downloader_mock.should_receive(:download_file).
26
+ with(:config => @config_double).
27
+ and_return @writer_double
28
+ @s3_downloader_double.should_receive(:download_file).
29
29
  with(:bucket => 'bucket-us-west-1',
30
30
  :key => 'tim/123.tar.gz').
31
31
  and_return 'plaintext'
32
- @cipher_mock.should_receive(:decrypt_data).
32
+ @cipher_double.should_receive(:decrypt_data).
33
33
  with(:secret => nil,
34
34
  :data => 'plaintext').and_return 'plaintext'
35
35
  Heirloom::Cipher::Data.should_receive(:new).
36
- with(:config => @config_mock).
37
- and_return @cipher_mock
36
+ with(:config => @config_double).
37
+ and_return @cipher_double
38
38
  end
39
39
 
40
40
  it "should download to the current path if output is not specified" do
41
- @writer_mock.should_receive(:save_archive).
41
+ @writer_double.should_receive(:save_archive).
42
42
  with(:archive => 'plaintext',
43
43
  :file => "123.tar.gz",
44
44
  :output => './',
@@ -50,7 +50,7 @@ describe Heirloom do
50
50
  end
51
51
 
52
52
  it "should download arhcive to specified output" do
53
- @writer_mock.should_receive(:save_archive).
53
+ @writer_double.should_receive(:save_archive).
54
54
  with(:archive => 'plaintext',
55
55
  :file => "123.tar.gz",
56
56
  :output => '/tmp/dir',
@@ -65,7 +65,7 @@ describe Heirloom do
65
65
 
66
66
  context "when unsuccesful" do
67
67
  before do
68
- @s3_downloader_mock.should_receive(:download_file).
68
+ @s3_downloader_double.should_receive(:download_file).
69
69
  with(:bucket => 'bucket-us-west-1',
70
70
  :key => 'tim/123.tar.gz').
71
71
  and_return false
@@ -83,28 +83,28 @@ describe Heirloom do
83
83
 
84
84
  context "secret given" do
85
85
  before do
86
- @s3_downloader_mock.should_receive(:download_file).
86
+ @s3_downloader_double.should_receive(:download_file).
87
87
  with(:bucket => 'bucket-us-west-1',
88
88
  :key => 'tim/123.tar.gz.gpg').
89
89
  and_return 'encrypted_data'
90
90
  Heirloom::Cipher::Data.should_receive(:new).
91
- with(:config => @config_mock).
92
- and_return @cipher_mock
91
+ with(:config => @config_double).
92
+ and_return @cipher_double
93
93
  end
94
94
 
95
95
  context "valid secret" do
96
96
  before do
97
- @writer_mock = mock 'writer'
97
+ @writer_double = double 'writer'
98
98
  Heirloom::Writer.should_receive(:new).
99
- with(:config => @config_mock).
100
- and_return @writer_mock
101
- @cipher_mock.should_receive(:decrypt_data).
99
+ with(:config => @config_double).
100
+ and_return @writer_double
101
+ @cipher_double.should_receive(:decrypt_data).
102
102
  with(:secret => 'supersecret',
103
103
  :data => 'encrypted_data').and_return 'plaintext'
104
104
  end
105
105
 
106
106
  it "should decrypt and save the downloaded file with secret" do
107
- @writer_mock.should_receive(:save_archive).
107
+ @writer_double.should_receive(:save_archive).
108
108
  with(:archive => 'plaintext',
109
109
  :file => "123.tar.gz",
110
110
  :output => './',
@@ -116,7 +116,7 @@ describe Heirloom do
116
116
  end
117
117
 
118
118
  it "should decrypt and extract the downloaded file with secret" do
119
- @writer_mock.should_receive(:save_archive).
119
+ @writer_double.should_receive(:save_archive).
120
120
  with(:archive => 'plaintext',
121
121
  :file => "123.tar.gz",
122
122
  :output => './',
@@ -130,7 +130,7 @@ describe Heirloom do
130
130
 
131
131
  context "invalid secret" do
132
132
  before do
133
- @cipher_mock.should_receive(:decrypt_data).
133
+ @cipher_double.should_receive(:decrypt_data).
134
134
  with(:secret => 'badsecret',
135
135
  :data => 'encrypted_data').and_return false
136
136
  end
@@ -140,7 +140,7 @@ describe Heirloom do
140
140
  :bucket_prefix => 'bucket',
141
141
  :extract => false,
142
142
  :secret => 'badsecret').should be_false
143
- end
143
+ end
144
144
 
145
145
  end
146
146
  end
@@ -3,18 +3,18 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = double 'config'
7
- @lister = Heirloom::Lister.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @lister = Heirloom::Lister.new :config => @config_double,
8
8
  :name => 'test123'
9
9
  end
10
10
 
11
11
  it "should list the known archive" do
12
- sdb_mock = mock 'sdb'
13
- @lister.should_receive(:sdb).and_return sdb_mock
14
- sdb_mock.should_receive(:select).
15
- with("select * from `heirloom_test123` where built_at > '2000-01-01T00:00:00.000Z' \
12
+ sdb_double = double 'sdb'
13
+ @lister.should_receive(:sdb).and_return sdb_double
14
+ sdb_double.should_receive(:select).
15
+ with("select * from `heirloom_test123` where built_at > '2000-01-01T00:00:00.000Z' \
16
16
  order by built_at desc limit 10").
17
- and_return( {'1' => 'one', '2' => 'two', '3' => 'three'} )
17
+ and_return( {'1' => 'one', '2' => 'two', '3' => 'three'} )
18
18
  @lister.list.should == ['1', '2', '3']
19
19
  end
20
20
 
@@ -3,113 +3,113 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @sdb_mock = mock 'sdb'
7
- @config_mock = mock 'config'
8
- @logger_stub = stub :debug => true
9
- @config_mock.stub :logger => @logger_stub
10
- @reader = Heirloom::Reader.new :config => @config_mock,
6
+ @sdb_double = double 'sdb'
7
+ @config_double = double 'config'
8
+ @logger_double = double :debug => true
9
+ @config_double.stub :logger => @logger_double
10
+ @reader = Heirloom::Reader.new :config => @config_double,
11
11
  :name => 'tim',
12
12
  :id => '123'
13
13
  end
14
14
 
15
15
  context "domain does exist" do
16
16
  before do
17
- Heirloom::AWS::SimpleDB.stub :new => @sdb_mock
18
- @sdb_mock.stub :domain_exists? => true
17
+ Heirloom::AWS::SimpleDB.stub :new => @sdb_double
18
+ @sdb_double.stub :domain_exists? => true
19
19
  end
20
20
 
21
21
  it "should show the item record" do
22
- @sdb_mock.should_receive(:select).
23
- with("select * from `heirloom_tim` where itemName() = '123'").
24
- and_return( { '123' => { 'value' => [ 'details' ] } } )
22
+ @sdb_double.should_receive(:select).
23
+ with("select * from `heirloom_tim` where itemName() = '123'").
24
+ and_return( { '123' => { 'value' => [ 'details' ] } } )
25
25
  @reader.show.should == { 'value' => 'details' }
26
26
  end
27
27
 
28
28
  it "should return an empty hash if item does not exist" do
29
- @sdb_mock.should_receive(:select).
30
- with("select * from `heirloom_tim` where itemName() = '123'").
31
- and_return({})
29
+ @sdb_double.should_receive(:select).
30
+ with("select * from `heirloom_tim` where itemName() = '123'").
31
+ and_return({})
32
32
  @reader.show.should == {}
33
33
  end
34
34
 
35
35
  it "should return true if the record exists" do
36
- @sdb_mock.should_receive(:select).
37
- with("select * from `heirloom_tim` where itemName() = '123'").
38
- and_return( { '123' => { 'value' => [ 'details' ] } } )
36
+ @sdb_double.should_receive(:select).
37
+ with("select * from `heirloom_tim` where itemName() = '123'").
38
+ and_return( { '123' => { 'value' => [ 'details' ] } } )
39
39
  @reader.exists?.should == true
40
40
  end
41
41
 
42
42
  it "should return false if the record does not exist" do
43
- @sdb_mock.should_receive(:select).
44
- with("select * from `heirloom_tim` where itemName() = '123'").
45
- and_return({})
43
+ @sdb_double.should_receive(:select).
44
+ with("select * from `heirloom_tim` where itemName() = '123'").
45
+ and_return({})
46
46
  @reader.exists?.should == false
47
47
  end
48
48
 
49
49
  it "should return the bucket if it exists" do
50
- @sdb_mock.should_receive(:select).
51
- at_least(:once).
52
- with("select * from `heirloom_tim` where itemName() = '123'").
53
- and_return( { '123' =>
54
- { 'us-west-1-s3-url' =>
55
- [ 's3://the-bucket/the-name/123.tar.gz' ]
56
- }
57
- } )
50
+ @sdb_double.should_receive(:select).
51
+ at_least(:once).
52
+ with("select * from `heirloom_tim` where itemName() = '123'").
53
+ and_return( { '123' =>
54
+ { 'us-west-1-s3-url' =>
55
+ [ 's3://the-bucket/the-name/123.tar.gz' ]
56
+ }
57
+ } )
58
58
  @reader.get_bucket(:region => 'us-west-1').should == 'the-bucket'
59
59
  end
60
60
 
61
61
  it "should return nil if the key does not exist" do
62
- @sdb_mock.should_receive(:select).
62
+ @sdb_double.should_receive(:select).
63
63
  with("select * from `heirloom_tim` where itemName() = '123'").
64
64
  and_return( { } )
65
65
  @reader.get_key(:region => 'us-west-1').should == nil
66
66
  end
67
67
 
68
68
  it "should return nil if the bucket does not exist" do
69
- @sdb_mock.should_receive(:select).
70
- with("select * from `heirloom_tim` where itemName() = '123'").
71
- and_return( { } )
69
+ @sdb_double.should_receive(:select).
70
+ with("select * from `heirloom_tim` where itemName() = '123'").
71
+ and_return( { } )
72
72
  @reader.get_bucket(:region => 'us-west-1').should == nil
73
73
  end
74
74
 
75
75
  it "should return the key if it exists" do
76
- @sdb_mock.should_receive(:select).
77
- at_least(:once).
78
- with("select * from `heirloom_tim` where itemName() = '123'").
79
- and_return( { '123' =>
80
- { 'us-west-1-s3-url' =>
81
- ['s3://the-url/the-bucket/123.tar.gz']
82
- }
83
- } )
76
+ @sdb_double.should_receive(:select).
77
+ at_least(:once).
78
+ with("select * from `heirloom_tim` where itemName() = '123'").
79
+ and_return( { '123' =>
80
+ { 'us-west-1-s3-url' =>
81
+ ['s3://the-url/the-bucket/123.tar.gz']
82
+ }
83
+ } )
84
84
  @reader.get_key(:region => 'us-west-1').should == 'the-bucket/123.tar.gz'
85
85
  end
86
86
 
87
87
  it "should return the encrypted key name" do
88
- @sdb_mock.should_receive(:select).
89
- with("select * from `heirloom_tim` where itemName() = '123'").
90
- and_return( { '123' => { 'encrypted' => [ 'true' ] } } )
88
+ @sdb_double.should_receive(:select).
89
+ with("select * from `heirloom_tim` where itemName() = '123'").
90
+ and_return( { '123' => { 'encrypted' => [ 'true' ] } } )
91
91
  @reader.key_name.should == '123.tar.gz.gpg'
92
92
  end
93
93
 
94
94
  it "should return the unencrypted key name" do
95
- @sdb_mock.should_receive(:select).
96
- with("select * from `heirloom_tim` where itemName() = '123'").
97
- and_return( { '123' => { 'encrypted' => [ 'false' ] } } )
95
+ @sdb_double.should_receive(:select).
96
+ with("select * from `heirloom_tim` where itemName() = '123'").
97
+ and_return( { '123' => { 'encrypted' => [ 'false' ] } } )
98
98
  @reader.key_name.should == '123.tar.gz'
99
99
  end
100
100
 
101
101
  it "should return the regions the archive has been uploaded to" do
102
- @sdb_mock.should_receive(:select).
103
- with("select * from `heirloom_tim` where itemName() = '123'").
104
- and_return( { '123' =>
105
- { 'us-west-1-s3-url' =>
106
- ['s3://the-url-us-west-1/the-bucket/123.tar.gz'],
107
- 'build_by' =>
108
- ['user'],
109
- 'us-east-1-s3-url' =>
110
- ['s3://the-url-us-east-1/the-bucket/123.tar.gz']
111
- }
112
- } )
102
+ @sdb_double.should_receive(:select).
103
+ with("select * from `heirloom_tim` where itemName() = '123'").
104
+ and_return( { '123' =>
105
+ { 'us-west-1-s3-url' =>
106
+ ['s3://the-url-us-west-1/the-bucket/123.tar.gz'],
107
+ 'build_by' =>
108
+ ['user'],
109
+ 'us-east-1-s3-url' =>
110
+ ['s3://the-url-us-east-1/the-bucket/123.tar.gz']
111
+ }
112
+ } )
113
113
  @reader.regions.should == ['us-west-1', 'us-east-1']
114
114
  end
115
115
 
@@ -117,8 +117,8 @@ describe Heirloom do
117
117
 
118
118
  context "domain does not exist" do
119
119
  before do
120
- Heirloom::AWS::SimpleDB.stub :new => @sdb_mock
121
- @sdb_mock.stub :domain_exists? => false
120
+ Heirloom::AWS::SimpleDB.stub :new => @sdb_double
121
+ @sdb_double.stub :domain_exists? => false
122
122
  end
123
123
 
124
124
  it "should return false if the simpledb domain does not exist" do
@@ -129,11 +129,11 @@ describe Heirloom do
129
129
  context "object_acl verify" do
130
130
  it "should get object_acls" do
131
131
  regions = ['us-west-1', 'us-west-2']
132
- @config_mock.stub :access_key => 'the-key',
133
- :secret_key => 'the-secret'
132
+ @config_double.stub :access_key => 'the-key',
133
+ :secret_key => 'the-secret'
134
134
  @reader.stub :regions => regions,
135
- :key_name => 'mockvalue',
136
- :get_bucket => 'mockvalue'
135
+ :key_name => 'doublevalue',
136
+ :get_bucket => 'doublevalue'
137
137
  data = { "Owner" => { "ID" => "123", "DisplayName" => "lc" },
138
138
  "AccessControlList" => [
139
139
  { "Grantee" => { "ID" => "321", "DisplayName" => "rickybobby" },
@@ -141,13 +141,13 @@ describe Heirloom do
141
141
  { "Grantee" => { "ID" => "123", "DisplayName" => "lc" },
142
142
  "Permission" => "FULL_CONTROL" }]
143
143
  }
144
- s3_stub = stub 's3', :get_object_acl => data
144
+ s3_double = double 's3', :get_object_acl => data
145
145
 
146
146
  regions.each do |region|
147
147
  Heirloom::AWS::S3.should_receive(:new).
148
- with(:config => @config_mock,
148
+ with(:config => @config_double,
149
149
  :region => region).
150
- and_return s3_stub
150
+ and_return s3_double
151
151
  end
152
152
 
153
153
  @reader.object_acls.should == { 'us-west-1-permissions' => 'rickybobby:read, lc:full_control',