typhoeus_spec_cache 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/typhoeus/spec_cache.rb +5 -2
- data/lib/typhoeus/spec_cache_macros.rb +13 -7
- data/spec/typhoeus/spec_cache_macros_spec.rb +5 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/typhoeus/spec_cache.rb
CHANGED
@@ -55,8 +55,11 @@ module Typhoeus
|
|
55
55
|
# Dumps out any cached items to disk.
|
56
56
|
def dump_cache_fixtures!
|
57
57
|
responses.each do |cache_key, response|
|
58
|
-
|
59
|
-
|
58
|
+
path = filepath_for(cache_key)
|
59
|
+
unless File.exist?(path)
|
60
|
+
File.open(path, "wb") do |fp|
|
61
|
+
fp.write(Marshal.dump(response))
|
62
|
+
end
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
@@ -9,15 +9,21 @@ module Typhoeus
|
|
9
9
|
|
10
10
|
module ClassMethods
|
11
11
|
def typhoeus_spec_cache(cache_path, &block)
|
12
|
-
|
13
|
-
|
12
|
+
describe "HTTP cache suite for #{cache_path}" do
|
13
|
+
hydra = Typhoeus::Hydra.new
|
14
|
+
cache = SpecCache.new(hydra, cache_path)
|
14
15
|
|
15
|
-
|
16
|
+
before(:each) do
|
17
|
+
stub_hydra(hydra)
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
yield hydra
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
cache.remove_unnecessary_cache_files!
|
24
|
+
cache.dump_cache_fixtures!
|
25
|
+
cache.clear_hydra_callbacks!
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -12,9 +12,14 @@ describe Typhoeus::SpecCacheMacros do
|
|
12
12
|
@cache.should_receive(:dump_cache_fixtures!).ordered
|
13
13
|
@cache.should_receive(:clear_hydra_callbacks!)
|
14
14
|
|
15
|
+
self.should_receive(:before).with(:each).
|
16
|
+
and_yield
|
17
|
+
self.should_receive(:stub_hydra).
|
18
|
+
with(an_instance_of(Typhoeus::Hydra))
|
15
19
|
self.should_receive(:after).
|
16
20
|
with(:all).
|
17
21
|
and_yield
|
22
|
+
self.should_receive(:describe).and_yield
|
18
23
|
|
19
24
|
@value_to_modify = nil
|
20
25
|
block_to_run = lambda { |hydra|
|