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
@@ -14,19 +14,19 @@ describe Heirloom do
14
14
  :aws_secret_key => 'secret' }
15
15
  Trollop.stub(:options).and_return options
16
16
 
17
- catalog_stub = stub :regions => ['us-east-1', 'us-west-1']
18
- Heirloom::Catalog.stub(:new).and_return catalog_stub
17
+ catalog_double = double :regions => ['us-east-1', 'us-west-1']
18
+ Heirloom::Catalog.stub(:new).and_return catalog_double
19
19
 
20
- @archive_mock = mock 'archive'
21
- @logger_mock = mock_log
22
- Heirloom::HeirloomLogger.stub :new => @logger_mock
23
- Heirloom::Archive.stub(:new).and_return @archive_mock
20
+ @archive_double = double 'archive'
21
+ @logger_double = double_log
22
+ Heirloom::HeirloomLogger.stub :new => @logger_double
23
+ Heirloom::Archive.stub(:new).and_return @archive_double
24
24
 
25
25
  end
26
26
 
27
27
  it "should delegate to archive object" do
28
28
 
29
- @archive_mock.should_receive :rotate
29
+ @archive_double.should_receive :rotate
30
30
 
31
31
  Heirloom::CLI::Rotate.new.rotate
32
32
 
@@ -34,9 +34,9 @@ describe Heirloom do
34
34
 
35
35
  it "should log and do a SystemExit when a rotate fails" do
36
36
 
37
- @archive_mock.stub(:rotate).and_raise Heirloom::Exceptions::RotateFailed.new("failed")
37
+ @archive_double.stub(:rotate).and_raise Heirloom::Exceptions::RotateFailed.new("failed")
38
38
 
39
- @logger_mock.should_receive(:error).with "failed"
39
+ @logger_double.should_receive(:error).with "failed"
40
40
  expect {
41
41
  Heirloom::CLI::Rotate.new.rotate
42
42
  }.to raise_error SystemExit
@@ -11,48 +11,48 @@ describe Heirloom do
11
11
  :name => 'archive_name',
12
12
  :metadata_region => 'us-west-1' }
13
13
 
14
- @logger_stub = stub 'logger', :error => true, :info => true
15
- @config_mock = mock_config :logger => @logger_stub
16
- @archive_mock = mock 'archive'
17
- @catalog_mock = mock 'catalog'
18
- @checker_mock = mock 'checker'
14
+ @logger_double = double 'logger', :error => true, :info => true
15
+ @config_double = double_config :logger => @logger_double
16
+ @archive_double = double 'archive'
17
+ @catalog_double = double 'catalog'
18
+ @checker_double = double 'checker'
19
19
  Trollop.stub(:options).and_return options
20
20
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
21
- and_return @logger_stub
21
+ and_return @logger_double
22
22
  Heirloom::CLI::Setup.any_instance.should_receive(:load_config).
23
- with(:logger => @logger_stub,
23
+ with(:logger => @logger_double,
24
24
  :opts => options).
25
- and_return @config_mock
25
+ and_return @config_double
26
26
  Heirloom::Archive.should_receive(:new).
27
27
  with(:name => 'archive_name',
28
- :config => @config_mock).
29
- and_return @archive_mock
28
+ :config => @config_double).
29
+ and_return @archive_double
30
30
  Heirloom::Catalog.should_receive(:new).
31
31
  with(:name => 'archive_name',
32
- :config => @config_mock).
33
- and_return @catalog_mock
32
+ :config => @config_double).
33
+ and_return @catalog_double
34
34
  Heirloom::Checker.should_receive(:new).
35
- with(:config => @config_mock).
36
- and_return @checker_mock
35
+ with(:config => @config_double).
36
+ and_return @checker_double
37
37
  @setup = Heirloom::CLI::Setup.new
38
38
  end
39
39
 
40
40
  it "should setup s3 buckets, catalog and simpledb domain" do
41
- @checker_mock.should_receive(:bucket_name_available?).
42
- with(:bucket_prefix => "bp",
43
- :regions => @regions,
44
- :config => @config_mock).
45
- and_return true
46
- @catalog_mock.should_receive(:create_catalog_domain)
47
- @catalog_mock.stub :entry_exists_in_catalog? => false
48
- @catalog_mock.should_receive(:add_to_catalog).
49
- with(:regions => @regions,
50
- :bucket_prefix => 'bp').
51
- and_return true
52
- @archive_mock.should_receive(:setup).
53
- with(:regions => @regions,
54
- :bucket_prefix => 'bp')
55
- @setup.setup
41
+ @checker_double.should_receive(:bucket_name_available?).
42
+ with(:bucket_prefix => "bp",
43
+ :regions => @regions,
44
+ :config => @config_double).
45
+ and_return true
46
+ @catalog_double.should_receive(:create_catalog_domain)
47
+ @catalog_double.stub :entry_exists_in_catalog? => false
48
+ @catalog_double.should_receive(:add_to_catalog).
49
+ with(:regions => @regions,
50
+ :bucket_prefix => 'bp').
51
+ and_return true
52
+ @archive_double.should_receive(:setup).
53
+ with(:regions => @regions,
54
+ :bucket_prefix => 'bp')
55
+ @setup.setup
56
56
  end
57
57
 
58
58
  end
@@ -7,104 +7,104 @@ describe Heirloom do
7
7
  context "testing ensure_valid_options" do
8
8
 
9
9
  before do
10
- @logger_mock = mock 'logger'
11
- @config_mock = mock_config(:logger => @logger_mock)
10
+ @logger_double = double 'logger'
11
+ @config_double = double_config(:logger => @logger_double)
12
12
  @object = Object.new
13
13
  @object.extend Heirloom::CLI::Shared
14
14
  end
15
15
 
16
16
  it "should exit if the secret is given and under 8 characters" do
17
- @logger_mock.should_receive(:error)
18
- @logger_mock.stub :info => true
17
+ @logger_double.should_receive(:error)
18
+ @logger_double.stub :info => true
19
19
  lambda { @object.ensure_valid_secret(:secret => 'shorty',
20
- :config => @config_mock) }.
20
+ :config => @config_double) }.
21
21
  should raise_error SystemExit
22
22
  end
23
23
 
24
24
  it "should return false if a required array is emtpy" do
25
- @logger_mock.should_receive(:error)
25
+ @logger_double.should_receive(:error)
26
26
  lambda { @object.ensure_valid_options(:provided => {
27
27
  :array => [],
28
28
  :string => 'present'
29
29
  },
30
30
  :required => [:array, :string],
31
- :config => @config_mock) }.
31
+ :config => @config_double) }.
32
32
  should raise_error SystemExit
33
33
  end
34
34
 
35
35
  it "should return false if a required string is nil" do
36
- @logger_mock.should_receive(:error)
36
+ @logger_double.should_receive(:error)
37
37
  lambda { @object.ensure_valid_options(:provided => {
38
38
  :array => ['present'],
39
39
  :string => nil
40
40
  },
41
41
  :required => [:array, :string],
42
- :config => @config_mock) }.
42
+ :config => @config_double) }.
43
43
  should raise_error SystemExit
44
44
  end
45
45
 
46
46
  it "should return false if a require string is nil & array is empty" do
47
- @logger_mock.should_receive(:error).exactly(2).times
47
+ @logger_double.should_receive(:error).exactly(2).times
48
48
  lambda { @object.ensure_valid_options(:provided => {
49
49
  :array => [],
50
50
  :string => nil
51
51
  },
52
52
  :required => [:array, :string],
53
- :config => @config_mock) }.
53
+ :config => @config_double) }.
54
54
  should raise_error SystemExit
55
55
  end
56
56
 
57
57
  it "should return true if all options are present" do
58
- @logger_mock.should_receive(:error).exactly(0).times
58
+ @logger_double.should_receive(:error).exactly(0).times
59
59
  @object.ensure_valid_options(:provided => { :array => ['present'],
60
- :string => 'present' },
61
- :required => [:array, :string],
62
- :config => @config_mock)
60
+ :string => 'present' },
61
+ :required => [:array, :string],
62
+ :config => @config_double)
63
63
  end
64
64
  end
65
65
 
66
66
  context "testing load_config" do
67
67
 
68
68
  before do
69
- @config_mock = mock 'config'
70
- @logger_stub = stub 'logger', :debug => true
69
+ @config_double = double 'config'
70
+ @logger_double = double 'logger', :debug => true
71
71
  @object = Object.new
72
72
  @object.extend Heirloom::CLI::Shared
73
- Heirloom::Config.should_receive(:new).with(:logger => @logger_stub, :environment => nil).
74
- and_return @config_mock
75
- @config_mock.stub :proxy => nil
73
+ Heirloom::Config.should_receive(:new).with(:logger => @logger_double, :environment => nil).
74
+ and_return @config_double
75
+ @config_double.stub :proxy => nil
76
76
  end
77
77
 
78
78
  it "should return the configuration" do
79
- @object.load_config(:logger => @logger_stub,
80
- :opts => {}).should == @config_mock
79
+ @object.load_config(:logger => @logger_double,
80
+ :opts => {}).should == @config_double
81
81
  end
82
82
 
83
83
  it "should set the metadata region if specified" do
84
84
  opts = { :metadata_region => 'us-west-1' }
85
- @config_mock.should_receive(:metadata_region=).with 'us-west-1'
86
- @object.load_config :logger => @logger_stub, :opts => opts
85
+ @config_double.should_receive(:metadata_region=).with 'us-west-1'
86
+ @object.load_config :logger => @logger_double, :opts => opts
87
87
  end
88
88
 
89
89
  it "should set the access key if specified" do
90
90
  opts = { :aws_access_key => 'the_key' }
91
- @config_mock.should_receive(:access_key=).with 'the_key'
92
- @object.load_config :logger => @logger_stub, :opts => opts
91
+ @config_double.should_receive(:access_key=).with 'the_key'
92
+ @object.load_config :logger => @logger_double, :opts => opts
93
93
  end
94
94
 
95
95
  it "should set the secret key if specified" do
96
96
  opts = { :aws_secret_key => 'the_secret' }
97
- @config_mock.should_receive(:secret_key=).with 'the_secret'
98
- @object.load_config :logger => @logger_stub, :opts => opts
97
+ @config_double.should_receive(:secret_key=).with 'the_secret'
98
+ @object.load_config :logger => @logger_double, :opts => opts
99
99
  end
100
100
 
101
101
  end
102
102
 
103
103
  context "test ensure directory" do
104
104
  before do
105
- @logger_stub = stub 'logger', :error => true
106
- @config_mock = mock 'config'
107
- @config_mock.stub :logger => @logger_stub
105
+ @logger_double = double 'logger', :error => true
106
+ @config_double = double 'config'
107
+ @config_double.stub :logger => @logger_double
108
108
  @object = Object.new
109
109
  @object.extend Heirloom::CLI::Shared
110
110
  end
@@ -113,48 +113,48 @@ describe Heirloom do
113
113
  File.should_receive(:directory?).with('/tmp/test').
114
114
  and_return false
115
115
  lambda { @object.ensure_path_is_directory(:path => '/tmp/test',
116
- :config => @config_mock) }.
116
+ :config => @config_double) }.
117
117
  should raise_error SystemExit
118
118
  end
119
119
 
120
120
  it "should not exit when path is a directory" do
121
121
  File.should_receive(:directory?).with('/tmp/test').
122
122
  and_return true
123
- @object.ensure_path_is_directory :path => '/tmp/test', :config => @config_mock
123
+ @object.ensure_path_is_directory :path => '/tmp/test', :config => @config_double
124
124
  end
125
125
 
126
126
  it "should exit when directory is not writable" do
127
127
  File.should_receive(:writable?).with('/tmp/test').
128
128
  and_return false
129
129
  lambda { @object.ensure_directory_is_writable(:path => '/tmp/test',
130
- :config => @config_mock) }.
130
+ :config => @config_double) }.
131
131
  should raise_error SystemExit
132
132
  end
133
133
 
134
134
  it "should not exit when directory is writable" do
135
135
  File.should_receive(:writable?).with('/tmp/test').
136
- and_return true
137
- @object.ensure_directory_is_writable :path => '/tmp/test', :config => @config_mock
136
+ and_return true
137
+ @object.ensure_directory_is_writable :path => '/tmp/test', :config => @config_double
138
138
  end
139
139
 
140
140
  end
141
141
 
142
142
  context "testing ensure domain" do
143
143
  before do
144
- @archive_mock = mock 'archive'
145
- @logger_stub = stub 'logger', :error => true
146
- @config_stub = stub 'config', :logger => @logger_stub,
144
+ @archive_double = double 'archive'
145
+ @logger_double = double 'logger', :error => true
146
+ @config_double = double 'config', :logger => @logger_double,
147
147
  :metadata_region => 'us-west-1'
148
148
  @object = Object.new
149
149
  @object.extend Heirloom::CLI::Shared
150
150
  Heirloom::Archive.should_receive(:new).
