Skip to content

Commit

Permalink
Enable RSpec zero-monkey-patching-mode (vcr#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleolleolle authored Mar 30, 2020
1 parent 8833506 commit b38a38e
Show file tree
Hide file tree
Showing 34 changed files with 43 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ RSpec.configure do |c|
end

# apply it to an example group
describe MyAPIWrapper, :vcr do
RSpec.describe MyAPIWrapper, :vcr do
end

describe MyAPIWrapper do
RSpec.describe MyAPIWrapper do
# apply it to an individual example
it "does something", :vcr do
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/concurrency_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR do
RSpec.describe VCR do
def recorded_content_for(name)
VCR.cassette_persisters[:file_system]["#{name}.yml"].to_s
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/threading_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR do
RSpec.describe VCR do
context 'when used in a multithreaded environment', :with_monkey_patches => :excon do
def preload_yaml_serializer_to_avoid_circular_require_warning_race_condition
VCR.cassette_serializers[:yaml]
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/erb_renderer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::Cassette::ERBRenderer do
RSpec.describe VCR::Cassette::ERBRenderer do
describe '#render' do
def render(*args)
described_class.new(*args).render
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/http_interaction_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module VCR
class Cassette
describe HTTPInteractionList do
::RSpec.describe HTTPInteractionList do
include_context "configuration stubbing"

::RSpec::Matchers.define :respond_with do |expected|
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/migrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'vcr/cassette/migrator'
require 'yaml'

describe VCR::Cassette::Migrator do
RSpec.describe VCR::Cassette::Migrator do
let(:original_contents) { <<-EOF
---
- !ruby/struct:VCR::HTTPInteraction
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/persisters/file_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module VCR
class Cassette
class Persisters
describe FileSystem do
::RSpec.describe FileSystem do
before { FileSystem.storage_location = VCR.configuration.cassette_library_dir }

describe "#[]" do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/persisters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module VCR
class Cassette
describe Persisters do
::RSpec.describe Persisters do
describe "#[]=" do
context 'when there is already a persister registered for the given name' do
before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette/serializers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

module VCR
class Cassette
describe Serializers do
::RSpec.describe Serializers do
shared_examples_for "encoding error handling" do |name, error_class|
context "the #{name} serializer" do
it 'appends info about the :preserve_exact_body_bytes option to the error' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/cassette_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::Cassette do
RSpec.describe VCR::Cassette do
def http_interaction
request = VCR::Request.new(:get)
response = VCR::Response.new
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::Configuration do
RSpec.describe VCR::Configuration do
describe '#cassette_library_dir=' do
let(:tmp_dir) { VCR::SPEC_ROOT + '/../tmp/cassette_library_dir/new_dir' }
after(:each) { FileUtils.rm_rf tmp_dir }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/deprecations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR, 'deprecations', :disable_warnings do
RSpec.describe VCR, 'deprecations', :disable_warnings do
describe ".config" do
it 'delegates to VCR.configure' do
expect(VCR).to receive(:configure)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module VCR
module Errors
describe UnhandledHTTPRequestError do
::RSpec.describe UnhandledHTTPRequestError do
def message_for(request_values = {})
described_class.new(request_with request_values).message
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks/excon_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'support/shared_example_groups/excon'

describe "Excon hook", :with_monkey_patches => :excon do
RSpec.describe "Excon hook", :with_monkey_patches => :excon do
after(:each) do
::Excon.stubs.clear
::Excon.defaults[:mock] = false
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks/faraday_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'vcr/library_hooks/faraday'

describe "Faraday hook" do
RSpec.describe "Faraday hook" do
it 'inserts the VCR middleware just before the adapter' do
conn = Faraday.new(:url => 'http://sushi.com') do |builder|
builder.request :url_encoded
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe "Typhoeus 0.4 hook", :with_monkey_patches => :typhoeus_0_4 do
RSpec.describe "Typhoeus 0.4 hook", :with_monkey_patches => :typhoeus_0_4 do
after(:each) do
::Typhoeus::Hydra.clear_stubs
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks/typhoeus_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe "Typhoeus hook", :with_monkey_patches => :typhoeus, :if => (RUBY_INTERPRETER == :mri) do
RSpec.describe "Typhoeus hook", :with_monkey_patches => :typhoeus, :if => (RUBY_INTERPRETER == :mri) do
after(:each) do
::Typhoeus::Expectation.clear
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks/webmock_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'support/shared_example_groups/excon'

describe "WebMock hook", :with_monkey_patches => :webmock do
RSpec.describe "WebMock hook", :with_monkey_patches => :webmock do
after(:each) do
::WebMock.reset!
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/library_hooks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'vcr/library_hooks'

module VCR
describe LibraryHooks do
::RSpec.describe LibraryHooks do
describe '#disabled?' do
it 'returns false by default for any argument given' do
expect(subject.disabled?(:foo)).to be false
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/middleware/faraday_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'vcr/library_hooks/faraday'

describe VCR::Middleware::Faraday do
RSpec.describe VCR::Middleware::Faraday do
http_libs = %w[ typhoeus net_http patron ]
http_libs.each do |lib|
flags = [ :does_not_support_rotating_responses ]
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/vcr/middleware/rack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module VCR
module Middleware
describe CassetteArguments do
::RSpec.describe CassetteArguments do
describe '#name' do
it 'initially returns nil' do
expect(subject.name).to be_nil
Expand Down Expand Up @@ -33,7 +33,7 @@ module Middleware
end
end

describe Rack do
::RSpec.describe Rack do
describe '.new' do
it 'raises an error if no cassette arguments block is provided' do
expect {
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/request_ignorer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'vcr/request_ignorer'

module VCR
describe RequestIgnorer do
::RSpec.describe RequestIgnorer do
def request(uri)
VCR::Request.new.tap { |r| r.uri = uri }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/request_matcher_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'support/configuration_stubbing'

module VCR
describe RequestMatcherRegistry do
::RSpec.describe RequestMatcherRegistry do
include_context "configuration stubbing"

before do
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/vcr/structs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'support/limited_uri'
require 'support/configuration_stubbing'

shared_examples_for "a header normalizer" do
RSpec.shared_examples_for "a header normalizer" do
let(:instance) do
with_headers('Some_Header' => 'value1', 'aNother' => ['a', 'b'], 'third' => [], 'fourth' => nil)
end
Expand Down Expand Up @@ -42,7 +42,7 @@
end
end

shared_examples_for "a body normalizer" do
RSpec.shared_examples_for "a body normalizer" do
it "ensures the body is serialized to yaml as a raw string" do
body = "My String"
body.instance_variable_set(:@foo, 7)
Expand All @@ -61,7 +61,7 @@
end

module VCR
describe HTTPInteraction do
::RSpec.describe HTTPInteraction do
include_context "configuration stubbing"
before { allow(config).to receive(:uri_parser) { LimitedURI } }

Expand Down Expand Up @@ -353,7 +353,7 @@ def assert_yielded_keys(hash, *keys)
end
end

describe HTTPInteraction::HookAware do
::RSpec.describe HTTPInteraction::HookAware do
include_context "configuration stubbing"

before do
Expand Down Expand Up @@ -440,7 +440,7 @@ def assert_yielded_keys(hash, *keys)
end
end

describe Request::Typed do
::RSpec.describe Request::Typed do
[:uri, :method, :headers, :body].each do |method|
it "delegates ##{method} to the request" do
request = double(method => "delegated value")
Expand Down Expand Up @@ -498,7 +498,7 @@ def assert_yielded_keys(hash, *keys)
end
end

describe Request do
::RSpec.describe Request do
include_context "configuration stubbing"

before do
Expand Down Expand Up @@ -584,7 +584,7 @@ def instance(body)
end
end

describe Response do
::RSpec.describe Response do
it_behaves_like 'a header normalizer' do
def with_headers(headers)
described_class.new(:status, headers, nil, '1.1')
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/test_frameworks/cucumber_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::CucumberTags do
RSpec.describe VCR::CucumberTags do
subject { described_class.new(self) }
let(:before_blocks_for_tags) { {} }
let(:after_blocks_for_tags) { {} }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/test_frameworks/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

VCR.configuration.configure_rspec_metadata!

describe VCR::RSpec::Metadata, :skip_vcr_reset do
RSpec.describe VCR::RSpec::Metadata, :skip_vcr_reset do
before(:all) { VCR.reset! }
after(:each) { VCR.reset! }

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/vcr/util/hooks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::Hooks::FilteredHook do
RSpec.describe VCR::Hooks::FilteredHook do
describe "#conditionally_invoke" do
it 'invokes the hook' do
called = false
Expand Down Expand Up @@ -75,7 +75,7 @@
end
end

describe VCR::Hooks do
RSpec.describe VCR::Hooks do
let(:hooks_class) { Class.new { include VCR::Hooks } }

subject { hooks_class.new }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/util/internet_connection_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR::InternetConnection do
RSpec.describe VCR::InternetConnection do
describe '.available?' do
before(:each) do
described_class.send(:remove_instance_variable, :@available) if described_class.instance_variable_defined?(:@available)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/util/version_checker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

module VCR
describe VersionChecker do
::RSpec.describe VersionChecker do
it 'raises an error if the major version is too low' do
checker = VersionChecker.new('foo', '0.7.3', '1.0.0')
expect { checker.check_version! }.to raise_error(Errors::LibraryVersionTooLowError)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/version_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe "VCR.version" do
RSpec.describe "VCR.version" do
subject { VCR.version }

it { should =~ /\A\d+\.\d+\.\d+(\.\w+)?\z/ }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe VCR do
RSpec.describe VCR do
def insert_cassette(name = :cassette_test)
VCR.insert_cassette(name)
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def reset!(hook = nil)
end

RSpec.configure do |config|
config.disable_monkey_patching!
tmp_dir = File.expand_path('../../tmp/cassette_library_dir', __FILE__)
config.before(:each) do |example|
unless example.metadata[:skip_vcr_reset]
Expand Down
2 changes: 1 addition & 1 deletion spec/support/configuration_stubbing.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shared_context "configuration stubbing" do
RSpec.shared_context "configuration stubbing" do
let(:config) { double("VCR::Configuration") }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_example_groups/excon.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shared_examples "Excon streaming" do
RSpec.shared_examples "Excon streaming" do
context "when Excon's streaming API is used" do
def make_request_to(path)
chunks = []
Expand Down

0 comments on commit b38a38e

Please sign in to comment.