vcr 3.0.3 → 6.2.0

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.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/vcr/cassette/erb_renderer.rb +4 -2
  3. data/lib/vcr/cassette/http_interaction_list.rb +14 -9
  4. data/lib/vcr/cassette/migrator.rb +5 -6
  5. data/lib/vcr/cassette/persisters/file_system.rb +9 -1
  6. data/lib/vcr/cassette/serializers/compressed.rb +2 -2
  7. data/lib/vcr/cassette/serializers/json.rb +14 -8
  8. data/lib/vcr/cassette/serializers/psych.rb +10 -2
  9. data/lib/vcr/cassette/serializers/syck.rb +7 -1
  10. data/lib/vcr/cassette/serializers/yaml.rb +14 -2
  11. data/lib/vcr/cassette/serializers.rb +10 -0
  12. data/lib/vcr/cassette.rb +63 -16
  13. data/lib/vcr/configuration.rb +21 -8
  14. data/lib/vcr/deprecations.rb +0 -62
  15. data/lib/vcr/errors.rb +17 -12
  16. data/lib/vcr/library_hooks/excon.rb +8 -0
  17. data/lib/vcr/library_hooks/typhoeus.rb +91 -79
  18. data/lib/vcr/library_hooks/webmock.rb +2 -11
  19. data/lib/vcr/linked_cassette.rb +4 -4
  20. data/lib/vcr/middleware/excon.rb +1 -1
  21. data/lib/vcr/middleware/faraday.rb +29 -2
  22. data/lib/vcr/request_ignorer.rb +8 -1
  23. data/lib/vcr/request_matcher_registry.rb +3 -3
  24. data/lib/vcr/structs.rb +48 -32
  25. data/lib/vcr/test_frameworks/cucumber.rb +16 -5
  26. data/lib/vcr/test_frameworks/rspec.rb +34 -22
  27. data/lib/vcr/util/hooks.rb +1 -0
  28. data/lib/vcr/util/internet_connection.rb +15 -21
  29. data/lib/vcr/version.rb +2 -2
  30. data/lib/vcr.rb +52 -2
  31. metadata +45 -272
  32. data/features/CHANGELOG.md +0 -710
  33. data/features/CONTRIBUTING.md +0 -26
  34. data/features/LICENSE.md +0 -20
  35. data/features/README.md +0 -339
  36. data/features/Upgrade.md +0 -289
  37. data/features/about_these_examples.md +0 -18
  38. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  39. data/features/cassettes/automatic_re_recording.feature +0 -72
  40. data/features/cassettes/decompress.feature +0 -74
  41. data/features/cassettes/dynamic_erb.feature +0 -100
  42. data/features/cassettes/exclusive.feature +0 -126
  43. data/features/cassettes/format.feature +0 -411
  44. data/features/cassettes/freezing_time.feature +0 -68
  45. data/features/cassettes/naming.feature +0 -28
  46. data/features/cassettes/no_cassette.feature +0 -152
  47. data/features/cassettes/update_content_length_header.feature +0 -112
  48. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  49. data/features/configuration/cassette_library_dir.feature +0 -31
  50. data/features/configuration/debug_logging.feature +0 -58
  51. data/features/configuration/default_cassette_options.feature +0 -100
  52. data/features/configuration/filter_sensitive_data.feature +0 -153
  53. data/features/configuration/hook_into.feature +0 -172
  54. data/features/configuration/ignore_request.feature +0 -192
  55. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  56. data/features/configuration/query_parser.feature +0 -84
  57. data/features/configuration/uri_parser.feature +0 -93
  58. data/features/getting_started.md +0 -82
  59. data/features/hooks/after_http_request.feature +0 -58
  60. data/features/hooks/around_http_request.feature +0 -57
  61. data/features/hooks/before_http_request.feature +0 -63
  62. data/features/hooks/before_playback.feature +0 -184
  63. data/features/hooks/before_record.feature +0 -172
  64. data/features/http_libraries/em_http_request.feature +0 -250
  65. data/features/http_libraries/net_http.feature +0 -179
  66. data/features/middleware/faraday.feature +0 -56
  67. data/features/middleware/rack.feature +0 -92
  68. data/features/record_modes/all.feature +0 -82
  69. data/features/record_modes/new_episodes.feature +0 -79
  70. data/features/record_modes/none.feature +0 -72
  71. data/features/record_modes/once.feature +0 -95
  72. data/features/request_matching/README.md +0 -30
  73. data/features/request_matching/body.feature +0 -91
  74. data/features/request_matching/body_as_json.feature +0 -90
  75. data/features/request_matching/custom_matcher.feature +0 -135
  76. data/features/request_matching/headers.feature +0 -85
  77. data/features/request_matching/host.feature +0 -95
  78. data/features/request_matching/identical_request_sequence.feature +0 -89
  79. data/features/request_matching/method.feature +0 -96
  80. data/features/request_matching/path.feature +0 -96
  81. data/features/request_matching/playback_repeats.feature +0 -98
  82. data/features/request_matching/query.feature +0 -97
  83. data/features/request_matching/uri.feature +0 -94
  84. data/features/request_matching/uri_without_param.feature +0 -101
  85. data/features/step_definitions/cli_steps.rb +0 -199
  86. data/features/support/env.rb +0 -46
  87. data/features/support/http_lib_filters.rb +0 -46
  88. data/features/test_frameworks/cucumber.feature +0 -211
  89. data/features/test_frameworks/rspec_macro.feature +0 -81
  90. data/features/test_frameworks/rspec_metadata.feature +0 -150
  91. data/features/test_frameworks/test_unit.feature +0 -49
  92. data/lib/vcr/extensions/net_http_response.rb +0 -36
  93. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  94. data/lib/vcr/library_hooks/typhoeus_0.4.rb +0 -103
  95. data/spec/acceptance/concurrency_spec.rb +0 -51
  96. data/spec/acceptance/threading_spec.rb +0 -34
  97. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  98. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  99. data/spec/fixtures/cassette_spec/example.yml +0 -111
  100. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  101. data/spec/fixtures/fake_example_responses.yml +0 -110
  102. data/spec/fixtures/match_requests_on.yml +0 -187
  103. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  104. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  105. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  106. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  107. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  108. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  109. data/spec/lib/vcr/cassette_spec.rb +0 -618
  110. data/spec/lib/vcr/configuration_spec.rb +0 -326
  111. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  112. data/spec/lib/vcr/errors_spec.rb +0 -178
  113. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  114. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  115. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  116. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  117. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  118. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  119. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  120. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  121. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  122. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  123. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  124. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  125. data/spec/lib/vcr/structs_spec.rb +0 -732
  126. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  127. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  128. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  129. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  130. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  131. data/spec/lib/vcr/version_spec.rb +0 -27
  132. data/spec/lib/vcr_spec.rb +0 -354
  133. data/spec/monkey_patches.rb +0 -186
  134. data/spec/spec_helper.rb +0 -63
  135. data/spec/support/configuration_stubbing.rb +0 -8
  136. data/spec/support/cucumber_helpers.rb +0 -39
  137. data/spec/support/fixnum_extension.rb +0 -10
  138. data/spec/support/http_library_adapters.rb +0 -289
  139. data/spec/support/limited_uri.rb +0 -21
  140. data/spec/support/ruby_interpreter.rb +0 -7
  141. data/spec/support/shared_example_groups/excon.rb +0 -63
  142. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  143. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  144. data/spec/support/sinatra_app.rb +0 -86
  145. data/spec/support/vcr_localhost_server.rb +0 -76
  146. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,182 +0,0 @@
1
- require 'support/ruby_interpreter'
2
- require 'vcr/cassette/serializers'
3
- require 'multi_json'
4
-
5
- begin
6
- require 'psych' # ensure psych is loaded for these tests if its available
7
- rescue LoadError
8
- end
9
-
10
- module VCR
11
- class Cassette
12
- describe Serializers do
13
- shared_examples_for "encoding error handling" do |name, error_class|
14
- context "the #{name} serializer" do
15
- it 'appends info about the :preserve_exact_body_bytes option to the error' do
16
- expect {
17
- result = serializer.serialize("a" => string)
18
- serializer.deserialize(result)
19
- }.to raise_error(error_class, /preserve_exact_body_bytes/)
20
- end unless (RUBY_INTERPRETER == :rubinius && RUBY_VERSION =~ /^1.9/)
21
- end
22
- end
23
-
24
- shared_examples_for "a serializer" do |name, file_extension, lazily_loaded|
25
- let(:serializer) { subject[name] }
26
-
27
- context "the #{name} serializer" do
28
- it 'lazily loads the serializer' do
29
- serializers = subject.instance_variable_get(:@serializers)
30
- expect(serializers).not_to have_key(name)
31
- expect(subject[name]).not_to be_nil
32
- expect(serializers).to have_key(name)
33
- end if lazily_loaded
34
-
35
- it "returns '#{file_extension}' as the file extension" do
36
- expect(serializer.file_extension).to eq(file_extension)
37
- end
38
-
39
- it "can serialize and deserialize a hash" do
40
- hash = { "a" => 7, "nested" => { "hash" => [1, 2, 3] }}
41
- serialized = serializer.serialize(hash)
42
- expect(serialized).not_to eq(hash)
43
- expect(serialized).to be_a(String)
44
- deserialized = serializer.deserialize(serialized)
45
- expect(deserialized).to eq(hash)
46
- end
47
- end
48
- end
49
-
50
- it_behaves_like "a serializer", :yaml, "yml", :lazily_loaded do
51
- it_behaves_like "encoding error handling", :yaml, ArgumentError do
52
- let(:string) { "\xFA".force_encoding("UTF-8") }
53
- before { ::YAML::ENGINE.yamler = 'psych' if defined?(::YAML::ENGINE) }
54
- end if ''.respond_to?(:encoding)
55
- end
56
-
57
- it_behaves_like "a serializer", :syck, "yml", :lazily_loaded do
58
- it_behaves_like "encoding error handling", :syck, ArgumentError do
59
- let(:string) { "\xFA".force_encoding("UTF-8") }
60
- end if ''.respond_to?(:encoding)
61
- end
62
-
63
- it_behaves_like "a serializer", :psych, "yml", :lazily_loaded do
64
- it_behaves_like "encoding error handling", :psych, ArgumentError do
65
- let(:string) { "\xFA".force_encoding("UTF-8") }
66
- end if ''.respond_to?(:encoding)
67
- end if RUBY_VERSION =~ /1.9/
68
-
69
- it_behaves_like "a serializer", :compressed, "gz", :lazily_loaded do
70
- it_behaves_like "encoding error handling", :compressed, ArgumentError do
71
- let(:string) { "\xFA".force_encoding("UTF-8") }
72
- end if ''.respond_to?(:encoding)
73
- end
74
-
75
- it_behaves_like "a serializer", :json, "json", :lazily_loaded do
76
- engines = {}
77
-
78
- if RUBY_INTERPRETER == :jruby
79
- # don't test yajl on jruby
80
- else
81
- engines[:yajl] = MultiJson::LoadError
82
- end
83
-
84
- if RUBY_VERSION =~ /1.9/
85
- engines[:json_gem] = EncodingError
86
-
87
- # Disable json_pure for now due to this bug:
88
- # https://github.com/flori/json/issues/186
89
- # engines[:json_pure] = EncodingError
90
- end
91
-
92
- engines.each do |engine, error|
93
- context "when MultiJson is configured to use #{engine.inspect}", :unless => (RUBY_INTERPRETER == :jruby) do
94
- before { MultiJson.engine = engine }
95
- it_behaves_like "encoding error handling", :json, error do
96
- let(:string) { "\xFA" }
97
- end
98
- end
99
- end
100
- end
101
-
102
- context "a custom :ruby serializer" do
103
- let(:custom_serializer) do
104
- Object.new.tap do |obj|
105
- def obj.file_extension
106
- "rb"
107
- end
108
-
109
- def obj.serialize(hash)
110
- hash.inspect
111
- end
112
-
113
- def obj.deserialize(string)
114
- eval(string)
115
- end
116
- end
117
- end
118
-
119
- before(:each) do
120
- subject[:ruby] = custom_serializer
121
- end
122
-
123
- it_behaves_like "a serializer", :ruby, "rb", false
124
- end
125
-
126
- describe "#[]=" do
127
- context 'when there is already a serializer registered for the given name' do
128
- before(:each) do
129
- subject[:foo] = :old_serializer
130
- allow(subject).to receive :warn
131
- end
132
-
133
- it 'overrides the existing serializer' do
134
- subject[:foo] = :new_serializer
135
- expect(subject[:foo]).to be(:new_serializer)
136
- end
137
-
138
- it 'warns that there is a name collision' do
139
- expect(subject).to receive(:warn).with(
140
- /WARNING: There is already a VCR cassette serializer registered for :foo\. Overriding it/
141
- )
142
- subject[:foo] = :new_serializer
143
- end
144
- end
145
- end
146
-
147
- describe "#[]" do
148
- it 'raises an error when given an unrecognized serializer name' do
149
- expect { subject[:foo] }.to raise_error(ArgumentError)
150
- end
151
-
152
- it 'returns the named serializer' do
153
- expect(subject[:yaml]).to be(VCR::Cassette::Serializers::YAML)
154
- end
155
- end
156
-
157
- # see https://gist.github.com/815769
158
- problematic_syck_string = "1\n \n2"
159
-
160
- describe "psych serializer" do
161
- it 'serializes things using pysch even if syck is configured as the default YAML engine' do
162
- ::YAML::ENGINE.yamler = 'syck'
163
- serialized = subject[:psych].serialize(problematic_syck_string)
164
- expect(subject[:psych].deserialize(serialized)).to eq(problematic_syck_string)
165
- end if defined?(::Psych) && RUBY_VERSION.to_f < 2.0
166
-
167
- it 'raises an error if psych cannot be loaded' do
168
- expect { subject[:psych] }.to raise_error(LoadError)
169
- end unless defined?(::Psych)
170
- end
171
-
172
- describe "syck serializer" do
173
- it 'forcibly serializes things using syck even if psych is the currently configured YAML engine' do
174
- ::YAML::ENGINE.yamler = 'psych'
175
- serialized = subject[:syck].serialize(problematic_syck_string)
176
- expect(subject[:syck].deserialize(serialized)).not_to eq(problematic_syck_string)
177
- end if defined?(::Psych) && (RUBY_INTERPRETER != :jruby) && (RUBY_VERSION.to_f < 2.0)
178
- end
179
- end
180
- end
181
- end
182
-