151
- with(:name => 'test', :config => @config_stub).
152
- and_return @archive_mock
151
+ with(:name => 'test', :config => @config_double).
152
+ and_return @archive_double
153
153
  end
154
154
 
155
155
  it "should exit if the domain does not exist" do
156
- @archive_mock.stub :domain_exists? => false
157
- lambda { @object.ensure_domain_exists :config => @config_stub,
156
+ @archive_double.stub :domain_exists? => false
157
+ lambda { @object.ensure_domain_exists :config => @config_double,
158
158
  :name => 'test'}.
159
159
  should raise_error SystemExit
160
160
  end
@@ -162,16 +162,16 @@ describe Heirloom do
162
162
 
163
163
  context "testing ensure metadata domain" do
164
164
  before do
165
- @archive_mock = mock 'archive'
166
- @logger_stub = stub 'logger', :error => true
167
- @config_stub = stub 'config', :logger => @logger_stub,
165
+ @archive_double = double 'archive'
166
+ @logger_double = double 'logger', :error => true
167
+ @config_double = double 'config', :logger => @logger_double,
168
168
  :metadata_region => 'us-west-1'
169
169
  @object = Object.new
170
170
  @object.extend Heirloom::CLI::Shared
171
171
  end
172
172
 
173
173
  it "should exit if the metadata region is not in an upload region" do
174
- options = { :config => @config_stub, :regions => ['us-west-2', 'us-east-1'] }
174
+ options = { :config => @config_double, :regions => ['us-west-2', 'us-east-1'] }
175
175
  lambda { @object.ensure_metadata_in_upload_region options }.
176
176
  should raise_error SystemExit
177
177
  end
@@ -179,15 +179,15 @@ describe Heirloom do
179
179
 
180
180
  context "testing ensure valid regions" do
181
181
  before do
182
- @logger_stub = stub 'logger', :error => true
183
- @config_stub = stub 'config', :logger => @logger_stub,
182
+ @logger_double = double 'logger', :error => true
183
+ @config_double = double 'config', :logger => @logger_double,
184
184
  :metadata_region => 'us-west-1'
185
185
  @object = Object.new
186
186
  @object.extend Heirloom::CLI::Shared
187
187
  end
188
188
 
189
189
  it "should exit if the region is not valid" do
190
- options = { :config => @config_stub, :regions => ['us-west-2', 'us-bad-1'] }
190
+ options = { :config => @config_double, :regions => ['us-west-2', 'us-bad-1'] }
191
191
  lambda { @object.ensure_valid_regions options }.
192
192
  should raise_error SystemExit
193
193
  end
@@ -196,17 +196,17 @@ describe Heirloom do
196
196
 
197
197
  context "testing ensure archive exists" do
198
198
  before do
199
- @archive_mock = mock 'archive'
200
- @logger_stub = stub 'logger', :error => true
201
- @config_stub = stub 'config', :logger => @logger_stub,
199
+ @archive_double = double 'archive'
200
+ @logger_double = double 'logger', :error => true
201
+ @config_double = double 'config', :logger => @logger_double,
202
202
  :metadata_region => 'us-west-1'
203
203
  @object = Object.new
204
204
  @object.extend Heirloom::CLI::Shared
205
205
  end
206
206
 
207
207
  it "should exit if the archive does not exist" do
208
- @archive_mock.should_receive(:exists?).and_return false
209
- options = { :config => @config_stub, :archive => @archive_mock }
208
+ @archive_double.should_receive(:exists?).and_return false
209
+ options = { :config => @config_double, :archive => @archive_double }
210
210
  lambda { @object.ensure_archive_exists options }.
211
211
  should raise_error SystemExit
212
212
  end
@@ -214,17 +214,17 @@ describe Heirloom do
214
214
 
215
215
  context "testing ensure archive domain empty" do
216
216
  before do
217
- @archive_stub = stub 'archive'
218
- @logger_stub = stub 'logger', :error => true
219
- @config_stub = stub 'config', :logger => @logger_stub,
217
+ @archive_double = double 'archive'
218
+ @logger_double = double 'logger', :error => true
219
+ @config_double = double 'config', :logger => @logger_double,
220
220
  :metadata_region => 'us-west-1'
221
- @options = { :config => @config_stub, :archive => @archive_stub }
221
+ @options = { :config => @config_double, :archive => @archive_double }
222
222
  @object = Object.new
223
223
  @object.extend Heirloom::CLI::Shared
224
224
  end
225
225
 
226
226
  it "should exit if the domain is not empty" do
227
- @archive_stub.stub :count => 200
227
+ @archive_double.stub :count => 200
228
228
  lambda { @object.ensure_archive_domain_empty @options }.
229
229
  should raise_error SystemExit
230
230
  end
@@ -232,17 +232,17 @@ describe Heirloom do
232
232
 
233
233
  context "testing ensure catalog domain exists" do
234
234
  before do
235
- @catalog_mock = mock 'catalog'
236
- @logger_stub = stub 'logger', :error => true
237
- @config_stub = stub 'config', :logger => @logger_stub,
235
+ @catalog_double = double 'catalog'
236
+ @logger_double = double 'logger', :error => true
237
+ @config_double = double 'config', :logger => @logger_double,
238
238
  :metadata_region => 'us-west-1'
239
- @options = { :config => @config_stub, :catalog => @catalog_mock }
239
+ @options = { :config => @config_double, :catalog => @catalog_double }
240
240
  @object = Object.new
241
241
  @object.extend Heirloom::CLI::Shared
242
242
  end
243
243
 
244
244
  it "should exit if the catlog domain does not exist" do
245
- @catalog_mock.stub :catalog_domain_exists? => false
245
+ @catalog_double.stub :catalog_domain_exists? => false
246
246
  lambda { @object.ensure_catalog_domain_exists @options }.
247
247
  should raise_error SystemExit
248
248
  end
@@ -250,21 +250,21 @@ describe Heirloom do
250
250
 
251
251
  context "testing ensure entry (does not) exists in catalog" do
252
252
  before do
253
- @catalog_mock = mock 'catalog'
254
- @logger_stub = stub 'logger', :error => true
255
- @config_stub = stub 'config', :logger => @logger_stub,
253
+ @catalog_double = double 'catalog'
254
+ @logger_double = double 'logger', :error => true
255
+ @config_double = double 'config', :logger => @logger_double,
256
256
  :metadata_region => 'us-west-1'
257
- @options = { :config => @config_stub,
258
- :catalog => @catalog_mock,
257
+ @options = { :config => @config_double,
258
+ :catalog => @catalog_double,
259
259
  :entry => 'entry' }
260
260
  @object = Object.new
261
261
  @object.extend Heirloom::CLI::Shared
262
262
  end
263
263
 
264
264
  it "should exit if the entry does not exist in catalog" do
265
- @catalog_mock.should_receive(:entry_exists_in_catalog?).
266
- with('entry').
267
- and_return false
265
+ @catalog_double.should_receive(:entry_exists_in_catalog?).
266
+ with('entry').
267
+ and_return false
268
268
  lambda { @object.ensure_entry_exists_in_catalog @options }.
269
269
  should raise_error SystemExit
270
270
  end
@@ -273,9 +273,9 @@ describe Heirloom do
273
273
 
274
274
  context "testing latest id" do
275
275
  before do
276
- @archive_mock = mock 'archive'
277
- @config_stub = stub 'config'
278
- @options = { :config => @config_stub, :archive => @archive_stub }
276
+ @archive_double = double 'archive'
277
+ @config_double = double 'config'
278
+ @options = { :config => @config_double, :archive => @archive_double }
279
279
  @object = Object.new
280
280
  @object.extend Heirloom::CLI::Shared
281
281
  end
@@ -283,13 +283,13 @@ describe Heirloom do
283
283
  it "should return the latest id" do
284
284
  Heirloom::Archive.should_receive(:new).
285
285
  with(:name => 'test',
286
- :config => @config_stub).
287
- and_return @archive_mock
288
- @archive_mock.should_receive(:list).
286
+ :config => @config_double).
287
+ and_return @archive_double
288
+ @archive_double.should_receive(:list).
289
289
  with(1).
290
290
  and_return ['id']
291
291
  @object.latest_id(:name => 'test',
292
- :config => @config_stub).
292
+ :config => @config_double).
293
293
  should == 'id'
