diff --git a/app/helpers/external/mailbluster_helper.rb b/app/helpers/external/mailbluster_helper.rb new file mode 100644 index 00000000..2f57fa26 --- /dev/null +++ b/app/helpers/external/mailbluster_helper.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module External + module Mailbluster + def create_lead(user) + # TODO + end + end +end \ No newline at end of file diff --git a/spec/helpers/external/mailbluster_helper_spec.rb b/spec/helpers/external/mailbluster_helper_spec.rb new file mode 100644 index 00000000..b6d3016e --- /dev/null +++ b/spec/helpers/external/mailbluster_helper_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'webmock/rspec' + +describe MailblusterHelper, type: :helper do + let!(:user) { create(:user) } + + describe 'create_lead' do + it 'makes a post request to Mailbluster\'s API' do + create_lead(@user) + expect(WebMock).to have_requested(:post, "api.mailbluster.com/api/leads"). + with { |req| req.body == "abc" } + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2d680fb2..32fc961c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,10 @@ SimpleCov.start 'rails' 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 'rspec/rails' require 'shoulda/matchers' require 'webdrivers'