vcr_helper 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/vcr_helper/version.rb +4 -0
- data/lib/vcr_helper.rb +83 -0
- data/vcr_helper.gemspec +22 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed117e11f0437a598df9f48b28433493a2494288
|
4
|
+
data.tar.gz: 95dc4cc48768c1ba623b7db83685632903ecd0a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 357bd82e6225e70c6ba4f96be3d0caa41cbdd74d5b0132cebda639288104abbd4ed27fc95139a95b6f50b0e675513675dc219922f2fe5126c71010d97ed3e5c5
|
7
|
+
data.tar.gz: 4fe348aac9c4f3621c947a2fa763087e7cea19453f94ff209af7e7099aba0ab466e4d84f540100550faeecac8beade7c30130c0b0e28314dd77335f2a0ee7aaf
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Josh Sharpe
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# VcrHelper
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vcr_helper'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vcr_helper
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/vcr_helper.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'vcr_helper/version'
|
2
|
+
|
3
|
+
if defined?(Test::Unit)
|
4
|
+
require 'webmock/test_unit'
|
5
|
+
end
|
6
|
+
if defined?(Rspec)
|
7
|
+
require 'webmock/rspec'
|
8
|
+
end
|
9
|
+
|
10
|
+
module VcrHelper
|
11
|
+
#
|
12
|
+
# Must be included after #setup and #teardown have been defined.
|
13
|
+
#
|
14
|
+
# Pass VR=true to a test or rake to open network connectivity and re-record all requests and responses
|
15
|
+
# Otherwise, blocks all network connectivity and uses cassettes to replay requests and responses.
|
16
|
+
#
|
17
|
+
# Stores all cassettes in test/vcr_cassettes.
|
18
|
+
# Each test case is saved to a different file.
|
19
|
+
#
|
20
|
+
|
21
|
+
def record?
|
22
|
+
ENV['VR']
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_rspec_cassette_name(example_group)
|
26
|
+
if example_group
|
27
|
+
example_group[:description_args].clone.unshift(*build_rspec_cassette_name(example_group[:example_group]))
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def cassette_name
|
34
|
+
if self.respond_to?(:described_class)
|
35
|
+
build_rspec_cassette_name(self.example.metadata).join("_").underscore.gsub('/','_').gsub(' ', '_').gsub(/[^a-z0-9\s_]/, '')
|
36
|
+
else
|
37
|
+
(self.class.name.underscore.gsub('/','_') + '__' + self.method_name.gsub(/^test[:_](\s?)/, '')).strip.downcase.squeeze(' ').gsub(/[^a-z0-9\s_]/, '').gsub(' ', '_')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# This method will be overridden in Test::Unit with the alias_method_chain method below; it exists to make rspec work
|
42
|
+
def setup_without_vcr
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_with_vcr
|
46
|
+
# call this at the top of ActiveSupport::TestCase
|
47
|
+
if record?
|
48
|
+
FileUtils.rm_rf "#{VCR.configuration.cassette_library_dir}/#{cassette_name}.yml"
|
49
|
+
VCR.insert_cassette(cassette_name, :record => :all)
|
50
|
+
::WebMock.allow_net_connect!
|
51
|
+
else
|
52
|
+
VCR.insert_cassette(cassette_name, :record => :none, :match_requests_on => [:host, :path])
|
53
|
+
::WebMock.disable_net_connect!
|
54
|
+
end
|
55
|
+
setup_without_vcr
|
56
|
+
end
|
57
|
+
|
58
|
+
# This method will be overridden in Test::Unit with the alias_method_chain method below; it exists to make rspec work
|
59
|
+
def teardown_without_vcr
|
60
|
+
end
|
61
|
+
|
62
|
+
def teardown_with_vcr
|
63
|
+
teardown_without_vcr
|
64
|
+
VCR.eject_cassette
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.included(base)
|
68
|
+
base.class_eval do
|
69
|
+
if base.respond_to?(:before)
|
70
|
+
base.before do
|
71
|
+
setup_with_vcr
|
72
|
+
end
|
73
|
+
base.after do
|
74
|
+
teardown_with_vcr
|
75
|
+
end
|
76
|
+
else
|
77
|
+
# We use alias method chain here because we need these setup methods to wrap the entire suit
|
78
|
+
alias_method_chain :setup, :vcr
|
79
|
+
alias_method_chain :teardown, :vcr
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/vcr_helper.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vcr_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vcr_helper"
|
8
|
+
gem.version = VcrHelper::VERSION
|
9
|
+
gem.authors = ["Josh Sharpe"]
|
10
|
+
gem.email = ["josh.m.sharpe@gmail.com"]
|
11
|
+
gem.description = %q{makes vcr easier to use}
|
12
|
+
gem.summary = %q{makes vcr easier to use}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency "vcr"
|
20
|
+
gem.add_dependency "webmock"
|
21
|
+
end
|
22
|
+
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vcr_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Sharpe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-22 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webmock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: makes vcr easier to use
|
42
|
+
email:
|
43
|
+
- josh.m.sharpe@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/vcr_helper.rb
|
54
|
+
- lib/vcr_helper/version.rb
|
55
|
+
- vcr_helper.gemspec
|
56
|
+
homepage: ''
|
57
|
+
licenses: []
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.2.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: makes vcr easier to use
|
79
|
+
test_files: []
|