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
@@ -5,8 +5,8 @@ describe Heirloom do
5
5
 
6
6
  it "should use the access and secret keys by default" do
7
7
 
8
- config = mock_config :aws_access_key_id => 'key',
9
- :aws_secret_access_key => 'secret'
8
+ config = double_config :aws_access_key_id => 'key',
9
+ :aws_secret_access_key => 'secret'
10
10
 
11
11
  Fog::Storage.should_receive(:new).
12
12
  with :provider => 'AWS',
@@ -19,8 +19,8 @@ describe Heirloom do
19
19
 
20
20
  it "should use the iam role if asked to" do
21
21
 
22
- config = mock_config :use_iam_profile => true
23
-
22
+ config = double_config :use_iam_profile => true
23
+
24
24
  Fog::Storage.should_receive(:new).
25
25
  with :provider => 'AWS',
26
26
  :use_iam_profile => true,
@@ -33,121 +33,121 @@ describe Heirloom do
33
33
  context "s3 / bucket operations" do
34
34
 
35
35
  before do
36
- @directories_mock = mock 'directories'
37
- @bucket_mock = mock 'bucket'
38
- @fog_mock = mock 'fog'
39
- @fog_mock.stub :directories => @directories_mock
40
- Fog::Storage.stub :new => @fog_mock
41
- @s3 = Heirloom::AWS::S3.new :config => mock_config, :region => 'us-west-1'
36
+ @directories_double = double 'directories'
37
+ @bucket_double = double 'bucket'
38
+ @fog_double = double 'fog'
39
+ @fog_double.stub :directories => @directories_double
40
+ Fog::Storage.stub :new => @fog_double
41
+ @s3 = Heirloom::AWS::S3.new :config => double_config, :region => 'us-west-1'
42
42
  end
43
43
 
44
44
  context "bucket_exists?" do
45
45
  it "should return true if the bucket exists" do
46
- @directories_mock.should_receive(:get).
47
- with('bucket').and_return @bucket_mock
46
+ @directories_double.should_receive(:get).
47
+ with('bucket').and_return @bucket_double
48
48
  @s3.bucket_exists?('bucket').should be_true
49
49
  end
50
50
 
51
51
  it "should return false if the bucket does not exist" do
52
- @directories_mock.should_receive(:get).
53
- with('bucket').and_return nil
52
+ @directories_double.should_receive(:get).
53
+ with('bucket').and_return nil
54
54
  @s3.bucket_exists?('bucket').should be_false
55
55
  end
56
56
 
57
57
  it "should return false if bucket owned by another account" do
58
- @directories_mock.should_receive(:get).
59
- with('bucket').
60
- and_raise Excon::Errors::Forbidden.new('msg')
58
+ @directories_double.should_receive(:get).
59
+ with('bucket').
60
+ and_raise Excon::Errors::Forbidden.new('msg')
61
61
  @s3.bucket_exists?('bucket').should be_false
62
62
  end
63
63
  end
64
64
 
65
65
  context "bucket_exists_in_another_region?" do
66
66
  it "should return true if the bucket exists in another region" do
67
- @bucket_mock.stub :location => 'us-east-1'
68
- @directories_mock.should_receive(:get).
69
- with('bucket').at_least(:once).
70
- and_return @bucket_mock
67
+ @bucket_double.stub :location => 'us-east-1'
68
+ @directories_double.should_receive(:get).
69
+ with('bucket').at_least(:once).
70
+ and_return @bucket_double
71
71
  @s3.bucket_exists_in_another_region?('bucket').should be_true
72
72
  end
73
73
 
74
74
  it "should return false if the bucket exists in the curren region" do
75
- @bucket_mock.stub :location => 'us-west-1'
76
- @directories_mock.should_receive(:get).
77
- with('bucket').at_least(:once).
78
- and_return @bucket_mock
75
+ @bucket_double.stub :location => 'us-west-1'
76
+ @directories_double.should_receive(:get).
77
+ with('bucket').at_least(:once).
78
+ and_return @bucket_double
79
79
  @s3.bucket_exists_in_another_region?('bucket').should be_false
80
80
  end
81
81
 
82
82
  it "should return false if bucket owned by another account" do
83
- @directories_mock.should_receive(:get).
84
- with('bucket').
85
- and_raise Excon::Errors::Forbidden.new('msg')
83
+ @directories_double.should_receive(:get).
84
+ with('bucket').
85
+ and_raise Excon::Errors::Forbidden.new('msg')
86
86
  @s3.bucket_exists_in_another_region?('bucket').should be_false
87
87
  end
88
88
  end
89
89
 
90
90
  context "bucket_owned_by_another_account?" do
91
91
  it "should return false if bucket owned by this account" do
92
- @directories_mock.should_receive(:get).
93
- with('bucket').
94
- and_return @bucket_mock
92
+ @directories_double.should_receive(:get).
93
+ with('bucket').
94
+ and_return @bucket_double
95
95
  @s3.bucket_owned_by_another_account?('bucket').should be_false
96
96
  end
97
97
 
98
98
  it "should return false if bucket does not exist" do
99
- @directories_mock.should_receive(:get).
100
- with('bucket').
101
- and_return nil
99
+ @directories_double.should_receive(:get).
100
+ with('bucket').
101
+ and_return nil
102
102
  @s3.bucket_owned_by_another_account?('bucket').should be_false
103
103
  end
104
104
 
105
105
  it "should return true if bucket is not owned by another account" do
106
- @directories_mock.should_receive(:get).
107
- with('bucket').
108
- and_raise Excon::Errors::Forbidden.new('msg')
106
+ @directories_double.should_receive(:get).
107
+ with('bucket').
108
+ and_raise Excon::Errors::Forbidden.new('msg')
109
109
  @s3.bucket_owned_by_another_account?('bucket').should be_true
110
110
  end
111
111
  end
112
112
 
113
113
  it "should delete an object from s3" do
114
- @fog_mock.should_receive(:delete_object).
115
- with('bucket', 'object', { :option => 'test' })
114
+ @fog_double.should_receive(:delete_object).
115
+ with('bucket', 'object', { :option => 'test' })
116
116
  @s3.delete_object('bucket', 'object', { :option => 'test' })
117
117
  end
118
118
 
119
119
  it "should get a bucket from s3" do
120
- @directories_mock.should_receive(:get).with 'bucket'
120
+ @directories_double.should_receive(:get).with 'bucket'
121
121
  @s3.get_bucket 'bucket'
122
122
  end
123
123
 
124
124
  context "testing bucket availability" do
125
125
 
126
126
  it "should return false if the bucket is forbidden" do
127
- @directories_mock.should_receive(:get).
128
- with('bucket').
129
- and_raise Excon::Errors::Forbidden.new('msg')
127
+ @directories_double.should_receive(:get).
128
+ with('bucket').
129
+ and_raise Excon::Errors::Forbidden.new('msg')
130
130
  @s3.bucket_name_available?('bucket').should be_false
131
131
  end
132
132
 
133
133
  it "should return false if bucket in different region" do
134
- @directories_mock.should_receive(:get).
135
- with('bucket').at_least(:once).
136
- and_return @bucket_mock
137
- @bucket_mock.stub :location => 'us-east-1'
134
+ @directories_double.should_receive(:get).
135
+ with('bucket').at_least(:once).
136
+ and_return @bucket_double
137
+ @bucket_double.stub :location => 'us-east-1'
138
138
  @s3.bucket_name_available?('bucket').should be_false
139
139
  end
140
140
 
141
141
  it "should return true if the bucket is in this account / region" do
142
- @directories_mock.should_receive(:get).
143
- with('bucket').at_least(:once).
144
- and_return @bucket_mock
145
- @bucket_mock.stub :location => 'us-west-1'
142
+ @directories_double.should_receive(:get).
143
+ with('bucket').at_least(:once).
144
+ and_return @bucket_double
145
+ @bucket_double.stub :location => 'us-west-1'
146
146
  @s3.bucket_name_available?('bucket').should be_true
147
147
  end
148
148
 
149
149
  it "should return true if the bucket is not found" do
150
- @directories_mock.should_receive(:get).
150
+ @directories_double.should_receive(:get).
151
151
  with('bucket').at_least(:once).
152
152
  and_return nil
153
153
  @s3.bucket_name_available?('bucket').should be_true
@@ -156,110 +156,110 @@ describe Heirloom do
156
156
  end
157
157
 
158
158
  it "should return object versions for a given bucket" do
159
- body_mock = mock 'body'
160
- @fog_mock.should_receive(:get_bucket_object_versions).
161
- with('bucket').
162
- and_return body_mock
163
- body_mock.stub :body => 'body_hash'
159
+ body_double = double 'body'
160
+ @fog_double.should_receive(:get_bucket_object_versions).
161
+ with('bucket').
162
+ and_return body_double
163
+ body_double.stub :body => 'body_hash'
164
164
  @s3.get_bucket_object_versions('bucket').should == 'body_hash'
165
165
  end
166
166
 
167
167
  context "testing bucket deletion" do
