vcr 2.2.5 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +5 -0
  2. data/.travis.yml +0 -5
  3. data/Appraisals +9 -0
  4. data/CHANGELOG.md +21 -0
  5. data/Gemfile +17 -21
  6. data/README.md +5 -2
  7. data/Rakefile +1 -0
  8. data/features/configuration/hook_into.feature +7 -6
  9. data/features/configuration/uri_parser.feature +91 -0
  10. data/features/middleware/faraday.feature +4 -3
  11. data/features/support/http_lib_filters.rb +2 -3
  12. data/features/support/vcr_cucumber_helpers.rb +2 -1
  13. data/features/test_frameworks/cucumber.feature +6 -0
  14. data/gemfiles/typhoeus-new.gemfile +18 -0
  15. data/gemfiles/typhoeus-new.gemfile.lock +172 -0
  16. data/gemfiles/typhoeus-old.gemfile +18 -0
  17. data/gemfiles/typhoeus-old.gemfile.lock +159 -0
  18. data/lib/vcr/cassette/migrator.rb +1 -1
  19. data/lib/vcr/configuration.rb +28 -0
  20. data/lib/vcr/errors.rb +1 -1
  21. data/lib/vcr/library_hooks/typhoeus.rb +74 -77
  22. data/lib/vcr/library_hooks/typhoeus_0.4.rb +99 -0
  23. data/lib/vcr/middleware/faraday.rb +1 -1
  24. data/lib/vcr/request_ignorer.rb +2 -2
  25. data/lib/vcr/request_matcher_registry.rb +8 -3
  26. data/lib/vcr/structs.rb +8 -1
  27. data/lib/vcr/test_frameworks/cucumber.rb +1 -1
  28. data/lib/vcr/version.rb +1 -1
  29. data/script/ci.sh +8 -1
  30. data/spec/capture_warnings.rb +10 -0
  31. data/spec/monkey_patches.rb +21 -3
  32. data/spec/spec_helper.rb +2 -0
  33. data/spec/support/http_library_adapters.rb +29 -0
  34. data/spec/support/limited_uri.rb +30 -0
  35. data/spec/support/vcr_localhost_server.rb +1 -4
  36. data/spec/vcr/cassette/http_interaction_list_spec.rb +0 -1
  37. data/spec/vcr/configuration_spec.rb +15 -1
  38. data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +31 -0
  39. data/spec/vcr/library_hooks/typhoeus_spec.rb +6 -6
  40. data/spec/vcr/library_hooks/webmock_spec.rb +3 -1
  41. data/spec/vcr/middleware/faraday_spec.rb +3 -1
  42. data/spec/vcr/request_matcher_registry_spec.rb +3 -1
  43. data/spec/vcr/structs_spec.rb +27 -1
  44. data/spec/vcr/test_frameworks/cucumber_spec.rb +1 -1
  45. metadata +41 -29
data/.gitignore CHANGED
@@ -36,6 +36,11 @@ features/LICENSE.md
36
36
  features/Upgrade.md
37
37
  features/CONTRIBUTING.md
38
38
 
39
+ ## PROJECT::TOOLS
40
+
39
41
  .rvmrc
40
42
  .yardoc
41
43
  doc
44
+
45
+ ## PROJECT::EDITORS
46
+ .idea/
@@ -12,11 +12,6 @@ rvm:
12
12
  - jruby-19mode
13
13
  - rbx-18mode
14
14
  - rbx-19mode
15
- branches:
16
- only:
17
- - master
18
- - 1-x-stable
19
- - travis-testing
20
15
  matrix:
21
16
  allow_failures:
22
17
  - rvm: jruby-18mode
@@ -0,0 +1,9 @@
1
+ appraise "typhoeus-new" do
2
+ gem 'typhoeus', :git => "https://github.com/typhoeus/typhoeus.git"
3
+ end
4
+
5
+ appraise "typhoeus-old" do
6
+ gem 'typhoeus', '~> 0.4.2'
7
+ gem 'webmock', '1.8.11'
8
+ end
9
+
@@ -1,3 +1,24 @@
1
+ ## 2.3.0 (October 29, 2012)
2
+
3
+ [Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.5...v2.3.0)
4
+
5
+ Enhancements:
6
+
7
+ * Add `uri_parser` configuration option. It defaults to `URI` but can
8
+ be set to something like `Addressable::URI` to handle non-standard
9
+ URIs that stdlib `URI` doesn't handle. Thanks to [Ryan
10
+ Burrows](https://github.com/rhburrows) for contributing this feature.
11
+ * Add support for Typhoeus 0.5. Thanks to [Hans
12
+ Hasselberg](https://github.com/i0rek) for making the needed changes.
13
+
14
+ Bug Fixes:
15
+
16
+ * Fix `:use_scenario_name` cucumber tag option so that it only uses the
17
+ first line of the scenario name. Scenarios can include a long preamble
18
+ that Cucumber includes as part of the scenario name. Thanks to
19
+ [Pascal Van Hecke](https://github.com/pascalvanhecke) for providing
20
+ this fix.
21
+
1
22
  ## 2.2.5 (September 7, 2012)
2
23
 
3
24
  [Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.4...v2.2.5)
data/Gemfile CHANGED
@@ -1,29 +1,25 @@
1
1
  source :rubygems
2
+
3
+ gem 'appraisal'
4
+
5
+ gem 'typhoeus', :git => "https://github.com/typhoeus/typhoeus.git"
6
+ gem 'webmock', :git => "https://github.com/i0rek/webmock.git", :branch => "typhoeus_0.5.0"
7
+
2
8
  gemspec
3
9
 
4
- group :development do
5
- platforms :jruby do
6
- gem 'jruby-openssl'
7
- end
8
- end
10
+ gem 'jruby-openssl', :platforms => :jruby
9
11
 
10
12
  gem 'yard'
11
13
 
12
14
  # Additional gems that are useful, but not required for development.
13
- group :extras do
14
- gem 'relish', '~> 0.6'
15
- gem 'fuubar'
16
- gem 'fuubar-cucumber'
17
-
18
- gem 'redcarpet', '~> 1.17.2'
19
- gem 'github-markup'
20
-
21
- platforms :mri_18, :jruby do
22
- gem 'ruby-debug'
23
- end
24
-
25
- platforms :mri_19 do
26
- gem 'ruby-debug19'
27
- end unless RUBY_VERSION == '1.9.3'
28
- end
15
+ gem 'relish', '~> 0.6'
16
+ gem 'fuubar'
17
+ gem 'fuubar-cucumber'
18
+
19
+ gem 'redcarpet', '~> 1.17.2'
20
+ gem 'github-markup'
21
+
22
+ gem 'ruby-debug', :platforms => [:mri_18, :jruby]
23
+
24
+ gem 'debugger', :platforms => :mri_19
29
25
 
data/README.md CHANGED
@@ -128,8 +128,8 @@ yard server --reload
128
128
  * [Chris Kampmeier](http://github.com/chrisk) for [FakeWeb](http://github.com/chrisk/fakeweb).
129
129
  * [Chris Young](http://github.com/chrisyoung) for [NetRecorder](http://github.com/chrisyoung/netrecorder),
130
130
  the inspiration for VCR.
131
- * [David Balatero](https://github.com/dbalatero) for help with [Typhoeus](https://github.com/typhoeus/typhoeus)
132
- support.
131
+ * [David Balatero](https://github.com/dbalatero) and [Hans Hasselberg](https://github.com/i0rek)
132
+ for help with [Typhoeus](https://github.com/typhoeus/typhoeus) support.
133
133
  * [Wesley Beary](https://github.com/geemus) for help with [Excon](https://github.com/geemus/excon)
134
134
  support.
135
135
  * [Jacob Green](https://github.com/Jacobkg) for help with ongoing VCR
@@ -150,6 +150,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
150
150
  * [Ezekiel Templin](https://github.com/ezkl)
151
151
  * [Flaviu Simihaian](https://github.com/closedbracket)
152
152
  * [Gordon Wilson](https://github.com/gordoncww)
153
+ * [Hans Hasselberg](https://github.com/i0rek)
153
154
  * [Ingemar](https://github.com/ingemar)
154
155
  * [Jacob Green](https://github.com/Jacobkg)
155
156
  * [Jeff Pollard](https://github.com/Fluxx)
@@ -157,6 +158,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
157
158
  * [Jonathan Tron](https://github.com/JonathanTron)
158
159
  * [Justin Smestad](https://github.com/jsmestad)
159
160
  * [Karl Baum](https://github.com/kbaum)
161
+ * [Mark Burns](https://github.com/markburns)
160
162
  * [Michael Lavrisha](https://github.com/vrish88)
161
163
  * [Mislav Marohnić](https://github.com/mislav)
162
164
  * [Nathaniel Bibler](https://github.com/nbibler)
@@ -165,6 +167,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
165
167
  * [Paco Guzmán](https://github.com/pacoguzman)
166
168
  * [playupchris](https://github.com/playupchris)
167
169
  * [Ryan Bates](https://github.com/ryanb)
170
+ * [Ryan Burrows](https://github.com/rhburrows)
168
171
  * [Sathya Sekaran](https://github.com/sfsekaran)
169
172
  * [Steven Anderson](https://github.com/bendycode)
170
173
  * [Tyler Hunt](https://github.com/tylerhunt)
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ if using_git
4
4
  require 'bundler'
5
5
  require 'bundler/setup'
6
6
  Bundler::GemHelper.install_tasks
7
+ require 'appraisal'
7
8
  end
8
9
 
9
10
  require 'rake'
@@ -88,7 +88,7 @@ Feature: hook_into
88
88
  | c.hook_into :faraday | faraday (w/ net_http) |
89
89
  | c.hook_into :faraday | faraday (w/ typhoeus) |
90
90
 
91
- @exclude-jruby
91
+ @exclude-jruby @exclude-18
92
92
  Scenario Outline: Use Typhoeus, Excon and Faraday in combination with FakeWeb or WebMock
93
93
  Given a file named "hook_into_multiple.rb" with:
94
94
  """ruby
@@ -96,6 +96,7 @@ Feature: hook_into
96
96
  require 'excon'
97
97
  require 'faraday'
98
98
  require 'vcr'
99
+ <extra_require>
99
100
 
100
101
  VCR.configure { |c| c.ignore_localhost = true }
101
102
 
@@ -167,8 +168,8 @@ Feature: hook_into
167
168
  | Faraday 2: Hello faraday |
168
169
 
169
170
  Examples:
170
- | hook_into | faraday_adapter |
171
- | :fakeweb | net_http |
172
- | :webmock | net_http |
173
- | :fakeweb | typhoeus |
174
- | :webmock | typhoeus |
171
+ | hook_into | faraday_adapter | extra_require |
172
+ | :fakeweb | net_http | |
173
+ | :webmock | net_http | |
174
+ | :fakeweb | typhoeus | require 'typhoeus/adapters/faraday' |
175
+ | :webmock | typhoeus | require 'typhoeus/adapters/faraday' |
@@ -0,0 +1,91 @@
1
+ Feature: uri_parser
2
+
3
+ By default, VCR will parse URIs using `URI` from the Ruby standard
4
+ library. There are some URIs seen out in the wild that `URI` cannot
5
+ parse properly. You can set the `uri_parser` configuration option
6
+ to use a different parser (such as `Addressable::URI`) to work with
7
+ these URIs.
8
+
9
+ The configured URI parser needs to expose a `.parse` class method
10
+ that returns an instance of the uri. This uri instance needs to
11
+ implement the folllowing API:
12
+
13
+ * `#scheme` => a string
14
+ * `#host` => a string
15
+ * `#port` => a fixnum
16
+ * `#path` => a string
17
+ * `#query` => a string
18
+ * `#to_s` => a string
19
+ * `#port=`
20
+ * `#query=`
21
+ * `#==` => boolean
22
+
23
+ Background:
24
+ Given a file named "cassettes/example.yml" with:
25
+ """
26
+ ---
27
+ http_interactions:
28
+ - request:
29
+ method: get
30
+ uri: http://bad_url.example.com/
31
+ body:
32
+ encoding: UTF-8
33
+ string: ""
34
+ headers: {}
35
+ response:
36
+ status:
37
+ code: 200
38
+ message: OK
39
+ headers:
40
+ Content-Length:
41
+ - "5"
42
+ body:
43
+ encoding: UTF-8
44
+ string: Hello
45
+ http_version: "1.1"
46
+ recorded_at: Tue, 25 Sep 2012 04:58:44 GMT
47
+ recorded_with: VCR 2.2.5
48
+ """
49
+
50
+ Scenario: the VCR uri parser gets its value from `uri_parser`
51
+ Given a file named "uri_parser.rb" with:
52
+ """ruby
53
+ require 'vcr'
54
+ require 'addressable/uri'
55
+
56
+ VCR.configure do |c|
57
+ c.uri_parser = Addressable::URI
58
+ c.hook_into :webmock
59
+ c.cassette_library_dir = 'cassettes'
60
+ end
61
+
62
+ uri = Addressable::URI.parse('http://bad_url.example.com')
63
+ VCR.use_cassette('example') do
64
+ puts Net::HTTP.get_response(uri).body
65
+ end
66
+ """
67
+ When I run `ruby uri_parser.rb`
68
+ Then it should pass with "Hello"
69
+
70
+ Scenario: the `uri_parser` defaults to the standard library's `URI`
71
+ Given a file named "uri_parser_default.rb" with:
72
+ """ruby
73
+ require 'vcr'
74
+ require 'addressable/uri'
75
+
76
+ VCR.configure do |c|
77
+ c.hook_into :webmock
78
+ c.cassette_library_dir = 'cassettes'
79
+ end
80
+
81
+ uri = Addressable::URI.parse('http://bad_url.example.com')
82
+ VCR.use_cassette('example') do
83
+ puts Net::HTTP.get_response(uri).body
84
+ end
85
+ """
86
+ When I run `ruby uri_parser_default.rb`
87
+ Then it should fail with an error like:
88
+ """
89
+ URI::InvalidURIError
90
+ """
91
+
@@ -21,6 +21,7 @@ Feature: Faraday middleware
21
21
 
22
22
  require 'faraday'
23
23
  require 'vcr'
24
+ <extra_require>
24
25
 
25
26
  VCR.configure do |c|
26
27
  c.default_cassette_options = { :serialize_with => :syck }
@@ -49,7 +50,7 @@ Feature: Faraday middleware
49
50
  And the file "cassettes/example.yml" should contain "Hello foo 1"
50
51
 
51
52
  Examples:
52
- | adapter |
53
- | net_http |
54
- | typhoeus |
53
+ | adapter | extra_require |
54
+ | net_http | |
55
+ | typhoeus | require 'typhoeus/adapters/faraday' |
55
56
 
@@ -5,9 +5,8 @@ Cucumber::Ast::OutlineTable::ExampleRow.class_eval do
5
5
  end
6
6
  end
7
7
 
8
- if RUBY_VERSION == '1.9.2'
9
- # For some reason, the local sinatra server locks up and never exits
10
- # when using patron on 1.9.2, even though it exits fine during the specs.
8
+ if RUBY_VERSION == '1.8.7'
9
+ # We get timeouts on 1.8.7 w/ Patron for some reason.
11
10
  UNSUPPORTED_HTTP_LIBS = %w[ patron ]
12
11
  elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
13
12
  # Patron is freezing up the cukes (as it does on 1.9.2)
@@ -23,8 +23,9 @@ if ENV['DATE_STRING']
23
23
  end
24
24
 
25
25
  def include_http_adapter_for(lib)
26
- require 'support/http_library_adapters'
27
26
  require (lib =~ /faraday/ ? 'faraday' : lib)
27
+ require 'typhoeus' if lib.include?('typhoeus') # for faraday-typhoeus
28
+ require 'support/http_library_adapters'
28
29
  include HTTP_LIBRARY_ADAPTERS[lib]
29
30
  end
30
31
 
@@ -92,6 +92,12 @@ Feature: Usage with Cucumber
92
92
 
93
93
  @vcr
94
94
  Scenario: tagged scenario
95
+
96
+ Note: Like the feature pre-amble, Cucumber treats the scenario pre-amble
97
+ as part of the scenario name. When using the :use_scenario_name option,
98
+ VCR will only use the first line of the feature name as the directory
99
+ for the cassette.
100
+
95
101
  When a request is made to "http://localhost:7777/localhost_request_1"
96
102
  Then the response should be "Hello localhost_request_1"
97
103
 
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "appraisal"
6
+ gem "webmock", :git=>"https://github.com/i0rek/webmock.git", :branch=>"typhoeus_0.5.0"
7
+ gem "jruby-openssl", :platforms=>:jruby
8
+ gem "yard"
9
+ gem "relish", "~> 0.6"
10
+ gem "fuubar"
11
+ gem "fuubar-cucumber"
12
+ gem "redcarpet", "~> 1.17.2"
13
+ gem "github-markup"
14
+ gem "ruby-debug", :platforms=>[:mri_18, :jruby]
15
+ gem "debugger", :platforms=>:mri_19
16
+ gem "typhoeus", :git=>"https://github.com/typhoeus/typhoeus.git"
17
+
18
+ gemspec :path=>"../"
@@ -0,0 +1,172 @@
1
+ GIT
2
+ remote: https://github.com/i0rek/webmock.git
3
+ revision: aeac5cc6a1ac7a313c138514d66cd536802b9dc4
4
+ branch: typhoeus_0.5.0
5
+ specs:
6
+ webmock (1.8.9)
7
+ addressable (>= 2.2.7)
8
+ crack (>= 0.1.7)
9
+
10
+ GIT
11
+ remote: https://github.com/typhoeus/typhoeus.git
12
+ revision: 6f4e9079ade2f90c20341dddd022ab1d153400ec
13
+ specs:
14
+ typhoeus (0.5.0.rc)
15
+ ethon (= 0.5.1)
16
+
17
+ PATH
18
+ remote: /Users/myron/code/vcr
19
+ specs:
20
+ vcr (2.2.5)
21
+
22
+ GEM
23
+ remote: http://rubygems.org/
24
+ specs:
25
+ addressable (2.3.2)
26
+ appraisal (0.4.1)
27
+ bundler
28
+ rake
29
+ archive-tar-minitar (0.5.2)
30
+ aruba (0.4.11)
31
+ childprocess (>= 0.2.3)
32
+ cucumber (>= 1.1.1)
33
+ ffi (>= 1.0.11)
34
+ rspec (>= 2.7.0)
35
+ builder (3.1.4)
36
+ childprocess (0.3.6)
37
+ ffi (~> 1.0, >= 1.0.6)
38
+ columnize (0.3.6)
39
+ cookiejar (0.3.0)
40
+ crack (0.3.1)
41
+ cucumber (1.1.9)
42
+ builder (>= 2.1.2)
43
+ diff-lcs (>= 1.1.2)
44
+ gherkin (~> 2.9.0)
45
+ json (>= 1.4.6)
46
+ term-ansicolor (>= 1.0.6)
47
+ curb (0.8.1)
48
+ debugger (1.2.1)
49
+ columnize (>= 0.3.1)
50
+ debugger-linecache (~> 1.1.1)
51
+ debugger-ruby_core_source (~> 1.1.4)
52
+ debugger-linecache (1.1.2)
53
+ debugger-ruby_core_source (>= 1.1.1)
54
+ debugger-ruby_core_source (1.1.4)
55
+ diff-lcs (1.1.3)
56
+ em-http-request (1.0.3)
57
+ addressable (>= 2.2.3)
58
+ cookiejar
59
+ em-socksify
60
+ eventmachine (>= 1.0.0.beta.4)
61
+ http_parser.rb (>= 0.5.3)
62
+ em-socksify (0.2.1)
63
+ eventmachine (>= 1.0.0.beta.4)
64
+ ethon (0.5.1)
65
+ ffi (~> 1.0.11)
66
+ mime-types (~> 1.18)
67
+ eventmachine (1.0.0)
68
+ excon (0.16.7)
69
+ fakeweb (1.3.0)
70
+ faraday (0.8.4)
71
+ multipart-post (~> 1.1)
72
+ ffi (1.0.11)
73
+ fuubar (1.0.0)
74
+ rspec (~> 2.0)
75
+ rspec-instafail (~> 0.2.0)
76
+ ruby-progressbar (~> 0.0.10)
77
+ fuubar-cucumber (0.0.15)
78
+ cucumber (>= 1.0.2)
79
+ ruby-progressbar (~> 0.0.10)
80
+ gherkin (2.9.3)
81
+ json (>= 1.4.6)
82
+ github-markup (0.7.4)
83
+ http_parser.rb (0.5.3)
84
+ httpclient (2.3.0.1)
85
+ json (1.6.7)
86
+ linecache (0.46)
87
+ rbx-require-relative (> 0.0.4)
88
+ mime-types (1.19)
89
+ multi_json (1.0.4)
90
+ multipart-post (1.1.5)
91
+ patron (0.4.18)
92
+ rack (1.3.6)
93
+ rack-protection (1.2.0)
94
+ rack
95
+ rake (0.9.2.2)
96
+ rbx-require-relative (0.0.9)
97
+ redcarpet (1.17.2)
98
+ redis (2.2.2)
99
+ relish (0.6)
100
+ archive-tar-minitar (>= 0.5.2)
101
+ json (>= 1.4.6)
102
+ rest-client (>= 1.6.1)
103
+ rest-client (1.6.7)
104
+ mime-types (>= 1.16)
105
+ rspec (2.11.0)
106
+ rspec-core (~> 2.11.0)
107
+ rspec-expectations (~> 2.11.0)
108
+ rspec-mocks (~> 2.11.0)
109
+ rspec-core (2.11.1)
110
+ rspec-expectations (2.11.3)
111
+ diff-lcs (~> 1.1.3)
112
+ rspec-instafail (0.2.4)
113
+ rspec-mocks (2.11.3)
114
+ ruby-debug (0.10.4)
115
+ columnize (>= 0.1)
116
+ ruby-debug-base (~> 0.10.4.0)
117
+ ruby-debug-base (0.10.4)
118
+ linecache (>= 0.3)
119
+ ruby-progressbar (0.0.10)
120
+ shoulda (2.9.2)
121
+ simplecov (0.5.4)
122
+ multi_json (~> 1.0.3)
123
+ simplecov-html (~> 0.5.3)
124
+ simplecov-html (0.5.3)
125
+ sinatra (1.3.3)
126
+ rack (~> 1.3, >= 1.3.6)
127
+ rack-protection (~> 1.2)
128
+ tilt (~> 1.3, >= 1.3.3)
129
+ term-ansicolor (1.0.7)
130
+ tilt (1.3.3)
131
+ timecop (0.3.5)
132
+ yajl-ruby (1.1.0)
133
+ yard (0.8.3)
134
+
135
+ PLATFORMS
136
+ ruby
137
+
138
+ DEPENDENCIES
139
+ appraisal
140
+ aruba (~> 0.4.11)
141
+ bundler (>= 1.0.7)
142
+ cucumber (~> 1.1.4)
143
+ curb (~> 0.8.0)
144
+ debugger
145
+ em-http-request (~> 1.0.2)
146
+ excon (>= 0.11.0, < 1.0)
147
+ fakeweb (~> 1.3.0)
148
+ faraday (~> 0.8)
149
+ fuubar
150
+ fuubar-cucumber
151
+ github-markup
152
+ httpclient (~> 2.2)
153
+ jruby-openssl
154
+ json (~> 1.6.5)
155
+ multi_json (~> 1.0.3)
156
+ patron (~> 0.4.15)
157
+ rack (~> 1.3.6)
158
+ rake (~> 0.9.2)
159
+ redcarpet (~> 1.17.2)
160
+ redis (~> 2.2.2)
161
+ relish (~> 0.6)
162
+ rspec (~> 2.11)
163
+ ruby-debug
164
+ shoulda (~> 2.9.2)
165
+ simplecov (~> 0.5.3)
166
+ sinatra (~> 1.3.2)
167
+ timecop (~> 0.3.5)
168
+ typhoeus!
169
+ vcr!
170
+ webmock!
171
+ yajl-ruby (~> 1.1.0)
172
+ yard