heirloom 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +12 -6
- data/heirloom.gemspec +3 -5
- data/lib/heirloom/catalog/verify.rb +2 -2
- data/lib/heirloom/cli/authorize.rb +1 -2
- data/lib/heirloom/cli/catalog.rb +62 -19
- data/lib/heirloom/cli/cleanup.rb +1 -2
- data/lib/heirloom/cli/destroy.rb +1 -2
- data/lib/heirloom/cli/download.rb +2 -3
- data/lib/heirloom/cli/formatter/catalog.rb +25 -11
- data/lib/heirloom/cli/list.rb +1 -3
- data/lib/heirloom/cli/rotate.rb +1 -2
- data/lib/heirloom/cli/setup.rb +1 -2
- data/lib/heirloom/cli/shared.rb +3 -0
- data/lib/heirloom/cli/show.rb +1 -3
- data/lib/heirloom/cli/tag.rb +1 -2
- data/lib/heirloom/cli/teardown.rb +1 -2
- data/lib/heirloom/cli/upload.rb +1 -2
- data/lib/heirloom/version.rb +1 -1
- data/spec/acl/s3_spec.rb +11 -11
- data/spec/archive/authorizer_spec.rb +20 -20
- data/spec/archive/builder_spec.rb +13 -13
- data/spec/archive/checker_spec.rb +24 -24
- data/spec/archive/destroyer_spec.rb +20 -20
- data/spec/archive/downloader_spec.rb +30 -30
- data/spec/archive/lister_spec.rb +7 -7
- data/spec/archive/reader_spec.rb +65 -65
- data/spec/archive/setup_spec.rb +27 -27
- data/spec/archive/teardowner_spec.rb +19 -19
- data/spec/archive/updater_spec.rb +10 -10
- data/spec/archive/uploader_spec.rb +26 -26
- data/spec/archive/verifier_spec.rb +25 -25
- data/spec/archive/writer_spec.rb +11 -11
- data/spec/archive_spec.rb +91 -93
- data/spec/aws/s3_spec.rb +102 -102
- data/spec/aws/simpledb_spec.rb +33 -63
- data/spec/catalog/add_spec.rb +12 -12
- data/spec/catalog/delete_spec.rb +14 -14
- data/spec/catalog/list_spec.rb +8 -8
- data/spec/catalog/setup_spec.rb +11 -11
- data/spec/catalog/show_spec.rb +13 -13
- data/spec/catalog/verify_spec.rb +16 -16
- data/spec/catalog_spec.rb +36 -36
- data/spec/cipher/data_spec.rb +19 -19
- data/spec/cipher/file_spec.rb +11 -11
- data/spec/cli/authorize_spec.rb +16 -16
- data/spec/cli/catalog_spec.rb +18 -34
- data/spec/cli/destroy_spec.rb +13 -13
- data/spec/cli/download_spec.rb +31 -31
- data/spec/cli/formatter/catalog_spec.rb +19 -17
- data/spec/cli/list_spec.rb +14 -14
- data/spec/cli/rotate_spec.rb +9 -9
- data/spec/cli/setup_spec.rb +29 -29
- data/spec/cli/shared_spec.rb +119 -119
- data/spec/cli/show_spec.rb +20 -20
- data/spec/cli/tag_spec.rb +18 -18
- data/spec/cli/teardown_spec.rb +28 -28
- data/spec/cli/upload_spec.rb +38 -38
- data/spec/config_spec.rb +21 -21
- data/spec/destroyer/s3_spec.rb +6 -6
- data/spec/directory/directory_spec.rb +19 -19
- data/spec/downloader/s3_spec.rb +18 -18
- data/spec/logger_spec.rb +9 -9
- data/spec/spec_helper.rb +4 -80
- data/spec/uploader/s3_spec.rb +35 -35
- metadata +23 -56
- data/spec/integration/authorize_spec.rb +0 -79
- data/spec/integration/cleanup_spec.rb +0 -77
- data/watchr.rb +0 -101
data/spec/aws/s3_spec.rb
CHANGED
@@ -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 =
|
9
|
-
|
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 =
|
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
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
Fog::Storage.stub :new => @
|
41
|
-
@s3 = Heirloom::AWS::S3.new :config =>
|
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
|
-
@
|
47
|
-
|
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
|
-
@
|
53
|
-
|
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
|
-
@
|
59
|
-
|
60
|
-
|
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
|
-
@
|
68
|
-
@
|
69
|
-
|
70
|
-
|
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
|
-
@
|
76
|
-
@
|
77
|
-
|
78
|
-
|
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
|
-
@
|
84
|
-
|
85
|
-
|
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
|
-
@
|
93
|
-
|
94
|
-
|
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
|
-
@
|
100
|
-
|
101
|
-
|
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
|
-
@
|
107
|
-
|
108
|
-
|
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
|
-
@
|
115
|
-
|
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
|
-
@
|
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
|
-
@
|
128
|
-
|
129
|
-
|
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
|
-
@
|
135
|
-
|
136
|
-
|
137
|
-
@
|
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
|
-
@
|
143
|
-
|
144
|
-
|
145
|
-
@
|
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
|
-
@
|
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
|
-
|
160
|
-
@
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
-
|
170
|
-
@
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
179
|
-
@
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
188
|
-
@
|
187
|
+
body_double = double 'body'
|
188
|
+
@fog_double.should_receive(:get_bucket_object_versions).
|
189
189
|
with('bucket').
|
190
|
-
and_return
|
191
|
-
|
192
|
-
@
|
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
|
-
|
199
|
-
@
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
@
|
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
|
-
@
|
209
|
-
|
210
|
-
|
211
|
-
@
|
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
|
-
|
218
|
-
@
|
219
|
-
|
220
|
-
|
221
|
-
|
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
|
-
|
227
|
-
@
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
-
|
236
|
-
@
|
237
|
-
|
238
|
-
|
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
|
-
@
|
246
|
-
|
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
|
-
@
|
254
|
-
|
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
|
-
@
|
262
|
-
|
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
|
|
data/spec/aws/simpledb_spec.rb
CHANGED
@@ -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 =>
|
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 =
|
10
|
-
|
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 =
|
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
|
-
@
|
64
|
-
Fog::AWS::SimpleDB.stub :new => @
|
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
|
-
|
69
|
-
@
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
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
|
-
@
|
112
|
-
|
113
|
-
|
114
|
-
@
|
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
|
-
@
|
121
|
-
|
122
|
-
|
123
|
-
@
|
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
|
-
@
|
130
|
-
|
131
|
-
|
132
|
-
@
|
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
|
-
@
|
139
|
-
|
140
|
-
|
141
|
-
@
|
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
|