Fix VCR warnings and use initializers (#6672)

This commit is contained in:
rhymes 2020-03-17 15:51:07 +01:00 committed by GitHub
parent 3b3808f2f6
commit b8b321c13d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 29 deletions

View file

@ -1,11 +1,6 @@
require "rails_helper"
VCR_OPTIONS = {
cassette_name: "twitter_fetch_status",
allow_playback_repeats: true
}.freeze
RSpec.describe Tweet, type: :model, vcr: VCR_OPTIONS do
RSpec.describe Tweet, type: :model, vcr: VCR_OPTIONS[:twitter_fetch_status] do
let(:tweet_id) { "1018911886862057472" }
it "fetches a tweet" do

View file

@ -51,17 +51,6 @@ allowed_sites = [
]
WebMock.disable_net_connect!(allow_localhost: true, allow: allowed_sites)
# tell VCR to ignore browsers download sites
# see <https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock>
VCR.configure do |config|
config.ignore_hosts(
"chromedriver.storage.googleapis.com",
"github.com/mozilla/geckodriver/releases",
"selenium-release.storage.googleapis.com",
"developer.microsoft.com/en-us/microsoft-edge/tools/webdriver",
)
end
RSpec::Matchers.define_negated_matcher :not_change, :change
RSpec.configure do |config|
@ -103,7 +92,7 @@ RSpec.configure do |config|
end
end
# Allow testing with Stripe's test server. BECAREFUL
# Allow testing with Stripe's test server. BE CAREFUL
if config.filter_manager.inclusions.rules.include?(:live)
WebMock.allow_net_connect!
StripeMock.toggle_live(true)
@ -137,8 +126,3 @@ RSpec.configure do |config|
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
Doorkeeper.configure do
# hash_token_secrets on its own won't work in test
hash_token_secrets fallback: :plain
end

View file

@ -1,11 +1,6 @@
require "rails_helper"
VCR_OPTIONS = {
cassette_name: "twitter_fetch_status",
allow_playback_repeats: true
}.freeze
RSpec.describe "LiquidEmbeds", type: :request, vcr: VCR_OPTIONS do
RSpec.describe "LiquidEmbeds", type: :request, vcr: VCR_OPTIONS[:twitter_fetch_status] do
describe "get /embeds" do
it "renders proper tweet" do
get "/embed/tweet?args=1018911886862057472"

View file

@ -0,0 +1,4 @@
Doorkeeper.configure do
# hash_token_secrets on its own won't work in test
hash_token_secrets fallback: :plain
end

View file

@ -6,6 +6,15 @@ VCR.configure do |config|
config.configure_rspec_metadata!
config.ignore_localhost = true
# tell VCR to ignore browsers download sites
# see <https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock>
config.ignore_hosts(
"chromedriver.storage.googleapis.com",
"github.com/mozilla/geckodriver/releases",
"selenium-release.storage.googleapis.com",
"developer.microsoft.com/en-us/microsoft-edge/tools/webdriver",
)
# Removes all private data (Basic Auth, Set-Cookie headers...)
config.before_record do |i|
i.response.headers.delete("Set-Cookie")
@ -15,3 +24,10 @@ VCR.configure do |config|
i.request.uri.sub!(/:\/\/.*#{Regexp.escape(u.host)}/, "://#{u.host}")
end
end
VCR_OPTIONS = {
twitter_fetch_status: {
cassette_name: "twitter_fetch_status",
allow_playback_repeats: true
}
}.freeze