vcr-fakefs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +12 -0
- data/Guardfile +50 -0
- data/LICENSE +21 -0
- data/README.md +55 -0
- data/lib/vcr/fakefs/fakefs_persister.rb +22 -0
- data/lib/vcr/fakefs/version.rb +11 -0
- data/lib/vcr-fakefs.rb +12 -0
- data/spec/fixtures/vcr_cassettes/site.yml +66 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/vcr-fakefs_spec.rb +34 -0
- data/vcr-fakefs.gemspec +31 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9333541b859c1b9b2036701b2bf6bffb96b3d904
|
4
|
+
data.tar.gz: 9f219cbcc77051676c0315bb01e63dcec0bdadb2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0036cf7337b90f2fcab8e58845bf889f6c11c31dd8fbfee4bc4ac6066ba60f4397475daa6f6011e463de7d7f5ef455385da530e288bb65a96d4ff5e5aa634e21
|
7
|
+
data.tar.gz: 1e16a3e81a32f169ab42121ef76912d21eb81341dc774a30bc5c304fd058cfc7146400818bafb8dd8146af45bfbe45bba31e7e785c02b5b6fa1025b6918c151b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
directories %w(lib spec)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
36
|
+
require "guard/rspec/dsl"
|
37
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
38
|
+
|
39
|
+
# Feel free to open issues for suggestions and improvements
|
40
|
+
|
41
|
+
# RSpec files
|
42
|
+
rspec = dsl.rspec
|
43
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
44
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
45
|
+
watch(rspec.spec_files)
|
46
|
+
|
47
|
+
# Ruby files
|
48
|
+
ruby = dsl.ruby
|
49
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
50
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Tyler Collier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# VCR-FakeFS
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/vcr-fakefs.png)](http://badge.fury.io/rb/vcr-fakefs) [![Build Status](https://secure.travis-ci.org/tylercollier/vcr-fakefs.png?branch=master)](http://travis-ci.org/tylercollier/vcr-fakefs)
|
4
|
+
|
5
|
+
For use with the VCR and FakeFS gems.
|
6
|
+
|
7
|
+
Record your vcr cassettes to the real file system, even when using FakeFS.
|
8
|
+
|
9
|
+
Without VCR-FakeFS, if you use both VCR and FakeFS, FakeFS works as you intend, but while it's activated, VCR's cassettes from your real file system won't exist, and network calls won't be saved to your real FS, defeating the purpose of using it. VCR-FakeFS keeps FakeFS the same, and makes sure VCR uses your real file system for storage.
|
10
|
+
|
11
|
+
# Install
|
12
|
+
|
13
|
+
## Using bundler
|
14
|
+
|
15
|
+
```
|
16
|
+
gem 'vcr-fakefs'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Manually
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install vcr-fakefs
|
23
|
+
```
|
24
|
+
|
25
|
+
Require the gem before your tests:
|
26
|
+
|
27
|
+
```
|
28
|
+
require 'vcr-fakefs'
|
29
|
+
```
|
30
|
+
|
31
|
+
# Usage / How does it work?
|
32
|
+
|
33
|
+
By default, you don't need to do anything extra besides require the gem.
|
34
|
+
|
35
|
+
VCR-FakeFS configures VCR automatically to use an alternative file system persister, which will use FakeFS's `without` tactic to bypass the fake file system to use VCR's original (real) file system persister.
|
36
|
+
|
37
|
+
If you want it to work differently (e.g. not automatically), just open an issue on Github.
|
38
|
+
|
39
|
+
# Thanks
|
40
|
+
|
41
|
+
Thank you to Myron Marston (@myronmarston) and Mark Van de Vyver (@taqtiqa-mark), for the enormously helpful conversation [here](https://github.com/vcr/vcr/issues/234).
|
42
|
+
|
43
|
+
Thank you to to Brian Donovan (@eventualbuddha) for pointing out how easily [this could be done with FakeFS](https://github.com/defunkt/fakefs/issues/167).
|
44
|
+
|
45
|
+
# License
|
46
|
+
|
47
|
+
The MIT License (MIT)
|
48
|
+
|
49
|
+
Copyright (c) 2015 Tyler Collier
|
50
|
+
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'fakefs/safe'
|
3
|
+
|
4
|
+
module VCR
|
5
|
+
module FakeFS
|
6
|
+
class FakeFSPersister
|
7
|
+
def initialize
|
8
|
+
@orig_fs_persister = VCR.cassette_persisters[:file_system]
|
9
|
+
@storage_location = @orig_fs_persister.storage_location
|
10
|
+
end
|
11
|
+
|
12
|
+
# I got this idea from: http://www.alfajango.com/blog/method_missing-a-rubyists-beautiful-mistress/
|
13
|
+
VCR::Cassette::Persisters.instance_methods(false).each do |name|
|
14
|
+
define_method(name) do |*args, &block|
|
15
|
+
::FakeFS.without do
|
16
|
+
@orig_fs_persister.send name, *args, &block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/vcr-fakefs.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'fakefs/safe'
|
3
|
+
require 'vcr/fakefs/fakefs_persister'
|
4
|
+
|
5
|
+
module VCR
|
6
|
+
module FakeFS
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_persisters[:fakefs_persister] = VCR::FakeFS::FakeFSPersister.new
|
9
|
+
c.default_cassette_options = { persist_with: :fakefs_persister }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.google.com/
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 04 Mar 2015 22:33:23 GMT
|
23
|
+
Expires:
|
24
|
+
- "-1"
|
25
|
+
Cache-Control:
|
26
|
+
- private, max-age=0
|
27
|
+
Content-Type:
|
28
|
+
- text/html; charset=ISO-8859-1
|
29
|
+
Set-Cookie:
|
30
|
+
- NID=67=UxfkHunkO6KWSb8lPeVNRmlPVsfX5D0mG1nOklOiyNzX4o0K3VwiIWtu2DjaRQXVpUFEInpMTe_lS2NTKYCADMjmSXFq7RaBUmrwuqSfsGFbCjGtADxZ2-M6ZGUijqGz;
|
31
|
+
expires=Thu, 03-Sep-2015 22:33:23 GMT; path=/; domain=.google.com; HttpOnly
|
32
|
+
- PREF=ID=61d681070280438c:FF=0:TM=1425508403:LM=1425508403:S=ISRJXtNEZ-AOphRW;
|
33
|
+
expires=Fri, 03-Mar-2017 22:33:23 GMT; path=/; domain=.google.com
|
34
|
+
P3p:
|
35
|
+
- CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657
|
36
|
+
for more info."
|
37
|
+
Server:
|
38
|
+
- gws
|
39
|
+
X-Xss-Protection:
|
40
|
+
- 1; mode=block
|
41
|
+
X-Frame-Options:
|
42
|
+
- SAMEORIGIN
|
43
|
+
Alternate-Protocol:
|
44
|
+
- 80:quic,p=0.08
|
45
|
+
Accept-Ranges:
|
46
|
+
- none
|
47
|
+
Vary:
|
48
|
+
- Accept-Encoding
|
49
|
+
Transfer-Encoding:
|
50
|
+
- chunked
|
51
|
+
Proxy-Connection:
|
52
|
+
- Keep-alive
|
53
|
+
body:
|
54
|
+
encoding: UTF-8
|
55
|
+
string: |-
|
56
|
+
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="/images/google_favicon_128.png" itemprop="image"><title>Google</title><script>(function(){window.google={kEI:'M4j3VP6bI9HmoASn3YCYDA',kEXPI:'3700304,3700362,4011009,4020347,4020562,4020726,4020873,4021338,4023678,4025633,4025836,4028527,4028717,4029054,4029141,4029155,4029510,4029515,4029613,4029796,4029798,4029811,4029844,4029962,4030154,4030170,4030183,4030440,8300123,8500393,8500852,8501081,10200083',authuser:0,kSID:'M4j3VP6bI9HmoASn3YCYDA'};google.kHL='en';})();(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI};google.getLEI=function(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b};google.https=function(){return"https:"==window.location.protocol};google.ml=function(){};google.time=function(){return(new Date).getTime()};google.log=function(a,b,e,f,l){var d=new Image,h=google.lc,g=google.li,c="",m=google.ls||"";d.onerror=d.onload=d.onabort=function(){delete h[g]};h[g]=d;if(!e&&-1==b.search("&ei=")){var k=google.getEI(f),c="&ei="+k;-1==b.search("&lei=")&&((f=google.getLEI(f))?c+="&lei="+f:k!=google.kEI&&(c+="&lei="+google.kEI))}a=e||"/"+(l||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+c+m+"&zx="+google.time();/^http:/i.test(a)&&google.https()?(google.ml(Error("a"),!1,{src:a,glmm:1}),delete h[g]):(d.src=a,google.li=g+1)};google.y={};google.x=function(a,b){google.y[a.id]=[a,b];return!1};google.load=function(a,b,e){google.x({id:a+n++},function(){google.load(a,b,e)})};var n=0;})();google.kCSI={};var _gjwl=location;function _gjuc(){var a=_gjwl.href.indexOf("#");if(0<=a&&(a=_gjwl.href.substring(a),0<a.indexOf("&q=")||0<=a.indexOf("#q="))&&(a=a.substring(1),-1==a.indexOf("#"))){for(var d=0;d<a.length;){var b=d;"&"==a.charAt(b)&&++b;var c=a.indexOf("&",b);-1==c&&(c=a.length);b=a.substring(b,c);if(0==b.indexOf("fp="))a=a.substring(0,d)+a.substring(c,a.length),c=d;else if("cad=h"==b)return 0;d=c}_gjwl.href="/search?"+a+"&cad=h";return 1}return 0}
|
57
|
+
function _gjh(){!_gjuc()&&window.google&&google.x&&google.x({id:"GJH"},function(){google.nav&&google.nav.gjh&&google.nav.gjh()})};window._gjh&&_gjh();</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#36c}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c !important}body{background:#fff;color:black}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff !important}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #999 #ccc;height:30px}.lsbb{display:block}.ftl,#fll a{display:inline-block;margin:0 12px}.lsb{background:url(/images/srpr/nav_logo80.png) 0 -258px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}</style><script></script></head><body bgcolor="#fff"><script>(function(){var src='/images/nav_logo176.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
|
58
|
+
if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
|
59
|
+
}
|
60
|
+
})();</script><div id="mngb"> <div id=gbar><nobr><b class=gb1>Search</b> <a class=gb1 href="http://www.google.com/imghp?hl=en&tab=wi">Images</a> <a class=gb1 href="http://maps.google.com/maps?hl=en&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=en&tab=w8">Play</a> <a class=gb1 href="http://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="http://news.google.com/nwshp?hl=en&tab=wn">News</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="http://www.google.com/intl/en/options/"><u>More</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.com/history/optout?hl=en" class=gb4>Web History</a> | <a href="/preferences?hl=en" class=gb4>Settings</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com/" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div> </div><center><span id="prt" style="display:block"> <div><style>.pmoabs{background-color:#fff;border:1px solid #E5E5E5;color:#666;font-size:13px;padding-bottom:20px;position:absolute;right:2px;top:3px;z-index:986}#pmolnk{border-radius:2px;-moz-border-radius:2px;-webkit-border-radius:2px}.kd-button-submit{border:1px solid #3079ed;background-color:#4d90fe;background-image:-webkit-gradient(linear,left top,left bottom,from(#4d90fe),to(#4787ed));background-image:-webkit-linear-gradient(top,#4d90fe,#4787ed);background-image:-moz-linear-gradient(top,#4d90fe,#4787ed);background-image:-ms-linear-gradient(top,#4d90fe,#4787ed);background-image:-o-linear-gradient(top,#4d90fe,#4787ed);background-image:linear-gradient(top,#4d90fe,#4787ed);filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#4d90fe',EndColorStr='#4787ed')}.kd-button-submit:hover{border:1px solid #2f5bb7;background-color:#357ae8;background-image:-webkit-gradient(linear,left top,left bottom,from(#4d90fe),to(#357ae8));background-image:-webkit-linear-gradient(top,#4d90fe,#357ae8);background-image:-moz-linear-gradient(top,#4d90fe,#357ae8);background-image:-ms-linear-gradient(top,#4d90fe,#357ae8);background-image:-o-linear-gradient(top,#4d90fe,#357ae8);background-image:linear-gradient(top,#4d90fe,#357ae8);filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#4d90fe',EndColorStr='#357ae8')}.kd-button-submit:active{-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);box-shadow:inset 0 1px 2px rgba(0,0,0,0.3)}#pmolnk a{color:#fff;display:inline-block;font-weight:bold;padding:5px 20px;text-decoration:none;white-space:nowrap}.xbtn{color:#999;cursor:pointer;font-size:23px;line-height:5px;padding-top:5px}.padi{padding:0 8px 0 10px}.padt{padding:5px 20px 0 0;color:#444}.pads{text-align:left;max-width:200px}</style> <div class="pmoabs" id="pmocntr2" style="behavior:url(#default#userdata);display:none"> <table border="0"> <tr> <td colspan="2"> <div class="xbtn" onclick="google.promos&&google.promos.toast&& google.promos.toast.cpc()" style="float:right">×</div> </td> </tr> <tr> <td class="padi" rowspan="2"> <img src="/images/icons/product/chrome-48.png"> </td> <td class="pads">A faster way to browse the web</td> </tr> <tr> <td class="padt"> <div class="kd-button-submit" id="pmolnk"> <a href="/chrome/index.html?hl=en&brand=CHNG&utm_source=en-hpp&utm_medium=hpp&utm_campaign=en" onclick="google.promos&&google.promos.toast&& google.promos.toast.cl()">Install Google Chrome</a> </div> </td> </tr> </table> </div> <script type="text/javascript">(function(){var a={o:{}};a.o.qa=50;a.o.oa=10;a.o.Y="body";a.o.Oa=!0;a.o.Ra=function(b,c){var d=a.o.Ea();a.o.Ga(d,b,c);a.o.Sa(d);a.o.Oa&&a.o.Pa(d)};a.o.Sa=function(b){(b=a.o.$(b))&&0<b.forms.length&&b.forms[0].submit()};a.o.Ea=function(){var b=document.createElement("iframe");b.height=0;b.width=0;b.style.overflow="hidden";b.style.top=b.style.left="-100px";b.style.position="absolute";document.body.appendChild(b);return b};a.o.$=function(b){return b.contentDocument||b.contentWindow.document};a.o.Ga=function(b,c,d){b=a.o.$(b);b.open();d=["<",a.o.Y,'><form method=POST action="',d,'">'];for(var e in c)c.hasOwnProperty(e)&&d.push('<textarea name="',e,'">',c[e],"</textarea>");d.push("</form></",a.o.Y,">");b.write(d.join(""));b.close()};a.o.ba=function(b,c){c>a.o.oa?google&&google.ml&&google.ml(Error("ogcdr"),!1,{cause:"timeout"}):b.contentWindow?a.o.Qa(b):window.setTimeout(function(){a.o.ba(b,c+1)},a.o.qa)};a.o.Qa=function(b){document.body.removeChild(b)};a.o.Pa=function(b){a.o.Ca(b,"load",function(){a.o.ba(b,0)})};a.o.Ca=function(b,c,d){b.addEventListener?b.addEventListener(c,d,!1):b.attachEvent&&b.attachEvent("on"+c,d)};var m={Va:0,D:1,F:2,K:5};a.k={};a.k.M={ka:"i",J:"d",ma:"l"};a.k.A={N:"0",G:"1"};a.k.O={L:1,J:2,I:3};a.k.v={ea:"a",ia:"g",C:"c",ya:"u",xa:"t",N:"p",pa:"pid",ga:"eid",za:"at"};a.k.la=window.location.protocol+"//www.google.com/_/og/promos/";a.k.ha="g";a.k.Aa="z";a.k.S=function(b,c,d,e){var f=null;switch(c){case m.D:f=window.gbar.up.gpd(b,d,!0);break;case m.K:f=window.gbar.up.gcc(e)}return null==f?0:parseInt(f,10)};a.k.Ka=function(b,c,d){return c==m.D?null!=window.gbar.up.gpd(b,d,!0):!1};a.k.P=function(b,c,d,e,f,h,k,l){var g={};g[a.k.v.N]=b;g[a.k.v.ia]=c;g[a.k.v.ea]=d;g[a.k.v.za]=e;g[a.k.v.ga]=f;g[a.k.v.pa]=1;k&&(g[a.k.v.C]=k);l&&(g[a.k.v.ya]=l);if(h)g[a.k.v.xa]=h;else return google.ml(Error("knu"),!1,{cause:"Token is not found"}),null;return g};a.k.V=function(b,c,d){if(b){var e=c?a.k.ha:a.k.Aa;c&&d&&(e+="?authuser="+d);a.o.Ra(b,a.k.la+e)}};a.k.Fa=function(b,c,d,e,f,h,k){b=a.k.P(c,b,a.k.M.J,a.k.O.J,d,f,null,e);a.k.V(b,h,k)};a.k.Ia=function(b,c,d,e,f,h,k){b=a.k.P(c,b,a.k.M.ka,a.k.O.L,d,f,e,null);a.k.V(b,h,k)};a.k.Na=function(b,c,d,e,f,h,k,l,g,n){switch(c){case m.K:window.gbar.up.dpc(e,f);break;case m.D:window.gbar.up.spd(b,d,1,!0);break;case m.F:g=g||!1,l=l||"",h=h||0,k=k||a.k.A.G,n=n||0,a.k.Fa(e,h,k,f,l,g,n)}};a.k.La=function(b,c,d,e,f){return c==m.D?0<d&&a.k.S(b,c,e,f)>=d:!1};a.k.Ha=function(b,c,d,e,f,h,k,l,g,n){switch(c){case m.K:window.gbar.up.iic(e,f);break;case m.D:c=a.k.S(b,c,d,e)+1;window.gbar.up.spd(b,d,c.toString(),!0);break;case m.F:g=g||!1,l=l||"",h=h||0,k=k||a.k.A.N,n=n||0,a.k.Ia(e,h,k,1,l,g,n)}};a.k.Ma=function(b,c,d,e,f,h){b=a.k.P(c,b,a.k.M.ma,a.k.O.I,d,e,null,null);a.k.V(b,f,h)};var p={Ta:"a",Wa:"l",Ua:"c",fa:"d",I:"h",L:"i",gb:"n",G:"x",cb:"ma",eb:"mc",fb:"mi",Xa:"pa",Ya:"pc",$a:"pi",bb:"pn",ab:"px",Za:"pd",hb:"gpa",jb:"gpi",kb:"gpn",lb:"gpx",ib:"gpd"};a.i={};a.i.s={na:"hplogo",wa:"pmocntr2"};a.i.A={va:"0",G:"1",da:"2"};a.i.p=document.getElementById(a.i.s.wa);a.i.ja=16;a.i.ra=2;a.i.ta=20;google.promos=google.promos||{};google.promos.toast=google.promos.toast||{};a.i.H=function(b){a.i.p&&(a.i.p.style.display=b?"":"none",a.i.p.parentNode&&(a.i.p.parentNode.style.position=b?"relative":""))};a.i.ca=function(b){try{if(a.i.p&&b&&b.es&&b.es.m){var c=window.gbar.rtl(document.body)?"left":"right";a.i.p.style[c]=b.es.m-a.i.ja+a.i.ra+"px";a.i.p.style.top=a.i.ta+"px"}}catch(d){google.ml(d,!1,{cause:a.i.w+"_PT"})}};google.promos.toast.cl=function(){try{a.i.Q==m.F&&a.k.Ma(a.i.T,a.i.B,a.i.A.da,a.i.X,a.i.U,a.i.W),window.gbar.up.sl(a.i.B,a.i.w,p.I,a.i.R(),1)}catch(b){google.ml(b,!1,{cause:a.i.w+"_CL"})}};google.promos.toast.cpc=function(){try{a.i.p&&(a.i.H(!1),a.k.Na(a.i.p,a.i.Q,a.i.s.Z,a.i.T,a.i.Da,a.i.B,a.i.A.G,a.i.X,a.i.U,a.i.W),window.gbar.up.sl(a.i.B,a.i.w,p.fa,a.i.R(),1))}catch(b){google.ml(b,!1,{cause:a.i.w+"_CPC"})}};a.i.aa=function(){try{if(a.i.p){var b=276,c=document.getElementById(a.i.s.na);c&&(b=Math.max(b,c.offsetWidth));var d=parseInt(a.i.p.style.right,10)||0;a.i.p.style.visibility=2*(a.i.p.offsetWidth+d)+b>document.body.clientWidth?"hidden":""}}catch(e){google.ml(e,!1,{cause:a.i.w+"_HOSW"})}};a.i.Ba=function(){var b=["gpd","spd","aeh","sl"];if(!window.gbar||!window.gbar.up)return!1;for(var c=0,d;d=b[c];c++)if(!(d in window.gbar.up))return!1;return!0};a.i.Ja=function(){return a.i.p.currentStyle&&"absolute"!=a.i.p.currentStyle.position};google.promos.toast.init=function(b,c,d,e,f,h,k,l,g,n,q,r){try{a.i.Ba()?a.i.p&&(e==m.F&&!l==!g?(google.ml(Error("tku"),!1,{cause:"zwieback: "+g+", gaia: "+l}),a.i.H(!1)):(a.i.s.C="toast_count_"+c+(q?"_"+q:""),a.i.s.Z="toast_dp_"+c+(r?"_"+r:""),a.i.w=d,a.i.B=b,a.i.Q=e,a.i.T=c,a.i.Da=f,a.i.X=l?l:g,a.i.U=!!l,a.i.W=k,a.k.Ka(a.i.p,e,a.i.s.Z,c)||a.k.La(a.i.p,e,h,a.i.s.C,c)||a.i.Ja()?a.i.H(!1):(a.k.Ha(a.i.p,e,a.i.s.C,c,f,a.i.B,a.i.A.va,a.i.X,a.i.U,a.i.W),n||(window.gbar.up.aeh(window,"resize",a.i.aa),window.lol=
|
61
|
+
a.i.aa,window.gbar.elr&&a.i.ca(window.gbar.elr()),window.gbar.elc&&window.gbar.elc(a.i.ca),a.i.H(!0)),window.gbar.up.sl(a.i.B,a.i.w,p.L,a.i.R())))):google.ml(Error("apa"),!1,{cause:a.i.w+"_INIT"})}catch(t){google.ml(t,!1,{cause:a.i.w+"_INIT"})}};a.i.R=function(){var b=a.k.S(a.i.p,a.i.Q,a.i.s.C,a.i.T);return"ic="+b};})();</script> <script type="text/javascript">(function(){var sourceWebappPromoID=144002;var sourceWebappGroupID=5;var payloadType=5;var cookieMaxAgeSec=2592000;var dismissalType=5;var impressionCap=25;var gaiaXsrfToken='';var zwbkXsrfToken='';var kansasDismissalEnabled=false;var sessionIndex=0;var invisible=false;window.gbar&&gbar.up&&gbar.up.r&&gbar.up.r(payloadType,function(show){if (show){google.promos.toast.init(sourceWebappPromoID,sourceWebappGroupID,payloadType,dismissalType,cookieMaxAgeSec,impressionCap,sessionIndex,gaiaXsrfToken,zwbkXsrfToken,invisible,'0612');}
|
62
|
+
});})();</script> </div> </span><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="95" src="/images/srpr/logo9w.png" style="padding:28px 0 14px" width="269" id="hplogo" onload="window.lol&&lol()"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="en" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><div class="ds" style="height:32px;margin:4px 0"><input style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top" autocomplete="off" class="lst" value="" title="Google Search" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" value="I'm Feeling Lucky" name="btnI" onclick="if(this.form.q.value)this.checked=1; else top.location='/doodles/'" type="submit"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=en&authuser=0">Advanced search</a><a href="/language_tools?hl=en&authuser=0">Language tools</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="fll"><a href="/intl/en/ads/">Advertising Programs</a><a href="/services/">Business Solutions</a><a href="https://plus.google.com/116899029375914044550" rel="publisher">+Google</a><a href="/intl/en/about.html">About Google</a></div></div><p style="color:#767676;font-size:8pt">© 2015 - <a href="/intl/en/policies/privacy/">Privacy</a> - <a href="/intl/en/policies/terms/">Terms</a></p></span></center><div id="xjsd"></div><div id="xjsi" data-jiis="bp"><script>(function(){function c(b){window.setTimeout(function(){var a=document.createElement("script");a.src=b;document.getElementById("xjsd").appendChild(a)},0)}google.dljp=function(b,a){google.xjsu=b;c(a)};google.dlj=c;})();(function(){window.google.xjsrm=[];})();if(google.y)google.y.first=[];if(!google.xjs){window._=window._||{};window._._DumpException=function(e){throw e};if(google.timers&&google.timers.load.t){google.timers.load.t.xjsls=new Date().getTime();}google.dljp('/xjs/_/js/k\x3dxjs.hp.en_US.dZiSPB2oArU.O/m\x3dsb_he,d/rt\x3dj/d\x3d1/t\x3dzcms/rs\x3dACT90oHu5JvNOJYz-rckhJzpAgytoZTMZg','/xjs/_/js/k\x3dxjs.hp.en_US.dZiSPB2oArU.O/m\x3dsb_he,d/rt\x3dj/d\x3d1/t\x3dzcms/rs\x3dACT90oHu5JvNOJYz-rckhJzpAgytoZTMZg');google.xjs=1;}google.pmc={"sb_he":{"agen":true,"cgen":true,"client":"heirloom-hp","dh":true,"ds":"","exp":"msedr","fl":true,"host":"google.com","jam":0,"jsonp":true,"msgs":{"cibl":"Clear Search","dym":"Did you mean:","lcky":"I\u0026#39;m Feeling Lucky","lml":"Learn more","oskt":"Input tools","psrc":"This search was removed from your \u003Ca href=\"/history\"\u003EWeb History\u003C/a\u003E","psrl":"Remove","sbit":"Search by image","srch":"Google Search"},"ovr":{},"pq":"","refoq":true,"scd":10,"sce":5,"stok":"QE6W9iJGw2gPtTzcHhI1MCHH274"},"d":{}};google.y.first.push(function(){if(google.med){google.med('init');google.initHistory();google.med('history');}});if(google.j&&google.j.en&&google.j.xi){window.setTimeout(google.j.xi,0);}
|
63
|
+
</script></div></body></html>
|
64
|
+
http_version:
|
65
|
+
recorded_at: Wed, 04 Mar 2015 22:33:24 GMT
|
66
|
+
recorded_with: VCR 2.9.3
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'fakefs/safe'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Run specs in random order to surface order dependencies. If you find an
|
6
|
+
# order dependency and want to debug it, you can fix the order by providing
|
7
|
+
# the seed, which is printed after each run.
|
8
|
+
# --seed 1234
|
9
|
+
config.order = "random"
|
10
|
+
|
11
|
+
VCR.configure do |c|
|
12
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
13
|
+
c.default_cassette_options = { record: :none, match_requests_on: [:uri, :method, :body] }
|
14
|
+
c.hook_into :webmock
|
15
|
+
c.ignore_localhost = true
|
16
|
+
c.configure_rspec_metadata!
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr-fakefs'
|
3
|
+
|
4
|
+
describe "vcr-fakefs" do
|
5
|
+
let(:url) { "http://www.google.com/" }
|
6
|
+
let(:cassette_path) { 'spec/fixtures/vcr_cassettes/site.yml' }
|
7
|
+
let(:file_download_path) { 'site/page.html' }
|
8
|
+
|
9
|
+
def download_file(url, output_path)
|
10
|
+
uri = URI.parse(url)
|
11
|
+
Net::HTTP.start(uri.host) do |http|
|
12
|
+
resp = http.get uri.path
|
13
|
+
FileUtils.mkdir_p 'site'
|
14
|
+
File.open(file_download_path, "wb") do |file|
|
15
|
+
file.write(resp.body)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "downloads file to fake file system and writes vcr cassette in real file system", vcr: { cassette_name: 'site', record: :none } do
|
21
|
+
expect(File.exists?(file_download_path)).to be false
|
22
|
+
expect(File.exists?(cassette_path)).to be true
|
23
|
+
FakeFS.activate!
|
24
|
+
expect(File.exists?(cassette_path)).to be false
|
25
|
+
|
26
|
+
download_file url, file_download_path
|
27
|
+
|
28
|
+
expect(File.exists?(file_download_path)).to be true
|
29
|
+
expect(File.exists?(cassette_path)).to be false
|
30
|
+
FakeFS.deactivate!
|
31
|
+
expect(File.exists?(file_download_path)).to be false
|
32
|
+
expect(File.exists?(cassette_path)).to be true
|
33
|
+
end
|
34
|
+
end
|
data/vcr-fakefs.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
lib = File.expand_path("../lib", __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require "vcr/fakefs/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "vcr-fakefs"
|
10
|
+
s.version = VCR::FakeFS::Version
|
11
|
+
s.author = "Tyler Collier"
|
12
|
+
s.email = "vcr-fakefs@tylercollier.com"
|
13
|
+
s.summary = "FakeFS plugin for VCR"
|
14
|
+
s.description = "Persist your VCR cassettes to the real FS when using FakeFS"
|
15
|
+
|
16
|
+
s.homepage = "https://rubygems.org/gems/vcr-fakefs"
|
17
|
+
s.license = "MIT"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
20
|
+
s.test_files = s.files.grep(%r{^spec/})
|
21
|
+
s.require_path = "lib"
|
22
|
+
|
23
|
+
# According to the following url, 2.2 is where VCR supported persistence
|
24
|
+
# abstraction: https://github.com/vcr/vcr/issues/234
|
25
|
+
s.add_dependency "vcr", "~> 2.2"
|
26
|
+
# FakeFS 0.4.1 is where the "without" support was added.
|
27
|
+
s.add_dependency "fakefs", "~> 0.4", ">= 0.4.1"
|
28
|
+
|
29
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
30
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vcr-fakefs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tyler Collier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vcr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fakefs
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.4.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.4'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.4.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
description: Persist your VCR cassettes to the real FS when using FakeFS
|
76
|
+
email: vcr-fakefs@tylercollier.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- ".gitignore"
|
82
|
+
- ".rspec"
|
83
|
+
- ".ruby-version"
|
84
|
+
- ".travis.yml"
|
85
|
+
- Gemfile
|
86
|
+
- Guardfile
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- lib/vcr-fakefs.rb
|
90
|
+
- lib/vcr/fakefs/fakefs_persister.rb
|
91
|
+
- lib/vcr/fakefs/version.rb
|
92
|
+
- spec/fixtures/vcr_cassettes/site.yml
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
- spec/vcr-fakefs_spec.rb
|
95
|
+
- vcr-fakefs.gemspec
|
96
|
+
homepage: https://rubygems.org/gems/vcr-fakefs
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.5
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: FakeFS plugin for VCR
|
120
|
+
test_files:
|
121
|
+
- spec/fixtures/vcr_cassettes/site.yml
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/vcr-fakefs_spec.rb
|