168
168
  it "should return true if the bucket has 0 objects" do
169
- body_mock = mock 'body'
170
- @fog_mock.should_receive(:get_bucket_object_versions).
171
- with('bucket').
172
- and_return body_mock
173
- body_mock.stub :body => { "Versions" => [ ] }
169
+ body_double = double 'body'
170
+ @fog_double.should_receive(:get_bucket_object_versions).
171
+ with('bucket').
172
+ and_return body_double
173
+ body_double.stub :body => { "Versions" => [ ] }
174
174
  @s3.bucket_empty?('bucket').should be_true
175
175
  end
176
176
 
177
177
  it "should return false if the bucket has any objects" do
178
- body_mock = mock 'body'
179
- @fog_mock.should_receive(:get_bucket_object_versions).
180
- with('bucket').
181
- and_return body_mock
182
- body_mock.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
178
+ body_double = double 'body'
179
+ @fog_double.should_receive(:get_bucket_object_versions).
180
+ with('bucket').
181
+ and_return body_double
182
+ body_double.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
183
183
  @s3.bucket_empty?('bucket').should be_false
184
184
  end
185
185
 
186
186
  it "should delete a bucket from s3 if empty" do
187
- body_mock = mock 'body'
188
- @fog_mock.should_receive(:get_bucket_object_versions).
187
+ body_double = double 'body'
188
+ @fog_double.should_receive(:get_bucket_object_versions).
189
189
  with('bucket').
190
- and_return body_mock
191
- body_mock.stub :body => { "Versions" => [ ] }
192
- @fog_mock.should_receive(:delete_bucket).
190
+ and_return body_double
191
+ body_double.stub :body => { "Versions" => [ ] }
192
+ @fog_double.should_receive(:delete_bucket).
193
193
  with('bucket').and_return true
194
194
  @s3.delete_bucket('bucket').should be_true
195
195
  end
196
196
 
197
197
  it "should return false and not attempt to delete a non empty s3 bucket" do
198
- body_mock = mock 'body'
199
- @fog_mock.should_receive(:get_bucket_object_versions).
200
- with('bucket').
201
- and_return body_mock
202
- body_mock.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
203
- @fog_mock.should_receive(:delete_bucket).never
198
+ body_double = double 'body'
199
+ @fog_double.should_receive(:get_bucket_object_versions).
200
+ with('bucket').
201
+ and_return body_double
202
+ body_double.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
203
+ @fog_double.should_receive(:delete_bucket).never
204
204
  @s3.delete_bucket('bucket').should be_false
205
205
  end
206
206
 
207
207
  it "should return true if Excon::Errors::NotFound raised when deleting bucket" do
208
- @fog_mock.should_receive(:get_bucket_object_versions).
209
- with('bucket').
210
- and_raise Excon::Errors::NotFound.new 'Bucket does not exist.'
211
- @fog_mock.should_receive(:delete_bucket).never
208
+ @fog_double.should_receive(:get_bucket_object_versions).
209
+ with('bucket').
210
+ and_raise Excon::Errors::NotFound.new 'Bucket does not exist.'
211
+ @fog_double.should_receive(:delete_bucket).never
212
212
  @s3.delete_bucket('bucket').should be_true
213
213
  end
214
214
  end
215
215
 
216
216
  it "should get an object from s3" do
217
- body_mock = mock 'body'
218
- @fog_mock.should_receive(:get_object).
219
- with('bucket', 'object').
220
- and_return body_mock
221
- body_mock.stub :body => 'body_hash'
217
+ body_double = double 'body'
218
+ @fog_double.should_receive(:get_object).
219
+ with('bucket', 'object').
220
+ and_return body_double
221
+ body_double.stub :body => 'body_hash'
222
222
  @s3.get_object('bucket', 'object').should == 'body_hash'
223
223
  end
224
224
 
225
225
  it "should get a buckets acl from s3" do
226
- body_mock = mock 'body'
227
- @fog_mock.should_receive(:get_object).
228
- with('bucket', 'object').
229
- and_return body_mock
230
- body_mock.should_receive(:body)
226
+ body_double = double 'body'
227
+ @fog_double.should_receive(:get_object).
228
+ with('bucket', 'object').
229
+ and_return body_double
230
+ body_double.should_receive(:body)
231
231
  @s3.get_object('bucket', 'object')
232
232
  end
233
233
 
234
234
  it "should get an objects acl from s3" do
