Fix up RSpec tests

This commit is contained in:
CactusPuppy 2021-03-23 13:01:22 -07:00
parent e99d9ac054
commit 7bc0842d26
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
4 changed files with 13 additions and 2 deletions

View file

@ -97,6 +97,7 @@ FactoryBot.define do
}
}"
WebMock.stub_request(:post, url_mailbluster)
.to_return(body: response_body, status: 200)
end
# Called by every user creation

View file

@ -5,6 +5,11 @@ require 'webmock/rspec'
describe External::MailblusterHelper, type: :helper do
let!(:user) { create(:user) }
before(:each) do
WebMock.reset_executed_requests!
end
url = 'https://api.mailbluster.com/api/leads/'
describe 'create_lead' do

View file

@ -13,8 +13,8 @@ ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent tests from making calls to the Internet
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)
# require 'webmock/rspec'
# WebMock.disable_net_connect!(allow_localhost: true)
require 'rspec/rails'
require 'shoulda/matchers'

View file

@ -11,6 +11,7 @@ RSpec.configure do |config|
config.before(:each) do
mock_commercial_request
mock_image_request
mock_default_mailbluster
end
end
@ -39,3 +40,7 @@ def mock_image_request
WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy')
.to_return(status: 200, body: {}.to_json, headers: {})
end
def mock_default_mailbluster
WebMock.stub_request(:any, /api.mailbluster.com/)
end