fake-aws-sdk 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fake_aws/s3/bucket.rb +9 -1
- data/lib/fake_aws/s3/bucket_collection.rb +0 -5
- data/lib/fake_aws/s3/object_collection.rb +0 -2
- data/lib/fake_aws/s3/s3_object.rb +9 -0
- data/lib/fake_aws/version.rb +1 -1
- data/spec/fake-aws/s3/bucket_collection_spec.rb +0 -4
- data/spec/fake-aws/s3/bucket_spec.rb +25 -0
- data/spec/fake-aws/s3/s3_object_spec.rb +33 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDcyZGRiZjUxNDQxYThiOGE2NDQyNGYzZDRiNTI4YmM5ZGM0MDkyZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzVmMGVjMTk5ODM2MjE5ODcxNmQ4OWZlMzY3MTMyNTA3MDA0ODRkZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjEwYjVkZGZjMjlhOTk2MWE3MWM5MGY0NjYxYzIzM2FlZGNmMWQ2NDc2ODlk
|
10
|
+
Mjg3ZTkxZGJiMjRkZmYxMTg0YjA5ZWVlODdjNTZkMjQyNzQ5NjU0YmM0OTAw
|
11
|
+
NjViMGI3NzdhMjRiODE4ZmUwMGNjZTcwYmFlNDkyNTY1NjVkNDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTdmODFkNmUyOTE4NzRkOTM4ZmFiMGQ2Zjc2ZDY1ZjIyNjZmODIyMWIwYjEx
|
14
|
+
OWIyNzZjYzNmYWNiZWI5MjY3M2UzZjRmYmY5NzU5OWZkNTc2ZTM3OTE5ZmE4
|
15
|
+
Yzc3Zjk4N2JiNTgwNDMwYjY1NDIxY2FlYWZmYmEyZjdiNTRjYTM=
|
data/lib/fake_aws/s3/bucket.rb
CHANGED
@@ -7,7 +7,7 @@ module FakeAWS
|
|
7
7
|
|
8
8
|
def initialize(name)
|
9
9
|
@name = name
|
10
|
-
|
10
|
+
clear!
|
11
11
|
end
|
12
12
|
|
13
13
|
attr_reader :name
|
@@ -17,6 +17,14 @@ module FakeAWS
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
|
20
|
+
def empty?
|
21
|
+
objects.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear!
|
25
|
+
@objects = ObjectCollection.new
|
26
|
+
end
|
27
|
+
|
20
28
|
end
|
21
29
|
|
22
30
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "fake_aws/s3/bucket"
|
2
|
-
require "forwardable"
|
3
2
|
|
4
3
|
module FakeAWS
|
5
4
|
class S3
|
@@ -17,10 +16,6 @@ module FakeAWS
|
|
17
16
|
@buckets[name]
|
18
17
|
end
|
19
18
|
|
20
|
-
extend Forwardable
|
21
|
-
|
22
|
-
def_delegators :@buckets, :empty?
|
23
|
-
|
24
19
|
include Enumerable
|
25
20
|
|
26
21
|
def each(&block)
|
@@ -16,6 +16,11 @@ module FakeAWS
|
|
16
16
|
|
17
17
|
def read
|
18
18
|
must_exist!
|
19
|
+
if block_given?
|
20
|
+
@data.each_line do |line|
|
21
|
+
yield line
|
22
|
+
end
|
23
|
+
end
|
19
24
|
@data
|
20
25
|
end
|
21
26
|
|
@@ -28,6 +33,10 @@ module FakeAWS
|
|
28
33
|
!!@data
|
29
34
|
end
|
30
35
|
|
36
|
+
def delete
|
37
|
+
@data = nil
|
38
|
+
end
|
39
|
+
|
31
40
|
private
|
32
41
|
|
33
42
|
def must_exist!
|
data/lib/fake_aws/version.rb
CHANGED
@@ -12,6 +12,10 @@ describe FakeAWS::S3::Bucket do
|
|
12
12
|
bucket.should exist
|
13
13
|
end
|
14
14
|
|
15
|
+
it "starts empty" do
|
16
|
+
bucket.should be_empty
|
17
|
+
end
|
18
|
+
|
15
19
|
describe "#objects" do
|
16
20
|
|
17
21
|
it "returns an ObjectCollection" do
|
@@ -20,4 +24,25 @@ describe FakeAWS::S3::Bucket do
|
|
20
24
|
|
21
25
|
end
|
22
26
|
|
27
|
+
context "containing objects" do
|
28
|
+
|
29
|
+
before do
|
30
|
+
bucket.objects["foo"].write("FOO")
|
31
|
+
bucket.objects["bar"].write("BAR")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#clear!" do
|
35
|
+
|
36
|
+
before do
|
37
|
+
bucket.clear!
|
38
|
+
end
|
39
|
+
|
40
|
+
it "deletes all the things" do
|
41
|
+
bucket.should be_empty
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
23
48
|
end
|
@@ -51,6 +51,20 @@ describe FakeAWS::S3::S3Object do
|
|
51
51
|
object.read.should eq(data)
|
52
52
|
end
|
53
53
|
|
54
|
+
context "with a block" do
|
55
|
+
|
56
|
+
let(:data) { "foo\nbar\n" }
|
57
|
+
|
58
|
+
it "yields data, line-by-line" do
|
59
|
+
@chunks = []
|
60
|
+
object.read do |chunk|
|
61
|
+
@chunks << chunk
|
62
|
+
end
|
63
|
+
@chunks.should eq(["foo\n", "bar\n"])
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
54
68
|
end
|
55
69
|
|
56
70
|
describe "#content_length" do
|
@@ -63,6 +77,25 @@ describe FakeAWS::S3::S3Object do
|
|
63
77
|
|
64
78
|
end
|
65
79
|
|
80
|
+
context "after being deleted" do
|
81
|
+
|
82
|
+
before do
|
83
|
+
object.write("whatever")
|
84
|
+
object.delete
|
85
|
+
end
|
86
|
+
|
87
|
+
it { should_not exist }
|
88
|
+
|
89
|
+
describe "#read" do
|
90
|
+
|
91
|
+
it "raises a KeyError" do
|
92
|
+
lambda { object.read }.should raise_error(KeyError)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
66
99
|
describe "#write" do
|
67
100
|
|
68
101
|
context "with an IO object" do
|