typhoeus_spec_cache 0.1.0 → 0.1.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -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
- File.open(filepath_for(cache_key), "wb") do |fp|
59
- fp.write(Marshal.dump(response))
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
- hydra = Typhoeus::Hydra.new
13
- cache = SpecCache.new(hydra, cache_path)
12
+ describe "HTTP cache suite for #{cache_path}" do
13
+ hydra = Typhoeus::Hydra.new
14
+ cache = SpecCache.new(hydra, cache_path)
14
15
 
15
- yield hydra
16
+ before(:each) do
17
+ stub_hydra(hydra)
18
+ end
16
19
 
17
- after(:all) do
18
- cache.remove_unnecessary_cache_files!
19
- cache.dump_cache_fixtures!
20
- cache.clear_hydra_callbacks!
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|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Balatero