294
294
  end
295
295
 
@@ -297,10 +297,10 @@ describe Heirloom do
297
297
 
298
298
  context "read secret from file" do
299
299
  before do
300
- @archive_mock = mock 'archive'
301
- @logger_stub = stub 'logger', :error => true
302
- @config_stub = stub 'config', :logger => @logger_stub
303
- @options = { :config => @config_stub, :opts => {} }
300
+ @archive_double = double 'archive'
301
+ @logger_double = double 'logger', :error => true
302
+ @config_double = double 'config', :logger => @logger_double
303
+ @options = { :config => @config_double, :opts => {} }
304
304
  @object = Object.new
305
305
  @object.extend Heirloom::CLI::Shared
306
306
  end
@@ -313,7 +313,7 @@ describe Heirloom do
313
313
  end
314
314
 
315
315
  it "should return the contents of the file with newline removed" do
316
- file_mock = mock 'file'
316
+ file_double = double 'file'
317
317
  @options[:opts][:secret_file] = '/good/file'
318
318
  File.stub :exists? => true
319
319
  File.should_receive(:read).
@@ -332,33 +332,33 @@ describe Heirloom do
332
332
 
333
333
  context "ensure buckets are available or owned by account" do
334
334
  before do
335
- @logger_stub = stub 'logger', :error => true
336
- @config_stub = stub 'config', :logger => @logger_stub
337
- @checker_mock = mock 'checker'
338
- @args = { :config => @config_stub,
335
+ @logger_double = double 'logger', :error => true
336
+ @config_double = double 'config', :logger => @logger_double
337
+ @checker_double = double 'checker'
338
+ @args = { :config => @config_double,
339
339
  :bucket_prefix => 'intu-lc',
340
340
  :regions => ['us-west-1', 'us-west-2'] }
341
341
  @object = Object.new
342
342
  @object.extend Heirloom::CLI::Shared
343
343
  Heirloom::Checker.should_receive(:new).
344
- with(:config => @config_stub).
345
- and_return @checker_mock
344
+ with(:config => @config_double).
345
+ and_return @checker_double
346
346
  end
347
347
 
348
348
  it "should return true if buckets available in all regions" do
349
- @checker_mock.should_receive(:bucket_name_available?).
349
+ @checker_double.should_receive(:bucket_name_available?).
350
350
  with(:bucket_prefix => 'intu-lc',
351
351
  :regions => ['us-west-1', 'us-west-2'],
352
- :config => @config_stub).
352
+ :config => @config_double).
353
353
  and_return true
354
354
  @object.ensure_buckets_available(@args).should be_true
355
355
  end
356
356
 
357
357
  it "should return raise and error if any bucket un-available in all regions" do
358
- @checker_mock.should_receive(:bucket_name_available?).
358
+ @checker_double.should_receive(:bucket_name_available?).
359
359
  with(:bucket_prefix => 'intu-lc',
360
360
  :regions => ['us-west-1', 'us-west-2'],
361
- :config => @config_stub).
361
+ :config => @config_double).
362
362
  and_return false
363
363
  lambda { @object.ensure_buckets_available(@args) }.
364
364
  should raise_error SystemExit
@@ -367,20 +367,20 @@ describe Heirloom do
367
367
 
368
368
  context "testing ensure entry does not exist in catalog unless forced" do
369
369
  before do
370
- @catalog_mock = mock 'catalog'
371
- @logger_stub = stub 'logger', :error => true
372
- @config_stub = stub 'config', :logger => @logger_stub,
370
+ @catalog_double = double 'catalog'
371
+ @logger_double = double 'logger', :error => true
372
+ @config_double = double 'config', :logger => @logger_double,
373
373
  :metadata_region => 'us-west-1'
374
374
  @object = Object.new
375
375
  @object.extend Heirloom::CLI::Shared
376
376
  end
377
377
 
378
378
  it "should exit if the entry exists in catalog and not forced" do
379
- options = { :config => @config_stub,
380
- :catalog => @catalog_mock,
379
+ options = { :config => @config_double,
380
+ :catalog => @catalog_double,
381
381
  :entry => 'entry',
382
382
  :force => false }
383
- @catalog_mock.should_receive(:entry_exists_in_catalog?).
383
+ @catalog_double.should_receive(:entry_exists_in_catalog?).
384
384
  with('entry').
385
385
  and_return true
386
386
  lambda { @object.ensure_entry_does_not_exist_in_catalog options }.
@@ -388,22 +388,22 @@ describe Heirloom do
388
388
  end
389
389
 
390
390
  it "should not exit if the entry exists in catalog and forced" do
391
- options = { :config => @config_stub,
392
- :catalog => @catalog_mock,
391
+ options = { :config => @config_double,
392
+ :catalog => @catalog_double,
393
393
  :entry => 'entry',
394
394
  :force => true }
395
- @catalog_mock.should_receive(:entry_exists_in_catalog?).
395
+ @catalog_double.should_receive(:entry_exists_in_catalog?).
396
396
  with('entry').
397
397
  and_return true
398
398
  @object.ensure_entry_does_not_exist_in_catalog options
399
399
  end
400
400
 
401
401
  it "should not exit if the does not exists in catalog" do
402
- options = { :config => @config_stub,
403
- :catalog => @catalog_mock,
402
+ options = { :config => @config_double,
403
+ :catalog => @catalog_double,
404
404
  :entry => 'entry',
405
405
  :force => false }
406
- @catalog_mock.should_receive(:entry_exists_in_catalog?).
406
+ @catalog_double.should_receive(:entry_exists_in_catalog?).
407
407
  with('entry').
408
408
  and_return false
409
409
  @object.ensure_entry_does_not_exist_in_catalog options
@@ -412,32 +412,32 @@ describe Heirloom do
412
412
 
413
413
  context "testing ensure valid name" do
414
414
  before do
415
- @logger_stub = stub 'logger', :error => true
416
- @config_stub = stub 'config', :logger => @logger_stub,
415
+ @logger_double = double 'logger', :error => true
416
+ @config_double = double 'config', :logger => @logger_double,
417
417
  :metadata_region => 'us-west-1'
418
418
  @object = Object.new
419
419
  @object.extend Heirloom::CLI::Shared
420
420
  end
421
421
 
422
422
  it "should not exit if name is valid" do
423
- @object.ensure_valid_name :config => @config_stub,
423
+ @object.ensure_valid_name :config => @config_double,
424
424
  :name => 'test-123_test'
425
425
  end
426
426
 
427
427
  it "should exit if name contains a upper case" do
428
- lambda { @object.ensure_valid_name :config => @config_stub,
428
+ lambda { @object.ensure_valid_name :config => @config_double,
429
429
  :name => 'TEST-123' }.
430
430
  should raise_error SystemExit
431
431
  end
432
432
 
433
433
  it "should exit if name contains a space" do
434
- lambda { @object.ensure_valid_name :config => @config_stub,
434
+ lambda { @object.ensure_valid_name :config => @config_double,
435
435
  :name => 'test 123' }.
436
436
  should raise_error SystemExit
437
437
  end
438
438
 
439
439
  it "should exit if name contains invalid characters" do
440
- lambda { @object.ensure_valid_name :config => @config_stub,
440
+ lambda { @object.ensure_valid_name :config => @config_double,
441
441
  :name => 'test,123' }.
442
442
  should raise_error SystemExit
443
443
  end
@@ -445,32 +445,32 @@ describe Heirloom do
445
445
 
446
446
  context "testing ensure valid bucket prefix" do
447
447
  before do
448
- @logger_stub = stub 'logger', :error => true
449
- @config_stub = stub 'config', :logger => @logger_stub,
448
+ @logger_double = double 'logger', :error => true
449
+ @config_double = double 'config', :logger => @logger_double,
450
450
  :metadata_region => 'us-west-1'
451
451
  @object = Object.new
452
452
  @object.extend Heirloom::CLI::Shared
453
453
  end
454
454
 
455
455
  it "should not exit if bucket_prefix is valid" do
456
- @object.ensure_valid_bucket_prefix :config => @config_stub,
456
+ @object.ensure_valid_bucket_prefix :config => @config_double,
457
457
  :bucket_prefix => 'test-123'
458
458
  end
459
459
 
460
460
  it "should exit if bucket_prefix contains uppercase" do
461
- lambda { @object.ensure_valid_bucket_prefix :config => @config_stub,
461
+ lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
462
462
  :bucket_prefix => 'TEST-123' }.
463
463
  should raise_error SystemExit
464
464
  end
465
465
 
466
466
  it "should exit if bucket_prefix contains a space" do
467
- lambda { @object.ensure_valid_bucket_prefix :config => @config_stub,
467
+ lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
468
468
  :bucket_prefix => 'test 123' }.
469
469
  should raise_error SystemExit
470
470
  end
471
471
 
472
472
  it "should exit if bucket_prefix contains invalid characters" do
473
- lambda { @object.ensure_valid_bucket_prefix :config => @config_stub,
473
+ lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
474
474
  :bucket_prefix => 'test,123' }.
475
475
  should raise_error SystemExit
476
476
  end