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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjEwYzgyMWM4M2ZkZTI0NDQ2NWUyMDg5Mzg4M2YxNjRiYWY2MjI1NA==
4
+ NDcyZGRiZjUxNDQxYThiOGE2NDQyNGYzZDRiNTI4YmM5ZGM0MDkyZA==
5
5
  data.tar.gz: !binary |-
6
- YzE1ZTEzMTEzOTkwMDNjNzQ5NWRmMWU1MjMwYjA2NjFhOGY4YWViZg==
6
+ YzVmMGVjMTk5ODM2MjE5ODcxNmQ4OWZlMzY3MTMyNTA3MDA0ODRkZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OThmODliYjJlNjQyZTk2MzY4OGM0ZmFiMWEzY2FkNDIyZTgxYzc2MGZmMGY4
10
- MTA1MTNiNGVmMGM0N2Y2MjkwMTAxNzcyZmUxMTUyODY0MDdlYTE3YTk4NzJh
11
- MThmM2NiNTJkNmY3NTY3NTBjOWQ2N2ExYjEzMzFlNjBjNjRjNGM=
9
+ MjEwYjVkZGZjMjlhOTk2MWE3MWM5MGY0NjYxYzIzM2FlZGNmMWQ2NDc2ODlk
10
+ Mjg3ZTkxZGJiMjRkZmYxMTg0YjA5ZWVlODdjNTZkMjQyNzQ5NjU0YmM0OTAw
11
+ NjViMGI3NzdhMjRiODE4ZmUwMGNjZTcwYmFlNDkyNTY1NjVkNDk=
12
12
  data.tar.gz: !binary |-
13
- NDBkMGE4ZGRiZWI0MTZkYjMxNTJiZjc1MjJlYWRlNjdiYWUzYTEzYzVjM2Rl
14
- ZGVlNGI0OGQ3Y2MyOTQ5ZDM2NGJjNmU1Mjc4OWViNDEyZjcwZWU5MmFlNzJm
15
- Yzk5MWI2ZWJiZjdlZTZhM2QxNDE3OWYxYTU1MjExNmZiZDM4M2E=
13
+ YTdmODFkNmUyOTE4NzRkOTM4ZmFiMGQ2Zjc2ZDY1ZjIyNjZmODIyMWIwYjEx
14
+ OWIyNzZjYzNmYWNiZWI5MjY3M2UzZjRmYmY5NzU5OWZkNTc2ZTM3OTE5ZmE4
15
+ Yzc3Zjk4N2JiNTgwNDMwYjY1NDIxY2FlYWZmYmEyZjdiNTRjYTM=
@@ -7,7 +7,7 @@ module FakeAWS
7
7
 
8
8
  def initialize(name)
9
9
  @name = name
10
- @objects = ObjectCollection.new
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)
@@ -17,8 +17,6 @@ module FakeAWS
17
17
  @objects[key]
18
18
  end
19
19
 
20
- extend Forwardable
21
-
22
20
  include Enumerable
23
21
 
24
22
  def each
@@ -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!
@@ -1,3 +1,3 @@
1
1
  module FakeAWS
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -4,10 +4,6 @@ describe FakeAWS::S3::BucketCollection do
4
4
 
5
5
  let(:buckets) { FakeAWS::S3::BucketCollection.new }
6
6
 
7
- it "starts empty" do
8
- buckets.should be_empty
9
- end
10
-
11
7
  describe "#[]" do
12
8
 
13
9
  it "returns a Bucket" do
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake-aws-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams