vcr-proxy 0.1.8 → 0.1.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 497e6654e537b72efe963d09f428607ca0663107736d953e4f497556e272ab66
4
- data.tar.gz: 294caaf5cdde3f99cd4d75455588c63847be864dec193bf2a8c36bb21c6beb52
3
+ metadata.gz: '07994befde2e4f31f77aecbede9025d962660100931c9bb19b36f1f85599d8f0'
4
+ data.tar.gz: f5d8aba52343655fa409d9a843604d73aa271792492dcc3c0b966720299ba845
5
5
  SHA512:
6
- metadata.gz: 88352b8c422417e4332a0626b95b14929f223bc285b5b0e03932efec10f588a27d15f7b1b5907fc21933ebdf5dcdffa73c170c1a286b801a388488f4cd29fce1
7
- data.tar.gz: f5916fc1ef9dd17c64cf8a5e49261132d9a18b67c15b2f7e1846d8c8ffbf1067f2b86494f849829c002a3160f5af6a7a43e67525a69cb85b60fbf3f02dbb0b1b
6
+ metadata.gz: 15c64956240280ff176faa05e1c33583b525ad22de557f9d0c61fffd038da55fb97fabff455d95fe8851a54887b4614184e524c2cdab17372140b56a73b45211
7
+ data.tar.gz: 96835c14f7d5180bdacd4b5b4adc7502044bf58fea944aeacb5c88d94a97a92a10b8d3a0994185d5396dd4acfb4b7c012f93a5451e9905c088fccb1a3870f196
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vcr-proxy (0.1.8)
4
+ vcr-proxy (0.1.9)
5
5
  faraday
6
6
  sinatra
7
7
  vcr
@@ -9,15 +9,24 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
12
16
  faraday (0.17.0)
13
17
  multipart-post (>= 1.2, < 3)
18
+ hashdiff (1.0.0)
14
19
  minitest (5.13.0)
15
20
  multipart-post (2.1.1)
16
21
  mustermann (1.0.3)
22
+ public_suffix (4.0.1)
17
23
  rack (2.0.7)
18
24
  rack-protection (2.0.7)
19
25
  rack
26
+ rack-test (1.1.0)
27
+ rack (>= 1.0, < 3)
20
28
  rake (10.5.0)
29
+ safe_yaml (1.0.5)
21
30
  sinatra (2.0.7)
22
31
  mustermann (~> 1.0)
23
32
  rack (~> 2.0)
@@ -25,6 +34,10 @@ GEM
25
34
  tilt (~> 2.0)
26
35
  tilt (2.0.10)
27
36
  vcr (5.0.0)
37
+ webmock (3.7.6)
38
+ addressable (>= 2.3.6)
39
+ crack (>= 0.3.2)
40
+ hashdiff (>= 0.4.0, < 2.0.0)
28
41
 
29
42
  PLATFORMS
30
43
  ruby
@@ -32,8 +45,10 @@ PLATFORMS
32
45
  DEPENDENCIES
33
46
  bundler (~> 2.0)
34
47
  minitest (~> 5.0)
48
+ rack-test
35
49
  rake (~> 10.0)
36
50
  vcr-proxy!
51
+ webmock
37
52
 
38
53
  BUNDLED WITH
39
54
  2.0.1
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Vcr::Proxy
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vcr/proxy`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Web proxy based on Sinatra and VCR to record and replay all the http requests, useful for end to end tests.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,18 +20,22 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ The basic usage usage is:
26
24
 
27
- ## Development
25
+ ```bash
26
+ $ vcr-proxy -e http://example.com -l spec/fixtures/vcr_cassettes
27
+ ```
28
28
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+ Check `vcr-proxy --help` for details.
30
+
31
+ ## Development
30
32
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+ After checking out the repo, run `bin/setup` to install dependencies. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
34
 
33
35
  ## Contributing
34
36
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vcr-proxy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ceritiun/vcr-proxy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
38
 
37
39
  ## Code of Conduct
38
40
 
39
- Everyone interacting in the Vcr::Proxy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vcr-proxy/blob/master/CODE_OF_CONDUCT.md).
41
+ Everyone interacting in the Vcr::Proxy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ceritium/vcr-proxy/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
10
- task :default => :test
12
+ task default: :test
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "vcr/proxy"
4
+ require 'bundler/setup'
5
+ require 'vcr/proxy'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "vcr/proxy"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/lib/vcr/proxy.rb CHANGED
@@ -1,9 +1,10 @@
1
- require "singleton"
2
- require "vcr/proxy/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+ require 'vcr/proxy/version'
3
5
 
4
6
  module VCR
5
7
  module Proxy
6
-
7
8
  def self.config
8
9
  Config.instance
9
10
  end
data/lib/vcr/proxy/app.rb CHANGED
@@ -13,33 +13,53 @@ class App < Sinatra::Base
13
13
 
14
14
  post '*' do
15
15
  vcr_wrapper('post') do
16
- uri = URI("#{VCR::Proxy.config}#{request.path}")
17
- uri.query = URI.encode_www_form(request.params)
18
- response = Faraday.post(uri, request.body.read, request_headers)
16
+ response = Faraday.post(request_uri, request.body.read, request_headers)
17
+ relay_response(response)
18
+ end
19
+ end
20
+
21
+ put '*' do
22
+ vcr_wrapper('put') do
23
+ response = Faraday.put(request_uri, request.body.read, request_headers)
24
+ relay_response(response)
25
+ end
26
+ end
27
+
28
+ patch '*' do
29
+ vcr_wrapper('patch') do
30
+ response = Faraday.patch(request_uri, request.body.read, request_headers)
31
+ relay_response(response)
32
+ end
33
+ end
34
+
35
+ delete '*' do
36
+ vcr_wrapper('delete') do
37
+ response = Faraday.delete(request_uri, {}, request_headers)
19
38
  relay_response(response)
20
39
  end
21
40
  end
22
41
 
23
42
  get '*' do
24
43
  vcr_wrapper('get') do
25
- uri = URI("#{VCR::Proxy.config.endpoint}#{request.path}")
26
- uri.query = URI.encode_www_form(request.params)
27
- response = Faraday.get(uri, request.params, request_headers)
44
+ response = Faraday.get(request_uri, {}, request_headers)
28
45
  relay_response(response)
29
46
  end
30
47
  end
31
48
 
32
49
  def relay_response(response)
33
- puts response.headers.to_h
34
50
  status response.status
35
51
  response.body
36
52
  end
37
53
 
54
+ def request_uri
55
+ uri = URI("#{VCR::Proxy.config.endpoint}#{request.path}")
56
+ uri.query = URI.encode_www_form(request.params)
57
+ uri
58
+ end
59
+
38
60
  def request_headers
39
61
  @request_headers ||= env.select { |k, _v| k.start_with? 'HTTP_' }
40
- .collect { |key, val| [key.sub(/^HTTP_/, ''), val] }
41
- .collect { |key, val| "#{key}: #{val}<br>" }
42
- .sort
62
+ .transform_keys { |k| k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-') }
43
63
  end
44
64
 
45
65
  def vcr_wrapper(verb)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VCR
2
4
  module Proxy
3
- VERSION = "0.1.8"
5
+ VERSION = '0.1.9'
4
6
  end
5
7
  end
data/vcr-proxy.gemspec CHANGED
@@ -11,14 +11,15 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['ceritium@gmail.com']
12
12
 
13
13
  spec.summary = 'VCR web proxy'
14
- # spec.description = %q{}
15
- spec.homepage = "https://github.com/ceritium/vcr-proxy"
14
+ spec.description = 'Web proxy based on Sinatra and VCR to record and replay all the http requests, useful for end to end tests.
15
+ '
16
+ spec.homepage = 'https://github.com/ceritium/vcr-proxy'
16
17
 
17
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
20
  if spec.respond_to?(:metadata)
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = "https://github.com/ceritium/vcr-proxy"
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = 'https://github.com/ceritium/vcr-proxy'
22
23
  # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
23
24
  else
24
25
  raise 'RubyGems 2.0 or newer is required to protect against ' \
@@ -34,10 +35,12 @@ Gem::Specification.new do |spec|
34
35
  spec.executables << 'vcr-proxy'
35
36
  spec.require_paths = ['lib']
36
37
 
38
+ spec.add_dependency 'faraday'
37
39
  spec.add_dependency 'sinatra'
38
40
  spec.add_dependency 'vcr'
39
- spec.add_dependency 'faraday'
40
41
  spec.add_development_dependency 'bundler', '~> 2.0'
41
42
  spec.add_development_dependency 'minitest', '~> 5.0'
43
+ spec.add_development_dependency 'rack-test'
42
44
  spec.add_development_dependency 'rake', '~> 10.0'
45
+ spec.add_development_dependency 'webmock'
43
46
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Galisteo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sinatra
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: vcr
28
+ name: sinatra
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: faraday
42
+ name: vcr
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +108,24 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '10.0'
97
- description:
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: 'Web proxy based on Sinatra and VCR to record and replay all the http
126
+ requests, useful for end to end tests.
127
+
128
+ '
98
129
  email:
99
130
  - ceritium@gmail.com
100
131
  executables: