vcr 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +29 -2
  5. data/Gemfile +3 -3
  6. data/README.md +55 -11
  7. data/Rakefile +45 -4
  8. data/features/.nav +6 -0
  9. data/features/{README.md → about_the_cucumber_features.md} +1 -1
  10. data/features/cassettes/update_content_length_header.feature +106 -0
  11. data/features/configuration/default_cassette_options.feature +20 -2
  12. data/features/configuration/filter_sensitive_data.feature +154 -0
  13. data/features/getting_started.md +67 -0
  14. data/features/record_modes/all.feature +4 -2
  15. data/features/record_modes/new_episodes.feature +8 -2
  16. data/features/record_modes/none.feature +4 -2
  17. data/features/record_modes/once.feature +92 -0
  18. data/features/step_definitions/cli_steps.rb +18 -0
  19. data/lib/vcr.rb +13 -6
  20. data/lib/vcr/cassette.rb +36 -15
  21. data/lib/vcr/config.rb +14 -2
  22. data/lib/vcr/deprecations/cassette.rb +29 -0
  23. data/lib/vcr/deprecations/config.rb +18 -0
  24. data/lib/vcr/deprecations/http_stubbing_adapters/common.rb +9 -0
  25. data/lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb +11 -0
  26. data/lib/vcr/http_stubbing_adapters/common.rb +1 -1
  27. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +2 -7
  28. data/lib/vcr/http_stubbing_adapters/multi_object_proxy.rb +1 -1
  29. data/lib/vcr/middleware/common.rb +3 -5
  30. data/lib/vcr/rspec.rb +1 -38
  31. data/lib/vcr/structs/http_interaction.rb +29 -0
  32. data/lib/vcr/structs/request.rb +6 -0
  33. data/lib/vcr/structs/response.rb +4 -0
  34. data/lib/vcr/{cucumber_tags.rb → test_frameworks/cucumber.rb} +10 -2
  35. data/lib/vcr/test_frameworks/rspec.rb +37 -0
  36. data/lib/vcr/util/basic_object.rb +32 -28
  37. data/lib/vcr/{hooks.rb → util/hooks.rb} +3 -6
  38. data/lib/vcr/util/internet_connection.rb +1 -1
  39. data/lib/vcr/util/ping.rb +21 -17
  40. data/lib/vcr/util/variable_args_block_caller.rb +12 -0
  41. data/lib/vcr/util/yaml.rb +11 -0
  42. data/lib/vcr/version.rb +1 -1
  43. data/script/FullBuildRakeFile +7 -0
  44. data/spec/monkey_patches.rb +0 -7
  45. data/spec/spec_helper.rb +40 -8
  46. data/spec/support/http_library_adapters.rb +0 -262
  47. data/spec/support/shared_example_groups/http_library.rb +256 -0
  48. data/spec/support/{http_stubbing_adapter.rb → shared_example_groups/http_stubbing_adapter.rb} +15 -3
  49. data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +28 -0
  50. data/spec/support/{normalizers.rb → shared_example_groups/normalizers.rb} +3 -3
  51. data/spec/support/{version_checker.rb → shared_example_groups/version_checking.rb} +1 -1
  52. data/spec/vcr/cassette_spec.rb +80 -28
  53. data/spec/vcr/config_spec.rb +55 -8
  54. data/spec/vcr/deprecations/cassette_spec.rb +57 -0
  55. data/spec/vcr/deprecations/config_spec.rb +30 -0
  56. data/spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb +7 -0
  57. data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +16 -0
  58. data/spec/vcr/extensions/net_http_response_spec.rb +1 -3
  59. data/spec/vcr/extensions/net_http_spec.rb +1 -3
  60. data/spec/vcr/http_stubbing_adapters/fakeweb_spec.rb +1 -4
  61. data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +1 -4
  62. data/spec/vcr/http_stubbing_adapters/typhoeus_spec.rb +1 -4
  63. data/spec/vcr/http_stubbing_adapters/webmock_spec.rb +1 -3
  64. data/spec/vcr/middleware/faraday_spec.rb +4 -4
  65. data/spec/vcr/middleware/rack_spec.rb +4 -4
  66. data/spec/vcr/structs/http_interaction_spec.rb +61 -0
  67. data/spec/vcr/structs/request_spec.rb +20 -2
  68. data/spec/vcr/structs/response_spec.rb +23 -1
  69. data/spec/vcr/structs/response_status_spec.rb +1 -1
  70. data/spec/vcr/{cucumber_tags_spec.rb → test_frameworks/cucumber_spec.rb} +12 -8
  71. data/spec/vcr/{rspec_spec.rb → test_frameworks/rspec_spec.rb} +0 -0
  72. data/spec/vcr/{hooks_spec.rb → util/hooks_spec.rb} +3 -3
  73. data/spec/vcr/util/internet_connection_spec.rb +3 -3
  74. data/spec/vcr_spec.rb +3 -3
  75. data/vcr.gemspec +5 -5
  76. metadata +149 -131
  77. data/Gemfile.lock +0 -155
  78. data/lib/vcr/deprecations.rb +0 -54
  79. data/spec/support/disable_warnings.rb +0 -12
  80. data/spec/support/temp_cassette_library_dir.rb +0 -16
  81. data/spec/support/webmock_macros.rb +0 -14
  82. data/spec/vcr/deprecations_spec.rb +0 -139
@@ -1,155 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- vcr (1.6.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- addressable (2.2.2)
10
- archive-tar-minitar (0.5.2)
11
- aruba (0.2.4)
12
- background_process
13
- cucumber (~> 0.9.3)
14
- background_process (1.2)
15
- bouncy-castle-java (1.5.0145.2)
16
- builder (2.1.2)
17
- columnize (0.3.1)
18
- configuration (1.2.0)
19
- crack (0.1.8)
20
- cucumber (0.9.4)
21
- builder (~> 2.1.2)
22
- diff-lcs (~> 1.1.2)
23
- gherkin (~> 2.2.9)
24
- json (~> 1.4.6)
25
- term-ansicolor (~> 1.0.5)
26
- curb (0.7.8)
27
- diff-lcs (1.1.2)
28
- em-http-request (0.2.12)
29
- addressable (>= 2.0.0)
30
- eventmachine (>= 0.12.9)
31
- eventmachine (0.12.10)
32
- eventmachine (0.12.10-java)
33
- fakeweb (1.3.0)
34
- faraday (0.5.3)
35
- addressable (~> 2.2.2)
36
- multipart-post (~> 1.0.1)
37
- rack (>= 1.1.0, < 2)
38
- fuubar (0.0.3)
39
- rspec (~> 2.0)
40
- rspec-instafail (~> 0.1.4)
41
- ruby-progressbar (~> 0.0.9)
42
- gherkin (2.2.9)
43
- json (~> 1.4.6)
44
- term-ansicolor (~> 1.0.5)
45
- gherkin (2.2.9-java)
46
- json (~> 1.4.6)
47
- term-ansicolor (~> 1.0.5)
48
- growl (1.0.3)
49
- guard (0.2.2)
50
- open_gem (~> 1.4.2)
51
- thor (~> 0.14.3)
52
- guard-cucumber (0.2.1)
53
- cucumber (~> 0.9.4)
54
- guard (~> 0.2.2)
55
- guard-rspec (0.1.8)
56
- guard (>= 0.2.0)
57
- httpclient (2.1.5.2)
58
- jruby-openssl (0.7.2)
59
- bouncy-castle-java
60
- json (1.4.6)
61
- json (1.4.6-java)
62
- launchy (0.3.7)
63
- configuration (>= 0.0.5)
64
- rake (>= 0.8.1)
65
- linecache (0.43)
66
- linecache19 (0.5.11)
67
- ruby_core_source (>= 0.1.4)
68
- mime-types (1.16)
69
- multipart-post (1.0.1)
70
- open_gem (1.4.2)
71
- launchy (~> 0.3.5)
72
- patron (0.4.9)
73
- rack (1.1.0)
74
- rake (0.8.7)
75
- rb-fsevent (0.3.6)
76
- rcov (0.9.9)
77
- relish (0.2.0)
78
- archive-tar-minitar (~> 0.5.2)
79
- json (~> 1.4.6)
80
- rest-client (~> 1.6.1)
81
- rest-client (1.6.1)
82
- mime-types (>= 1.16)
83
- rspec (2.4.0)
84
- rspec-core (~> 2.4.0)
85
- rspec-expectations (~> 2.4.0)
86
- rspec-mocks (~> 2.4.0)
87
- rspec-core (2.4.0)
88
- rspec-expectations (2.4.0)
89
- diff-lcs (~> 1.1.2)
90
- rspec-instafail (0.1.5)
91
- rspec-mocks (2.4.0)
92
- ruby-debug (0.10.3)
93
- columnize (>= 0.1)
94
- ruby-debug-base (~> 0.10.3.0)
95
- ruby-debug-base (0.10.3)
96
- linecache (>= 0.3)
97
- ruby-debug-base19 (0.11.23)
98
- columnize (>= 0.3.1)
99
- linecache19 (>= 0.5.11)
100
- ruby_core_source (>= 0.1.4)
101
- ruby-debug19 (0.11.6)
102
- columnize (>= 0.3.1)
103
- linecache19 (>= 0.5.11)
104
- ruby-debug-base19 (>= 0.11.19)
105
- ruby-progressbar (0.0.9)
106
- ruby_core_source (0.1.4)
107
- archive-tar-minitar (>= 0.5.2)
108
- shoulda (2.9.2)
109
- sinatra (1.1.0)
110
- rack (~> 1.1)
111
- tilt (~> 1.1)
112
- term-ansicolor (1.0.5)
113
- thor (0.14.6)
114
- tilt (1.1)
115
- timecop (0.3.5)
116
- typhoeus (0.2.1)
117
- mime-types
118
- webmock (1.6.2)
119
- addressable (>= 2.2.2)
120
- crack (>= 0.1.7)
121
-
122
- PLATFORMS
123
- java
124
- ruby
125
-
126
- DEPENDENCIES
127
- aruba (~> 0.2.1)
128
- bundler (~> 1.0.7)
129
- cucumber (~> 0.9.4)
130
- curb (~> 0.7.8)
131
- em-http-request (~> 0.2.7)
132
- fakeweb (~> 1.3.0)
133
- faraday (~> 0.5.3)
134
- fuubar
135
- growl
136
- guard-cucumber
137
- guard-rspec
138
- httpclient (~> 2.1.5.2)
139
- jruby-openssl
140
- patron (~> 0.4.6)
141
- rack (= 1.1.0)
142
- rake (~> 0.8.7)
143
- rb-fsevent
144
- rcov
145
- relish
146
- rspec (~> 2.4.0)
147
- ruby-debug
148
- ruby-debug-base19 (= 0.11.23)
149
- ruby-debug19
150
- shoulda (~> 2.9.2)
151
- sinatra (~> 1.1.0)
152
- timecop (~> 0.3.5)
153
- typhoeus (~> 0.2.1)
154
- vcr!
155
- webmock (~> 1.6.0)
@@ -1,54 +0,0 @@
1
- module VCR
2
- module HttpStubbingAdapters
3
- module Common
4
- def ignore_localhost?
5
- VCR::Config.ignore_localhost?
6
- end
7
- end
8
- end
9
-
10
- module Config
11
- def http_stubbing_library
12
- warn "WARNING: `VCR::Config.http_stubbing_library` is deprecated. Use `VCR::Config.http_stubbing_libraries` instead."
13
- @http_stubbing_libraries && @http_stubbing_libraries.first
14
- end
15
-
16
- def http_stubbing_library=(library)
17
- warn "WARNING: `VCR::Config.http_stubbing_library = #{library.inspect}` is deprecated. Use `VCR::Config.stub_with #{library.inspect}` instead."
18
- stub_with library
19
- end
20
-
21
- def ignore_localhost?
22
- warn "WARNING: `VCR::Config.ignore_localhost?` is deprecated. Check the list of ignored hosts using `VCR::Config.ignored_hosts` instead."
23
- (VCR::LOCALHOST_ALIASES - ignored_hosts).empty?
24
- end
25
- end
26
-
27
- class Cassette
28
- def allow_real_http_requests_to?(uri)
29
- warn "WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used."
30
- VCR::Config.uri_should_be_ignored?(uri.to_s)
31
- end
32
-
33
- private
34
-
35
- def deprecate_old_cassette_options(options)
36
- message = "VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option."
37
- if options[:allow_real_http] == :localhost
38
- @original_ignored_hosts = VCR::Config.ignored_hosts.dup
39
- VCR::Config.ignored_hosts.clear
40
- VCR::Config.ignore_hosts *VCR::LOCALHOST_ALIASES
41
- Kernel.warn "WARNING: #{message}"
42
- elsif options[:allow_real_http]
43
- raise ArgumentError.new(message)
44
- end
45
- end
46
-
47
- def restore_ignore_localhost_for_deprecation
48
- if defined?(@original_ignored_hosts)
49
- VCR::Config.ignored_hosts.clear
50
- VCR::Config.ignore_hosts *@original_ignored_hosts
51
- end
52
- end
53
- end
54
- end
@@ -1,12 +0,0 @@
1
- module DisableWarnings
2
- def disable_warnings
3
- before(:all) do
4
- @orig_std_err = $stderr
5
- $stderr = StringIO.new
6
- end
7
-
8
- after(:all) do
9
- $stderr = @orig_std_err
10
- end
11
- end
12
- end
@@ -1,16 +0,0 @@
1
- module TempCassetteLibraryDir
2
- def temp_dir(dir, options = {})
3
- before(:each) do
4
- @temp_dir = dir
5
- @dir_remover = lambda { FileUtils.rm_rf(@temp_dir) if File.exist?(@temp_dir) }
6
- @dir_remover.call
7
- if options[:assign_to_cassette_library_dir]
8
- VCR::Config.cassette_library_dir = @temp_dir
9
- end
10
- end
11
-
12
- after(:each) do
13
- @dir_remover.call
14
- end
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- module WebMockMacros
2
- def without_webmock_callbacks
3
- before(:all) do
4
- @original_webmock_callbacks = ::WebMock::CallbackRegistry.callbacks
5
- ::WebMock::CallbackRegistry.reset
6
- end
7
-
8
- after(:all) do
9
- @original_webmock_callbacks.each do |cb|
10
- ::WebMock::CallbackRegistry.add_callback(cb[:options], cb[:block])
11
- end
12
- end
13
- end
14
- end
@@ -1,139 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for '.ignore_localhost? deprecation' do
4
- it 'returns false when no hosts are ignored' do
5
- VCR::Config.ignored_hosts.should be_empty
6
- described_class.ignore_localhost?.should be_false
7
- end
8
-
9
- it 'returns false when only non-local hosts are ignored' do
10
- VCR::Config.ignore_hosts 'example.com'
11
- described_class.ignore_localhost?.should be_false
12
- end
13
-
14
- it 'returns false when only some localhost aliases are ignored' do
15
- aliases = VCR::LOCALHOST_ALIASES.dup
16
- aliases.pop
17
- VCR::Config.ignore_hosts *aliases
18
- described_class.ignore_localhost?.should be_false
19
- end
20
-
21
- it 'returns true when all localhost aliases are ignored, even if some other hosts are ignored, too' do
22
- VCR::Config.ignore_hosts 'example.com', *VCR::LOCALHOST_ALIASES
23
- described_class.ignore_localhost?.should be_true
24
- end
25
-
26
- it 'prints a warning: WARNING: `VCR::Config.ignore_localhost?` is deprecated. Check the list of ignored hosts using `VCR::Config.ignored_hosts` instead.' do
27
- VCR::Config.should_receive(:warn).with(/Check the list of ignored hosts using `VCR::Config.ignored_hosts` instead/)
28
- described_class.ignore_localhost?
29
- end
30
- end
31
-
32
- describe 'Deprecations' do
33
- disable_warnings
34
-
35
- VCR::HttpStubbingAdapters::Common.adapters.each do |adapter|
36
- describe adapter do
37
- it_behaves_like '.ignore_localhost? deprecation'
38
- end
39
- end
40
-
41
- describe VCR::HttpStubbingAdapters::FakeWeb do
42
- describe 'LOCALHOST_REGEX constant' do
43
- subject { described_class::LOCALHOST_REGEX }
44
-
45
- it 'refers to the expected regex' do
46
- should == %r|\Ahttps?://((\w+:)?\w+@)?(#{VCR::LOCALHOST_ALIASES.sort.map { |a| Regexp.escape(a) }.join('|')})(:\d+)?/|i
47
- end
48
-
49
- it 'prints a warning: WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.' do
50
- described_class.should_receive(:warn).with("WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.")
51
- subject
52
- end
53
- end
54
- end
55
-
56
- describe VCR::Config do
57
- describe '.http_stubbing_library' do
58
- before(:each) { described_class.stub_with :webmock, :typhoeus }
59
-
60
- it 'returns the first configured stubbing library' do
61
- described_class.http_stubbing_library.should == :webmock
62
- end
63
-
64
- it 'prints a warning: WARNING: VCR::Config.http_stubbing_library is deprecated. Use VCR::Config.http_stubbing_libraries instead' do
65
- described_class.should_receive(:warn).with("WARNING: `VCR::Config.http_stubbing_library` is deprecated. Use `VCR::Config.http_stubbing_libraries` instead.")
66
- described_class.http_stubbing_library
67
- end
68
- end
69
-
70
- describe '.http_stubbing_library=' do
71
- it 'sets http_stubbing_libraries to an array of the given value' do
72
- described_class.http_stubbing_library = :webmock
73
- described_class.http_stubbing_libraries.should == [:webmock]
74
- end
75
-
76
- it 'prints a warning: WARNING: VCR::Config.http_stubbing_library= is deprecated. Use VCR::Config.stub_with instead' do
77
- described_class.should_receive(:warn).with("WARNING: `VCR::Config.http_stubbing_library = :webmock` is deprecated. Use `VCR::Config.stub_with :webmock` instead.")
78
- described_class.http_stubbing_library = :webmock
79
- end
80
- end
81
-
82
- it_behaves_like '.ignore_localhost? deprecation'
83
- end
84
-
85
- describe VCR::Cassette do
86
- subject { VCR::Cassette.new('cassette name') }
87
-
88
- it 'raises an error when an :allow_real_http lambda is given' do
89
- expect { VCR::Cassette.new('cassette name', :allow_real_http => lambda {}) }.to raise_error(ArgumentError)
90
- end
91
-
92
- it "prints a warning: WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used" do
93
- subject.should_receive(:warn).with("WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used.")
94
- subject.allow_real_http_requests_to?(URI.parse('http://example.org'))
95
- end
96
-
97
- [true, false].each do |orig_ignore_localhost|
98
- orig_ignored_hosts = if orig_ignore_localhost
99
- VCR::LOCALHOST_ALIASES
100
- else
101
- []
102
- end
103
-
104
- context "when the ignored_hosts list is set to #{orig_ignored_hosts.inspect} and the :allow_real_http option is set to :localhost" do
105
- before(:each) do
106
- VCR::Config.ignored_hosts.clear
107
- VCR::Config.ignore_hosts *orig_ignored_hosts
108
- end
109
-
110
- subject { VCR::Cassette.new('cassette name', :allow_real_http => :localhost) }
111
-
112
- it "sets the ignored_hosts list to the list of localhost aliases" do
113
- subject
114
- VCR::Config.ignored_hosts.should == VCR::LOCALHOST_ALIASES
115
- end
116
-
117
- it "prints a warning: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option." do
118
- Kernel.should_receive(:warn).with("WARNING: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option.")
119
- subject
120
- end
121
-
122
- it "reverts ignore_hosts when the cassette is ejected" do
123
- subject.eject
124
- VCR::Config.ignored_hosts.should == orig_ignored_hosts
125
- end
126
-
127
- {
128
- 'http://localhost' => true,
129
- 'http://127.0.0.1' => true,
130
- 'http://example.com' => false
131
- }.each do |url, expected_value|
132
- it "returns #{expected_value} for #allow_real_http_requests_to? when it is given #{url}" do
133
- subject.allow_real_http_requests_to?(URI.parse(url)).should == expected_value
134
- end
135
- end
136
- end
137
- end
138
- end
139
- end