typhoeus_spec_cache 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/.gitignore +2 -0
  2. data/README.markdown +78 -0
  3. data/VERSION +1 -1
  4. metadata +7 -5
  5. data/README.rdoc +0 -17
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  typhoeus_spec_cache.gemspec
23
+
24
+ README.markdown.html
data/README.markdown ADDED
@@ -0,0 +1,78 @@
1
+ typhoeus\_spec\_cache
2
+ -------------------
3
+
4
+ Typhoeus is a great frontend to Curl/Curl::Multi. However, if you have a large spec suite that hits a number of external HTTP resources, you will quickly find yourself getting tired of caching all those resources by hand! Trust me. No seriously, I hate doing this by hand.
5
+
6
+ Thanks to [Paul Dix](http://github.com/pauldix) for writing Typhoeus!
7
+
8
+ Usage
9
+ -----
10
+
11
+ In any specs that hit HTTP via `Typhoeus::Hydra`, wrap them in a `typhoeus_spec_cache` block:
12
+
13
+ describe "making 30 expensive HTTP calls" do
14
+ typhoeus_spec_cache("spec/cache/mycache") do |hydra|
15
+ it "should get 10 URLs" do
16
+ result = fetch_urls(10)
17
+ result.should have(10).things
18
+ end
19
+
20
+ it "should get 20 URLs" do
21
+ result = fetch_urls(20)
22
+ result.should have(20).things
23
+ end
24
+ end
25
+ end
26
+
27
+ Create the cache directory:
28
+
29
+ mkdir -p spec/cache/mycache
30
+
31
+ On the first run of these two specs, Typhoeus will make 30 live HTTP requests. These will then be dumped out to `.cache` files in `spec/cache/mycache`, and used on subsequent runs, avoiding any future HTTP calls.
32
+
33
+ Auto-stubbing of Hydra
34
+ ----------------------
35
+
36
+ Calling `typhoeus_spec_cache` automatically stubs out calls to Typhoeus::Hydra.new with a single shared Hydra object.
37
+
38
+ Auto-managing of cache files
39
+ ----------------------------
40
+
41
+ If the URLs your code hits ever changes, the `typhoeus_spec_cache` wrapper is smart about handling your cache. It will:
42
+
43
+ * Only download new URLs it hasn't seen.
44
+ * Remove any `.cache` files that aren't needed anymore.
45
+
46
+ This way, your cache directory will contain exactly the `.cache` files you need, and no more.
47
+
48
+ Installation
49
+ ------------
50
+
51
+ sudo gem install typhoeus_spec_cache
52
+
53
+ Then, add the following to your spec/spec_helper.rb
54
+
55
+ require 'typhoeus_spec_cache'
56
+
57
+ And add these two lines to your `Spec::Runner.configure` block in `spec/spec_helper.rb`:
58
+
59
+ Spec::Runner.configure do |config|
60
+ config.include(Typhoeus::SpecCacheMacros::InstanceMethods)
61
+ config.extend(Typhoeus::SpecCacheMacros::ClassMethods)
62
+ end
63
+
64
+ Note on Patches/Pull Requests
65
+ -----------------------------
66
+
67
+ * Fork the project.
68
+ * Make your feature addition or bug fix.
69
+ * Add tests for it. This is important so I don't break it in a
70
+ future version unintentionally.
71
+ * Commit, do not mess with rakefile, version, or history.
72
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
73
+ * Send me a pull request. Bonus points for topic branches.
74
+
75
+ Copyright
76
+ ---------
77
+
78
+ Copyright (c) 2010 David Balatero. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
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-06 00:00:00 -07:00
17
+ date: 2010-04-07 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,12 +39,13 @@ extensions: []
39
39
 
40
40
  extra_rdoc_files:
41
41
  - LICENSE
42
- - README.rdoc
42
+ - README.markdown
43
+ - README.markdown.html
43
44
  files:
44
45
  - .document
45
46
  - .gitignore
46
47
  - LICENSE
47
- - README.rdoc
48
+ - README.markdown
48
49
  - Rakefile
49
50
  - VERSION
50
51
  - lib/typhoeus/response_marshalling.rb
@@ -55,6 +56,7 @@ files:
55
56
  - spec/spec_helper.rb
56
57
  - spec/typhoeus/spec_cache_macros_spec.rb
57
58
  - spec/typhoeus/spec_cache_spec.rb
59
+ - README.markdown.html
58
60
  has_rdoc: true
59
61
  homepage: http://github.com/dbalatero/typhoeus_spec_cache
60
62
  licenses: []
data/README.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = typhoeus_spec_cache
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 David Balatero. See LICENSE for details.