defog 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f78e9196fe479090f8c5a32df1c2bc936d45c48
4
- data.tar.gz: 28c49ba6db95862f3b245e5aab5d703d4b5afa21
3
+ metadata.gz: 2a60db0801e91688744ef767c60e5f2c63bc4459
4
+ data.tar.gz: e889069aa987fec086b1f1fe355bc5807c7fe7ec
5
5
  SHA512:
6
- metadata.gz: 1fedff27855d7b2adb3685bdadd3be1c937a9f9dae9c66240524e28773f08b593fa9f673f92d091f9fdb1ba7848e2cff871dd419acfb5ff8751aed82a5af0949
7
- data.tar.gz: deedf9a852806d1d41d74267586c7cabe5e50a92e358f00f073f24d06bc8d603b86ca9306a2fee213de8e58cae539bcc7b8ead5875d6b4255d2e47e12558e31b
6
+ metadata.gz: 98059d13cc752f0552a2afa0699808efbc25715c66fcb1e3bc35760fc47bcc88ed8e729e54fb2a8be305e42eca48ae8191b2e2a19588e844d837811ee6697008
7
+ data.tar.gz: 6ad35f25424c6bd77b59d419bf1efc9e9cab2ac85477452ad44419177b3f877dc9d9ce90ef29877a01859043171f5962c9d65e90b98924c4d3f88037a98cc490
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  rvm:
2
3
  - 1.9.3
3
4
  - 2.1.3
data/README.md CHANGED
@@ -253,6 +253,7 @@ plus appropriate rspec examples.)
253
253
  ## History
254
254
 
255
255
  Release Notes:
256
+ * 0.9.4 - Bug fix: don't fail when checking atime if file gets deleted by another process (more robust)
256
257
  * 0.9.3 - Bug fix: don't fail when measuring cache if file gets deleted by another process (more robust)
257
258
  * 0.9.2 - Bug fix: don't fail when measuring cache if file gets deleted by another process (more robust)
258
259
  * 0.9.1 - Bug fix: don't fail when measuring cache if file gets deleted by another process
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'rdoc'
24
- gem.add_development_dependency 'rspec', "<2.99"
24
+ gem.add_development_dependency 'rspec', "~> 3.0"
25
25
  gem.add_development_dependency 'simplecov'
26
- gem.add_development_dependency 'simplecov-gem-adapter'
26
+ gem.add_development_dependency 'simplecov-gem-profile'
27
27
  end
@@ -237,7 +237,10 @@ module Defog
237
237
  begin
238
238
  path.send method
239
239
  rescue Errno::ENOENT
240
- 0
240
+ case method
241
+ when :atime then Time.new(0)
242
+ else 0
243
+ end
241
244
  end
242
245
  end
243
246
 
@@ -1,3 +1,3 @@
1
1
  module Defog
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -6,7 +6,7 @@ shared_examples "get proxy" do
6
6
  create_remote("hello")
7
7
  should_log /Download/
8
8
  file = @proxy.file(key, @mode)
9
- File.exist?(file.path).should be_true
9
+ expect(File.exist?(file.path)).to be_truthy
10
10
  file.close
11
11
  end
12
12
 
@@ -17,24 +17,24 @@ shared_examples "get proxy" do
17
17
  it "should overwrite existing proxy if it's not valid " do
18
18
  create_remote("hello")
19
19
  create_proxy("goodbye")
20
- proxy_path.read.should == "goodbye"
20
+ expect(proxy_path.read).to eq("goodbye")
21
21
  should_log /Download/
22
22
  @proxy.file(key, @mode)
23
- proxy_path.read.should == "hello"
23
+ expect(proxy_path.read).to eq("hello")
24
24
  end
25
25
 
26
26
  it "should use existing proxy if it's valid" do
27
27
  create_remote("hello")
28
28
  create_proxy("hello")
29
29
  handle = @proxy.file(key)
30
- handle.proxy_path.should_not_receive(:open).with(/^w/)
30
+ expect(handle.proxy_path).not_to receive(:open).with(/^w/)
31
31
  should_not_log /Download/
32
32
  handle.open(@mode)
33
33
  end
34
34
 
35
35
  it "should include key info in exception messages" do
36
36
  create_remote("error me")
37
- File.any_instance.should_receive(:write) { raise Encoding::UndefinedConversionError, "dummy" }
37
+ expect_any_instance_of(File).to receive(:write) { raise Encoding::UndefinedConversionError, "dummy" }
38
38
  expect {
39
39
  @proxy.file(key, "r")
40
40
  }.to raise_error Encoding::UndefinedConversionError, /#{key}/