235
- body_mock = mock 'body'
236
- @fog_mock.should_receive(:get_object_acl).
237
- with('bucket', 'object').and_return(body_mock)
238
- body_mock.stub :body => 'data'
235
+ body_double = double 'body'
236
+ @fog_double.should_receive(:get_object_acl).
237
+ with('bucket', 'object').and_return(body_double)
238
+ body_double.stub :body => 'data'
239
239
  @s3.get_object_acl({ :bucket => 'bucket', :object_name => 'object'}).
240
240
  should == 'data'
241
241
  end
242
242
 
243
243
 
244
244
  it "should set object acls" do
245
- @fog_mock.should_receive(:put_object_acl).
246
- with 'bucket', 'object', 'grants'
245
+ @fog_double.should_receive(:put_object_acl).
246
+ with 'bucket', 'object', 'grants'
247
247
  @s3.put_object_acl 'bucket', 'object', 'grants'
248
248
  end
249
249
 
250
250
  it "should call put bucket with location_constraint us-west-1" do
251
251
  options = { 'LocationConstraint' => 'us-west-1',
252
252
  'x-amz-acl' => 'private' }
253
- @fog_mock.should_receive(:put_bucket).
254
- with('name', options)
253
+ @fog_double.should_receive(:put_bucket).
254
+ with('name', options)
255
255
  @s3.put_bucket 'name', 'us-west-1'
256
256
  end
257
257
 
258
258
  it "should call put bucket with location_constraint nil when region us-west-1" do
259
259
  options = { 'LocationConstraint' => nil,
260
260
  'x-amz-acl' => 'private' }
261
- @fog_mock.should_receive(:put_bucket).
262
- with('name', options)
261
+ @fog_double.should_receive(:put_bucket).
262
+ with('name', options)
263
263
  @s3.put_bucket 'name', 'us-east-1'
264
264
  end
265
265
 
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Heirloom::AWS::SimpleDB do
4
4
 
5
- let(:sdb) { Heirloom::AWS::SimpleDB.new :config => mock_config }
5
+ let(:sdb) { Heirloom::AWS::SimpleDB.new :config => double_config }
6
6
 
7
7
  context "credential management" do
8
8
  it "should use the access and secret keys by default" do
9
- config = mock_config :aws_access_key_id => 'key',
10
- :aws_secret_access_key => 'secret'
9
+ config = double_config :aws_access_key_id => 'key',
10
+ :aws_secret_access_key => 'secret'
11
11
 
12
12
  Fog::AWS::SimpleDB.should_receive(:new).
13
13
  with :aws_access_key_id => 'key',
@@ -18,7 +18,7 @@ describe Heirloom::AWS::SimpleDB do
18
18
  end
19
19
 
20
20
  it "should use the iam role if asked to" do
21
- config = mock_config :use_iam_profile => true
21
+ config = double_config :use_iam_profile => true
22
22
 
23
23
  Fog::AWS::SimpleDB.should_receive(:new).
24
24
  with :use_iam_profile => true,
@@ -28,117 +28,87 @@ describe Heirloom::AWS::SimpleDB do
28
28
 
29
29
  end
30
30
 
31
- # Data recorded with VCR after running ./spec/fixtures/create_test_data.sh
32
- context "select", :vcr => true do
33
- let(:sdb) { Heirloom::AWS::SimpleDB.new :config => integration_or_mock_config }
34
-
35
- before do
36
- @q = "select * from `heirloom_test_data` where built_at > '2000-01-01T00:00:00.000Z' order by built_at desc"
37
- end
38
-
39
- it "should get results" do
40
- keys = sdb.select(@q).keys
41
- keys.size.should == 10
42
- keys.first.should == "v10"
43
- end
44
-
45
- it "should be able to offset results" do
46
- keys = sdb.select(@q, :offset => 2).keys
47
- keys.size.should == 8
48
- keys.first.should == "v8"
49
- end
50
-
51
- it "should yield when requested" do
52
- num_yields = 0
53
- sdb.select(@q, :offset => 2) do |k, v|
54
- num_yields += 1
55
- end
56
- num_yields.should == 8
57
- end
58
-
59
- end
60
-
61
31
  context "sdb operations" do
62
32
  before do
63
- @fog_mock = mock 'fog'
64
- Fog::AWS::SimpleDB.stub :new => @fog_mock
33
+ @fog_double = double 'fog'
34
+ Fog::AWS::SimpleDB.stub :new => @fog_double
65
35
  end
66
36
 
67
37
  it "should list the domains in simples db" do
68
- body_mock = mock 'body'
69
- @fog_mock.should_receive(:list_domains).
70
- and_return body_mock
71
- body_mock.should_receive(:body).
72
- and_return 'Domains' => ['domain1']
38
+ body_double = double 'body'
39
+ @fog_double.should_receive(:list_domains).
40
+ and_return body_double
41
+ body_double.should_receive(:body).
42
+ and_return 'Domains' => ['domain1']
73
43
  sdb.domains.should == ['domain1']
74
44
  end
75
45
 
76
46
  it "should create a new domain when it does not exist" do
77
47
  sdb.should_receive(:domains).and_return([])
78
- @fog_mock.should_receive(:create_domain).with('new_domain')
48
+ @fog_double.should_receive(:create_domain).with('new_domain')
79
49
  sdb.create_domain('new_domain')
80
50
  end
81
51
 
82
52
  it "should destroy the specified domain" do
83
- @fog_mock.should_receive(:delete_domain).with('new_domain')
53
+ @fog_double.should_receive(:delete_domain).with('new_domain')
84
54
  sdb.delete_domain('new_domain')
85
55
  end
86
56
 
87
57
  it "should not create a new domain when already exists" do
88
58
  sdb.should_receive(:domains).and_return(['new_domain'])
89
- @fog_mock.should_receive(:create_domain).exactly(0).times
59
+ @fog_double.should_receive(:create_domain).exactly(0).times
90
60
  sdb.create_domain('new_domain')
91
61
  end
92
62
 
93
63
  it "should update the attributes for an entry" do
94
- @fog_mock.should_receive(:put_attributes).
64
+ @fog_double.should_receive(:put_attributes).
95
65
  with('domain', 'key', {'key' => 'value'}, { "option" => "123" })
96
66
  sdb.put_attributes('domain', 'key', {'key' => 'value'}, { "option" => "123" })
97
67
  end
98
68
 
99
69
  it "should delete the given entry from sdb" do
100
- @fog_mock.should_receive(:delete_attributes).with('domain', 'key')
70
+ @fog_double.should_receive(:delete_attributes).with('domain', 'key')
101
71
  sdb.delete('domain', 'key')
102
72
  end
103
73
 
104
74
  context "testing counts" do
105
75
  before do
106
- @body_stub = stub 'body'
76
+ @body_double = double 'body'
107
77
  end
108
78
 
109
79
  it "should count the number of entries in the domain" do
110
80
  data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
111
- @fog_mock.should_receive(:select).
112
- with('SELECT count(*) FROM `heirloom_domain`').
113
- and_return @body_stub
114
- @body_stub.stub :body => data
81
+ @fog_double.should_receive(:select).
82
+ with('SELECT count(*) FROM `heirloom_domain`').
83
+ and_return @body_double
84
+ @body_double.stub :body => data
115
85
  sdb.count('heirloom_domain').should == 1
116
86
  end
117
87
 
118
88
  it "should return true if no entries for the domain" do
119
89
  data = { 'Items' => { 'Domain' => { 'Count' => ['0'] } } }
120
- @fog_mock.should_receive(:select).
121
- with('SELECT count(*) FROM `heirloom_domain`').
122
- and_return @body_stub
123
- @body_stub.stub :body => data
90
+ @fog_double.should_receive(:select).
91
+ with('SELECT count(*) FROM `heirloom_domain`').
92
+ and_return @body_double
93
+ @body_double.stub :body => data
124
94
  sdb.domain_empty?('heirloom_domain').should be_true
125
95
  end
126
96
 
127
97
  it "should return false if entries exist for the domain" do
128
98
  data = { 'Items' => { 'Domain' => { 'Count' => ['50'] } } }
129
- @fog_mock.should_receive(:select).
130
- with('SELECT count(*) FROM `heirloom_domain`').
131
- and_return @body_stub
132
- @body_stub.stub :body => data
99
+ @fog_double.should_receive(:select).
100
+ with('SELECT count(*) FROM `heirloom_domain`').
101
+ and_return @body_double
102
+ @body_double.stub :body => data
133
103
  sdb.domain_empty?('heirloom_domain').should be_false
134
104
  end
135
105
 
136
106
  it "should return the count for a specific itemName within a domain" do
137
107
  data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
138
- @fog_mock.should_receive(:select).
139
- with("SELECT count(*) FROM `heirloom` WHERE itemName() = 'archive'").
140
- and_return @body_stub
141
- @body_stub.stub :body => data
108
+ @fog_double.should_receive(:select).
109
+ with("SELECT count(*) FROM `heirloom` WHERE itemName() = 'archive'").
110
+ and_return @body_double
111
+ @body_double.stub :body => data
142
112
  sdb.item_count('heirloom', 'archive').should == 1
143
113
  end
144
114
  end