Fix up RSpec tests
This commit is contained in:
parent
e99d9ac054
commit
7bc0842d26
4 changed files with 13 additions and 2 deletions
|
|
@ -97,6 +97,7 @@ FactoryBot.define do
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
WebMock.stub_request(:post, url_mailbluster)
|
WebMock.stub_request(:post, url_mailbluster)
|
||||||
|
.to_return(body: response_body, status: 200)
|
||||||
end
|
end
|
||||||
# Called by every user creation
|
# Called by every user creation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ require 'webmock/rspec'
|
||||||
|
|
||||||
describe External::MailblusterHelper, type: :helper do
|
describe External::MailblusterHelper, type: :helper do
|
||||||
let!(:user) { create(:user) }
|
let!(:user) { create(:user) }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
WebMock.reset_executed_requests!
|
||||||
|
end
|
||||||
|
|
||||||
url = 'https://api.mailbluster.com/api/leads/'
|
url = 'https://api.mailbluster.com/api/leads/'
|
||||||
|
|
||||||
describe 'create_lead' do
|
describe 'create_lead' do
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ ENV['RAILS_ENV'] ||= 'test'
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
require File.expand_path('../../config/environment', __FILE__)
|
||||||
|
|
||||||
# Prevent tests from making calls to the Internet
|
# Prevent tests from making calls to the Internet
|
||||||
require 'webmock/rspec'
|
# require 'webmock/rspec'
|
||||||
WebMock.disable_net_connect!(allow_localhost: true)
|
# WebMock.disable_net_connect!(allow_localhost: true)
|
||||||
|
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'shoulda/matchers'
|
require 'shoulda/matchers'
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ RSpec.configure do |config|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
mock_commercial_request
|
mock_commercial_request
|
||||||
mock_image_request
|
mock_image_request
|
||||||
|
mock_default_mailbluster
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -39,3 +40,7 @@ def mock_image_request
|
||||||
WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy')
|
WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy')
|
||||||
.to_return(status: 200, body: {}.to_json, headers: {})
|
.to_return(status: 200, body: {}.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mock_default_mailbluster
|
||||||
|
WebMock.stub_request(:any, /api.mailbluster.com/)
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue