typhoeus_spec_cache 0.1.2 → 0.2.0
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/README.markdown +1 -1
- data/VERSION +1 -1
- data/lib/typhoeus/instance_exec.rb +33 -0
- data/lib/typhoeus/spec_cache.rb +2 -1
- data/lib/typhoeus/spec_cache_macros.rb +1 -1
- metadata +4 -3
data/README.markdown
CHANGED
@@ -33,7 +33,7 @@ On the first run of these two specs, Typhoeus will make 30 live HTTP requests. T
|
|
33
33
|
Auto-stubbing of Hydra
|
34
34
|
----------------------
|
35
35
|
|
36
|
-
Calling `typhoeus_spec_cache` automatically stubs out calls to Typhoeus::Hydra
|
36
|
+
Calling `typhoeus_spec_cache` automatically stubs out calls to `Typhoeus::Hydra#new` with a single shared Hydra object.
|
37
37
|
|
38
38
|
Auto-managing of cache files
|
39
39
|
----------------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This patch allows calling of instance_exec in Ruby implementations
|
2
|
+
# below 1.8.7.
|
3
|
+
#
|
4
|
+
# Patch taken from activesupport.
|
5
|
+
|
6
|
+
class Object
|
7
|
+
unless defined? instance_exec # 1.9, < 1.8.7
|
8
|
+
module InstanceExecMethods #:nodoc:
|
9
|
+
end
|
10
|
+
include InstanceExecMethods
|
11
|
+
|
12
|
+
# Evaluate the block with the given arguments within the context of
|
13
|
+
# this object, so self is set to the method receiver.
|
14
|
+
#
|
15
|
+
# From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec
|
16
|
+
def instance_exec(*args, &block)
|
17
|
+
begin
|
18
|
+
old_critical, Thread.critical = Thread.critical, true
|
19
|
+
n = 0
|
20
|
+
n += 1 while respond_to?(method_name = "__instance_exec#{n}")
|
21
|
+
InstanceExecMethods.module_eval { define_method(method_name, &block) }
|
22
|
+
ensure
|
23
|
+
Thread.critical = old_critical
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
send(method_name, *args)
|
28
|
+
ensure
|
29
|
+
InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/typhoeus/spec_cache.rb
CHANGED
@@ -46,7 +46,8 @@ module Typhoeus
|
|
46
46
|
|
47
47
|
# Reads in the cache fixture files to in-memory cache.
|
48
48
|
def read_cache_fixtures!
|
49
|
-
|
49
|
+
files = cache_files
|
50
|
+
files.each do |file|
|
50
51
|
cache_key = get_cache_key_from_filename(file)
|
51
52
|
responses[cache_key] = Marshal.load(File.read(file))
|
52
53
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Balatero
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-29 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.markdown
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
|
+
- lib/typhoeus/instance_exec.rb
|
51
52
|
- lib/typhoeus/response_marshalling.rb
|
52
53
|
- lib/typhoeus/spec_cache.rb
|
53
54
|
- lib/typhoeus/spec_cache_macros.rb
|