@@ -46,22 +46,22 @@ shared_examples "read" do
46
46
  create_remote("read me")
47
47
  @proxy.file(key, @mode) do |file|
48
48
  file.rewind
49
- file.read.should == "read me"
49
+ expect(file.read).to eq("read me")
50
50
  end
51
51
  end
52
52
 
53
53
  it "should pass 'b' mode through" do
54
54
  create_remote("binary me")
55
55
  @proxy.file(key, "#{@mode}b") do |file|
56
- file.external_encoding.name.should == "ASCII-8BIT"
56
+ expect(file.external_encoding.name).to eq("ASCII-8BIT")
57
57
  end
58
58
  end
59
59
 
60
60
  it "should pass encodings through" do
61
61
  create_remote("encode me")
62
62
  @proxy.file(key, "#{@mode}:EUC-JP:UTF-8") do |file|
63
- file.external_encoding.name.should == "EUC-JP"
64
- file.internal_encoding.name.should == "UTF-8"
63
+ expect(file.external_encoding.name).to eq("EUC-JP")
64
+ expect(file.internal_encoding.name).to eq("UTF-8")
65
65
  end
66
66
  end
67
67
 
@@ -72,7 +72,7 @@ shared_examples "read after write" do
72
72
  @proxy.file(key, @mode) do |file|
73
73
  file.write "read me"
74
74
  file.rewind
75
- file.read.should == "read me"
75
+ expect(file.read).to eq("read me")
76
76
  end
77
77
  end
78
78
  end
@@ -83,7 +83,7 @@ shared_examples "write" do
83
83
  @proxy.file(key, @mode, :persist => true) do |file|
84
84
  file.write "write me"
85
85
  end
86
- proxy_path.read.should =~ /write me$/
86
+ expect(proxy_path.read).to match(/write me$/)
87
87
  end
88
88
  end
89
89
 
@@ -94,7 +94,7 @@ shared_examples "append" do
94
94
  file.write "goodbye"
95
95
  should_log /Upload/
96
96
  end
97
- proxy_path.read.should == "hellogoodbye"
97
+ expect(proxy_path.read).to eq("hellogoodbye")
98
98
  end
99
99
  end
100
100
 
@@ -105,7 +105,7 @@ shared_examples "create" do
105
105
  file = @proxy.file(key, @mode)
106
106
  create_proxy("upload me")
107
107
  file.close
108
- remote_body.should == "upload me"
108
+ expect(remote_body).to eq("upload me")
109
109
  end
110
110
 
111
111
  it "should not create remote if proxy is deleted" do
@@ -114,7 +114,7 @@ shared_examples "create" do
114
114
  file.write("ignore me")
115
115
  proxy_path.unlink
116
116
  end
117
- expect {remote_body}.to raise_error
117
+ expect(remote_body).to be_nil
118
118
  end
119
119
 
120
120
  it "should not create remote if :synchronize => false" do
@@ -122,19 +122,19 @@ shared_examples "create" do
122
122
  file = @proxy.file(key, @mode)
123
123
  create_proxy("ignore me")
124
124
  file.close(:synchronize => false)
125
- expect {remote_body}.to raise_error
125
+ expect(remote_body).to be_nil
126
126
  end
127
127
 
128
128
  it "should create remote asynchronously if :synchronize => async" do
129
129
  should_log /Upload/
130
130
  file = @proxy.file(key, @mode)
131
131
  create_proxy("upload me in thread")
132
- Thread.should_receive(:new) { |&block|
133
- expect {remote_body}.to raise_error
132
+ expect(Thread).to receive(:new) { |&block|
133
+ expect(remote_body).to be_nil
134
134
  block.call
135
135
  }
136
136
  file.close(:synchronize => :async)
137
- remote_body.should == "upload me in thread"
137
+ expect(remote_body).to eq("upload me in thread")
138
138
  end
139
139
 
140
140
  end
@@ -143,25 +143,25 @@ shared_examples "update" do
143
143
 
144
144
  it "should overwrite remote" do
145
145
  create_remote("overwrite me")
146
- remote_body.should == "overwrite me"
146
+ expect(remote_body).to eq("overwrite me")
147
147
  file = @proxy.file(key, @mode)
148
148
  create_proxy("upload me")
149
149
  should_log /Upload/
150
150
  file.close
151
- remote_body.should == "upload me"
151
+ expect(remote_body).to eq("upload me")
152
152
  end
153
153
 
154
154
  it "should overwrite remote asynchronously if :synchronize => :async" do
155
155
  create_remote("overwrite me")
156
156
  file = @proxy.file(key, @mode)
157
157
  create_proxy("upload me")
158
- Thread.should_receive(:new) { |&block|
159
- remote_body.should == "overwrite me"
158
+ expect(Thread).to receive(:new) { |&block|
159
+ expect(remote_body).to eq("overwrite me")
160
160
  block.call
161
161
  }
162
162
  should_log /Upload/
163
163
  file.close(:synchronize => :async)
164
- remote_body.should == "upload me"
164
+ expect(remote_body).to eq("upload me")
165
165
  end
166
166
 
167
167
  it "should not overwrite remote if proxy is deleted" do
@@ -171,7 +171,7 @@ shared_examples "update" do
171
171
  file.write("ignore me")
172
172
  proxy_path.unlink
173
173
  end
174
- remote_body.should == "keep me"
174
+ expect(remote_body).to eq("keep me")
175
175
  end
176
176
 
177
177
  it "should not overwrite remote if :synchronize => false" do
@@ -180,7 +180,7 @@ shared_examples "update" do
180
180
  file = @proxy.file(key, @mode)
181
181
  create_proxy("ignore me")
182
182
  file.close(:synchronize => false)
183
- remote_body.should == "keep me"
183
+ expect(remote_body).to eq("keep me")
184
184
  end
185
185
 
186
186
  end
@@ -189,41 +189,41 @@ shared_examples "persistence" do
189
189
  it "should delete proxy on close" do
190
190
  create_remote("whatever")
191
191
  file = @proxy.file(key, @mode)
192
- proxy_path.should be_exist
192
+ expect(proxy_path).to be_exist
193
193
  file.close
194
- proxy_path.should_not be_exist
194
+ expect(proxy_path).not_to be_exist
195
195
  end
196
196
 
197
197
  it "should delete proxy on close (block form)" do
198
198
  create_remote("whatever")
199
199
  @proxy.file(key, @mode) do |file|
200
- proxy_path.should be_exist
200
+ expect(proxy_path).to be_exist
201
201
  end
202
- proxy_path.should_not be_exist
202
+ expect(proxy_path).not_to be_exist
203
203
  end
204
204
 
205
205
  it "should not delete proxy if persisting" do
206
206
  create_remote("whatever")
207
207
  @proxy.file(key, @mode, :persist => true) do |file|
208
- proxy_path.should be_exist
208
+ expect(proxy_path).to be_exist
209
209
  end
210
- proxy_path.should be_exist
210
+ expect(proxy_path).to be_exist
211
211
  end
212
212
 
213
213
  it "close should override persist true" do
214
214
  create_remote("whatever")
215
215
  file = @proxy.file(key, @mode)
216
- proxy_path.should be_exist
216
+ expect(proxy_path).to be_exist
217
217
  file.close(:persist => true)
218
- proxy_path.should be_exist
218
+ expect(proxy_path).to be_exist
219
219
  end
220
220
 
221
221
  it "close should override persist false" do
222
222
  create_remote("whatever")
223
223
  file = @proxy.file(key, @mode, :persist => true)
224
- proxy_path.should be_exist
224
+ expect(proxy_path).to be_exist
225
225
  file.close(:persist => false)
226
- proxy_path.should_not be_exist
226
+ expect(proxy_path).not_to be_exist
227
227
  end
228
228
 
229
229
  end
@@ -263,7 +263,7 @@ shared_examples "a proxy file" do |proxyargs|
263
263
 
264
264
  it "should have a nice to_s" do
265
265
  @proxy.file(key, "w") {|f|
266
- f.to_s.should include f.path
266
+ expect(f.to_s).to include f.path
267
267
  }
268
268
  end
269
269
 
@@ -11,21 +11,21 @@ shared_examples "a handle" do |proxyargs|
11
11
  end
12
12
 
13
13
  it "should have a nice to_s" do
14
- @handle.to_s.should include key
14
+ expect(@handle.to_s).to include key
15
15
  end
16
16
 
17
17
  context "proxy path" do
18
18
  it "should start with proxy root" do
19
- @handle.proxy_path.to_s.should start_with(@proxy.proxy_root.to_s)
19
+ expect(@handle.proxy_path.to_s).to start_with(@proxy.proxy_root.to_s)
20
20
  end
21
21
 
22
22
  it "should end with key" do
23
- @handle.proxy_path.to_s.should end_with(key)
23
+ expect(@handle.proxy_path.to_s).to end_with(key)
24
24
  end
25
25
 
26
26
  it "should include prefix" do
27
27
  prefix = "IAmAPrefix"
28
- Defog::Proxy.new(proxyargs.merge(:prefix => prefix)).file(key).proxy_path.to_s.should include(prefix.to_s)
28
+ expect(Defog::Proxy.new(proxyargs.merge(:prefix => prefix)).file(key).proxy_path.to_s).to include(prefix.to_s)
29
29
  end
30
30
  end
31
31
 
@@ -36,21 +36,21 @@ shared_examples "a handle" do |proxyargs|
36
36
  end
37
37
 
38
38
  it "should report exist? true" do
39
- @handle.should be_exist
39
+ expect(@handle).to be_exist
40
40
  end
41
41
 
42
42
  it "should return md5 hash" do
43
- @handle.md5_hash.should == Digest::MD5.hexdigest("i exist")
43
+ expect(@handle.md5_hash).to eq(Digest::MD5.hexdigest("i exist"))
44
44
  end
45
45
  end
46
46
 
47
47
  context "if remote cloud file does not exist" do
48
48
  it "should report exist? false" do
49
- @handle.should_not be_exist
49
+ expect(@handle).not_to be_exist
50
50
  end
51
51
 
52
52
  it "should return nil md5 hash" do
53
- @handle.md5_hash.should be_nil
53
+ expect(@handle.md5_hash).to be_nil
54
54
  end
55
55
  end
56
56
 
@@ -60,45 +60,45 @@ shared_examples "a handle" do |proxyargs|
60
60
 
61
61
  it "should delegate #{method.inspect} to the fog model #{fog_method.inspect} if the remote file exists" do
62
62
  create_remote("delegate me")
63
- @handle.fog_model.class.any_instance.should_receive(fog_method).and_return { "dummy" }
64
- @handle.send(method).should == "dummy"
63
+ expect_any_instance_of(@handle.fog_model.class).to receive(fog_method) { "dummy" }
64
+ expect(@handle.send(method)).to eq("dummy")
65
65
  end
66
66
 
67
67
  it "should return nil from #{method} if the remote file does not exist" do
68
- @handle.send(method).should be_nil
68
+ expect(@handle.send(method)).to be_nil
69
69
  end
70
70
 
71
71
  end
72
72
 
73
73
  it "should delete a remote cloud file" do
74
74
  create_remote("delete me")
75
- remote_exist?.should be_true
75
+ expect(remote_exist?).to be_truthy
76
76
  @handle.delete
77
- remote_exist?.should be_false
77
+ expect(remote_exist?).to be_falsey
78
78
  end
79
79
 
80
80
  it "should return a URL to a file" do
81
81
  create_remote("reach out to me")
82
- @handle.url.should be_a String
82
+ expect(@handle.url).to be_a String
83
83
  end
84
84
 
85
85
  it "should open a file" do
86
- Defog::File.should_receive(:open).with(hash_including(:handle => @handle, :mode => "w"))
86
+ expect(Defog::File).to receive(:open).with(hash_including(:handle => @handle, :mode => "w"))
87
87
  @handle.open("w")
88
88
  end
89
89
 
90
90
  it "should return a Fog model" do
91
91
  create_remote("foggy")
92
- @handle.fog_model.body.should == "foggy"
92
+ expect(@handle.fog_model.body).to eq("foggy")
93
93
  end
94
94
 
95
95
  it "should update when file changes" do
96
96
  create_remote("abc")
97
- @proxy.file(key).size.should == 3
97
+ expect(@proxy.file(key).size).to eq(3)
98
98
  @proxy.file(key).open("w") do |f|
99
99
  f.write("defghij")
100
100
  end
101
- @proxy.file(key).size.should == 7
101
+ expect(@proxy.file(key).size).to eq(7)
102
102
  end
103
103
 
104
104
 
@@ -117,7 +117,7 @@ describe Defog::Handle do
117
117
 
118
118
  it "should return a file:// URL" do
119
119
  @proxy = Defog::Proxy.new(args)
120
- @proxy.file(key).url.should == "file://" + (LOCAL_CLOUD_PATH + key).to_s
120
+ expect(@proxy.file(key).url).to eq("file://" + (LOCAL_CLOUD_PATH + key).to_s)
121
121
  end
122
122
 
123
123
  context "with a rails app" do
@@ -125,14 +125,14 @@ describe Defog::Handle do
125
125
  it "should return a path relative to public if in public" do
126
126
  with_rails_defined do
127
127
  @proxy = Defog::Proxy.new(:provider => :local, :local_root => Rails.root + "public/defog")
128
- @proxy.file(key).url.should == "/defog/#{key}"
128
+ expect(@proxy.file(key).url).to eq("/defog/#{key}")
129
129
  end
130
130
  end
131
131
 
132
132
  it "should return a file:// path if not in public" do
133
133
  with_rails_defined do
134
134
  @proxy = Defog::Proxy.new(args)
135
- @proxy.file(key).url.should == "file://" + (LOCAL_CLOUD_PATH + key).to_s
135
+ expect(@proxy.file(key).url).to eq("file://" + (LOCAL_CLOUD_PATH + key).to_s)
136
136
  end
137
137
  end
138
138
  end
@@ -154,7 +154,7 @@ describe Defog::Handle do
154
154
  t = Time.now + 10*60
155
155
  #Fog::Storage::AWS::File.any_instance.should_receive(:url).with(t, "response-content-disposition" => "attachment")
156
156
  url = @proxy.file(key).url(:expiry => t, :query => {"response-content-disposition" => "attachment"})
157
- url.should include "response-content-disposition=attachment"
157
+ expect(url).to include "response-content-disposition=attachment"
158
158
  end
159
159
 
160
160
 
@@ -8,51 +8,51 @@ shared_examples "a proxy" do |args|
8
8
  end
9
9
 
10
10
  it "should have a nice to_s" do
11
- @proxy.to_s.should include @proxy.provider.to_s
12
- @proxy.to_s.should include @proxy.location
11
+ expect(@proxy.to_s).to include @proxy.provider.to_s
12
+ expect(@proxy.to_s).to include @proxy.location
13
13
  end
14
14
 
15
15
  it "file should return a handle" do
16
16
  handle = @proxy.file(key)
17
- handle.proxy.should == @proxy
18
- handle.key.should == key
17
+ expect(handle.proxy).to eq(@proxy)
18
+ expect(handle.key).to eq(key)
19
19
  end
20
20
 
21
21
  it "file should yield a handle" do
22
22
  ret = @proxy.file(key) do |handle|
23
- handle.proxy.should == @proxy
24
- handle.key.should == key
23
+ expect(handle.proxy).to eq(@proxy)
24
+ expect(handle.key).to eq(key)
25
25
  123
26
26
  end
27
- ret.should == 123
27
+ expect(ret).to eq(123)
28
28
  end
29
29
 
30
30
  it "should forward file open to handle" do
31
- Defog::Handle.should_receive(:new).with(@proxy, key).and_return { mock('Handle').tap { |handle|
32
- handle.should_receive(:open).with("r+", :persist => true)
31
+ expect(Defog::Handle).to receive(:new).with(@proxy, key) { double('Handle').tap { |handle|
32
+ expect(handle).to receive(:open).with("r+", :persist => true)
33
33
  } }
34
34
  @proxy.file(key, "r+", :persist => true)
35
35
  end
36
36
 
37
37
  it "should return fog storage" do
38
- @proxy.fog_connection.should == @proxy.fog_directory.service
38
+ expect(@proxy.fog_connection).to eq(@proxy.fog_directory.service)
39
39
  end
40
40
 
41
41
  it "should return fog directory" do
42
42
  create_remote("hello")
43
- @proxy.fog_directory.files.get(key).body.should == "hello"
43
+ expect(@proxy.fog_directory.files.get(key).body).to eq("hello")
44
44
  end
45
45
  end
46
46
 
47
47
  context "settings" do
48
48
  it "should set default for :persist => true" do
49
49
  @proxy = Defog::Proxy.new(args.merge(:persist => true))
50
- Defog::File.should_receive(:open).with(hash_including :persist => true)
50
+ expect(Defog::File).to receive(:open).with(hash_including :persist => true)
51
51
  @proxy.file(key, "w") do end
52
52
  end
53
53
  it "should set default for :synchronize => :async" do
54
54
  @proxy = Defog::Proxy.new(args.merge(:synchronize => :async))
55
- Defog::File.should_receive(:open).with(hash_including :synchronize => :async)
55
+ expect(Defog::File).to receive(:open).with(hash_including :synchronize => :async)
56
56
  @proxy.file(key, "w") do end
57
57
  end
58
58
  end
@@ -73,11 +73,11 @@ shared_examples "a proxy" do |args|
73
73
  @proxy.each do |handle|
74
74
  seen << handle.key
75
75
  end
76
- seen.should =~ [other_key("i0"), other_key("i1"), other_key("i2")]
76
+ expect(seen).to match_array([other_key("i0"), other_key("i1"), other_key("i2")])
77
77
  end
78
78
 
79
79
  it "should return an enumerator" do
80
- @proxy.each.map(&:key).should =~ [other_key("i0"), other_key("i1"), other_key("i2")]
80
+ expect(@proxy.each.map(&:key)).to match_array([other_key("i0"), other_key("i1"), other_key("i2")])
81
81
  end
82
82
 
83
83
  end
@@ -86,14 +86,14 @@ shared_examples "a proxy" do |args|
86
86
  it "should return its prefix" do
87
87
  prefix = "me-first"
88
88
  @proxy = Defog::Proxy.new(args.merge(:prefix => prefix))
89
- @proxy.prefix.should == prefix
89
+ expect(@proxy.prefix).to eq(prefix)
90
90
  end
91
91
 
92
92
  it "should use a prefix" do
93
93
  prefix = "me-first"
94
94
  @proxy = Defog::Proxy.new(args.merge(:prefix => prefix))
95
95
  @proxy.file(key, "w") { |f| f.puts "hello" }
96
- @proxy.file(key).fog_model.key.should == prefix + key
96
+ expect(@proxy.file(key).fog_model.key).to eq(prefix + key)
97
97
  end
98
98
 
99
99
  it "should iterate only matches to prefix" do
@@ -105,7 +105,7 @@ shared_examples "a proxy" do |args|
105
105
  create_other_remote("yes-y1")
106
106
  create_other_remote("yes-y2")
107
107
  create_other_remote("yes-y3")
108
- @proxy.each.map(&:key).should =~[other_key("y1"), other_key("y2"), other_key("y3")]
108
+ expect(@proxy.each.map(&:key)).to match_array([other_key("y1"), other_key("y2"), other_key("y3")])
109
109
  end
110
110
 
111
111
  end
@@ -113,20 +113,20 @@ shared_examples "a proxy" do |args|
113
113
  context "proxy root location" do
114
114
  it "should default proxy root to tmpdir/defog" do
115
115
  proxy = Defog::Proxy.new(args)
116
- proxy.proxy_root.should == Pathname.new(Dir.tmpdir) + "defog" + "#{proxy.provider.to_s}-#{proxy.location}"
116
+ expect(proxy.proxy_root).to eq(Pathname.new(Dir.tmpdir) + "defog" + "#{proxy.provider.to_s}-#{proxy.location}")
117
117
  end
118
118
 
119
119
  it "should default proxy root to Rails.root" do
120
120
  with_rails_defined do
121
121
  proxy = Defog::Proxy.new(args)
122
- proxy.proxy_root.should == Rails.root + "tmp/defog" + "#{proxy.provider.to_s}-#{proxy.location}"
122
+ expect(proxy.proxy_root).to eq(Rails.root + "tmp/defog" + "#{proxy.provider.to_s}-#{proxy.location}")
123
123
  end
124
124
  end
125
125
 
126
126
  it "should accept proxy root parameter" do
127
127
  path = Pathname.new("/a/random/path")
128
128
  proxy = Defog::Proxy.new(args.merge(:proxy_root => path))
129
- proxy.proxy_root.should == path
129
+ expect(proxy.proxy_root).to eq(path)
130
130
  end
131
131
  end
132
132
 
@@ -144,15 +144,15 @@ shared_examples "a proxy" do |args|
144
144
  it "should raise an error trying to proxy a file larger than the cache" do
145
145
  create_remote("x" * 101)
146
146
  expect { @proxy.file(key, "r") }.to raise_error(Defog::Error::CacheFull)
147
- proxy_path.should_not be_exist
147
+ expect(proxy_path).not_to be_exist
148
148
  end
149
149
 
150
150
  it "should not count existing proxy in total" do
151
151
  create_proxy("y" * 70)
152
152
  create_remote("x" * 70)
153
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Defog::Error::CacheFull)
154
- proxy_path.should be_exist
155
- proxy_path.read.should == remote_body
153
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
154
+ expect(proxy_path).to be_exist
155
+ expect(proxy_path.read).to eq(remote_body)
156
156
  end
157
157
 
158
158
  it "should delete proxies to make room" do
@@ -160,11 +160,11 @@ shared_examples "a proxy" do |args|
160
160
  create_other_proxy("b", 30)
161
161
  create_other_proxy("c", 40)
162
162
  create_remote("x" * 80)
163
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Defog::Error::CacheFull)
164
- proxy_path.should be_exist
165
- other_proxy_path("a").should be_exist
166
- other_proxy_path("b").should_not be_exist
167
- other_proxy_path("c").should_not be_exist
163
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
164
+ expect(proxy_path).to be_exist
165
+ expect(other_proxy_path("a")).to be_exist
166
+ expect(other_proxy_path("b")).not_to be_exist
167
+ expect(other_proxy_path("c")).not_to be_exist
168
168
  end
169
169
 
170
170
  [0, 3, 6].each do |sizect|
@@ -172,14 +172,14 @@ shared_examples "a proxy" do |args|
172
172
  create_other_proxy("a", 30)
173
173
  create_other_proxy("b", 30)
174
174
  create_other_proxy("c", 30)
175
- create_remote("x" * 80)
175
+ create_remote("x" * 9)
176
176
  z = 0
177
- Pathname.any_instance.stub(:size) { |path|
177
+ allow_any_instance_of(Pathname).to receive(:size) { |path|
178
178
  raise Errno::ENOENT if z == sizect
179
179
  z += 1
180
180
  30
181
181
  }
182
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Errno::ENOENT)
182
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
183
183
  end
184
184
  end
185
185
 
@@ -188,28 +188,31 @@ shared_examples "a proxy" do |args|
188
188
  create_other_proxy("b", 30)
189
189
  create_other_proxy("c", 40)
190
190
  create_remote("x" * 80)
191
- Pathname.any_instance.should_receive(:unlink).and_raise Errno::ENOENT
192
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Errno::ENOENT)
191
+ allow_any_instance_of(Pathname).to receive(:unlink) { raise Errno::ENOENT }
192
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
193
193
  end
194
194
 
195
- it "should not fail atime when proxies get deleted by another process" do
195
+ it "should not fail atime when a proxy gets deleted by another process" do
196
196
  create_other_proxy("a", 10)
197
197
  create_other_proxy("b", 30)
198
198
  create_other_proxy("c", 40)
199
199
  create_remote("x" * 80)
200
- Pathname.any_instance.should_receive(:atime).and_raise Errno::ENOENT
201
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Errno::ENOENT)
200
+ allow_any_instance_of(Pathname).to receive(:atime) {
201
+ @raised = true and raise Errno::ENOENT unless @raised
202
+ Time.now
203
+ }
204
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
202
205
  end
203
206
 
204
207
  it "should delete proxies to make room for hinted size" do
205
208
  create_other_proxy("a", 10)
206
209
  create_other_proxy("b", 30)
207
210
  create_other_proxy("c", 40)
208
- expect { @proxy.file(key, "w", :size_hint => 80) do end }.to_not raise_error(Defog::Error::CacheFull)
209
- proxy_path.should be_exist
210
- other_proxy_path("a").should be_exist
211
- other_proxy_path("b").should_not be_exist
212
- other_proxy_path("c").should_not be_exist
211
+ expect { @proxy.file(key, "w", :size_hint => 80) do end }.not_to raise_error
212
+ expect(proxy_path).to be_exist
213
+ expect(other_proxy_path("a")).to be_exist
214
+ expect(other_proxy_path("b")).not_to be_exist
215
+ expect(other_proxy_path("c")).not_to be_exist
213
216
  end
214
217
 
215
218
  it "should not delete proxies that are open" do
@@ -220,12 +223,12 @@ shared_examples "a proxy" do |args|
220
223
  @proxy.file(other_key("R"), "r") do
221
224
  @proxy.file(other_key("S"), "w") do
222
225
  create_other_proxy("S", 30)
223
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Defog::Error::CacheFull)
224
- proxy_path.should be_exist
225
- other_proxy_path("R").should be_exist
226
- other_proxy_path("S").should be_exist
227
- other_proxy_path("a").should_not be_exist
228
- other_proxy_path("b").should_not be_exist
226
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
227
+ expect(proxy_path).to be_exist
228
+ expect(other_proxy_path("R")).to be_exist
229
+ expect(other_proxy_path("S")).to be_exist
230
+ expect(other_proxy_path("a")).not_to be_exist
231
+ expect(other_proxy_path("b")).not_to be_exist
229
232
  end
230
233
  end
231
234
  end
@@ -234,10 +237,10 @@ shared_examples "a proxy" do |args|
234
237
  create_other_remote("R", 60)
235
238
  create_remote("z" * 60)
236
239
  @proxy.file(other_key("R"), "r") do end
237
- other_proxy_path("R").should be_exist
238
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Defog::Error::CacheFull)
239
- proxy_path.should be_exist
240
- other_proxy_path("R").should_not be_exist
240
+ expect(other_proxy_path("R")).to be_exist
241
+ expect { @proxy.file(key, "r") do end }.not_to raise_error
242
+ expect(proxy_path).to be_exist
243
+ expect(other_proxy_path("R")).not_to be_exist
241
244
  end
242
245
 
243
246
  it "should not delete proxies if there wouldn't be enough space" do
@@ -249,11 +252,11 @@ shared_examples "a proxy" do |args|
249
252
  @proxy.file(other_key("R"), "r") do
250
253
  @proxy.file(other_key("S"), "r") do
251
254
  expect { @proxy.file(key, "r") do end }.to raise_error(Defog::Error::CacheFull)
252
- proxy_path.should_not be_exist
253
- other_proxy_path("a").should be_exist
254
- other_proxy_path("b").should be_exist
255
- other_proxy_path("R").should be_exist
256
- other_proxy_path("S").should be_exist
255
+ expect(proxy_path).not_to be_exist
256
+ expect(other_proxy_path("a")).to be_exist
257
+ expect(other_proxy_path("b")).to be_exist
258
+ expect(other_proxy_path("R")).to be_exist
259
+ expect(other_proxy_path("S")).to be_exist
257
260
  end
258
261
  end
259
262
  end
@@ -296,7 +299,7 @@ describe Defog::Proxy do
296
299
  it_should_behave_like "a proxy", args
297
300
 
298
301
  it "should use the deslashed local_root as the location" do
299
- Defog::Proxy.new(args).location.should == LOCAL_CLOUD_PATH.to_s.gsub(%r{/},"-")
302
+ expect(Defog::Proxy.new(args).location).to eq(LOCAL_CLOUD_PATH.to_s.gsub(%r{/},"-"))
300
303
  end
301
304
 
302
305
  end
@@ -310,25 +313,25 @@ describe Defog::Proxy do
310
313
  it_should_behave_like "a proxy", args
311
314
 
312
315
  it "should use the bucket name as the location" do
313
- Defog::Proxy.new(args).location.should == args[:bucket]
316
+ expect(Defog::Proxy.new(args).location).to eq(args[:bucket])
314
317
  end
315
318
 
316
319
  it "should share fog connection with same bucket" do
317
320
  proxy1 = Defog::Proxy.new(args)
318
321
  proxy2 = Defog::Proxy.new(args)
319
- proxy1.fog_connection.should be_equal proxy2.fog_connection
322
+ expect(proxy1.fog_connection).to be_equal proxy2.fog_connection
320
323
  end
321
324
 
322
325
  it "should share fog connection with different bucket" do
323
326
  proxy1 = Defog::Proxy.new(args)
324
327
  proxy2 = Defog::Proxy.new(args.merge(:bucket => "other"))
325
- proxy1.fog_connection.should be_equal proxy2.fog_connection
328
+ expect(proxy1.fog_connection).to be_equal proxy2.fog_connection
326
329
  end
327
330
 
328
331
  it "should not share fog connection with different connection args" do
329
332
  proxy1 = Defog::Proxy.new(args)
330
333
  proxy2 = Defog::Proxy.new(args.merge(:aws_access_key_id => "other"))
331
- proxy1.fog_connection.should_not be_equal proxy2.fog_connection
334
+ expect(proxy1.fog_connection).not_to be_equal proxy2.fog_connection
332
335
  end
333
336
 
334
337
  end
@@ -1,6 +1,6 @@
1
1
  if RUBY_VERSION > "1.9"
2
2
  require 'simplecov'
3
- require 'simplecov-gem-adapter'
3
+ require 'simplecov-gem-profile'
4
4
  SimpleCov.start 'gem'
5
5
  end
6
6
 
@@ -3,7 +3,7 @@ module Helpers
3
3
  def key
4
4
  # returns a key that will be different for each example, to avoid any
5
5
  # cross-example interactions
6
- example.metadata[:full_description].gsub(/\+/,'plus').gsub(/\W/,'-') + "/filename"
6
+ RSpec.current_example.metadata[:full_description].gsub(/\+/,'plus').gsub(/\W/,'-') + "/filename"
7
7
  end
8
8
 
9
9
  def create_remote(body)
@@ -23,7 +23,7 @@ module Helpers
23
23
  end
24
24
 
25
25
  def remote_body
26
- @proxy.file(key).fog_model.body
26
+ @proxy.file(key).fog_model.andand.body
27
27
  end
28
28
 
29
29
  def remote_exist?
@@ -40,11 +40,11 @@ module Helpers
40
40
  end
41
41
 
42
42
  def should_log(arg)
43
- @proxy.logger.should_receive(:info).with(arg)
43
+ expect(@proxy.logger).to receive(:info).with(arg)
44
44
  end
45
45
 
46
46
  def should_not_log(arg)
47
- @proxy.logger.should_not_receive(:info).with(arg)
47
+ expect(@proxy.logger).not_to receive(:info).with(arg)
48
48
  end
49
49
 
50
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-30 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "<"
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.99'
89
+ version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "<"
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.99'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: simplecov-gem-adapter
112
+ name: simplecov-gem-profile
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.2.2
171
+ rubygems_version: 2.4.5
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Wrapper to fog gem, proxying access to cloud files as local files. Access