From 173d4ef529283f0487a2f6bfce5187931ad7de2e Mon Sep 17 00:00:00 2001 From: Ken Ding Date: Sun, 22 Dec 2024 12:04:53 +1100 Subject: [PATCH] 13 - move createsend stub to CampaignMonitorStubs module --- spec/rails_helper.rb | 3 +++ spec/spec_helper.rb | 9 --------- spec/support/campaign_monitor_stubs.rb | 11 +++++++++++ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 spec/support/campaign_monitor_stubs.rb diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9db0236d..0a2a3029 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -53,4 +53,7 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + config.before(:each) do + CampaignMonitorStubs.configure + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bb33ef78..9890430b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -95,13 +95,4 @@ # # test failures related to randomization by passing the same `--seed` value # # as the one that triggered the failure. # Kernel.srand config.seed - config.before(:each) do - # all confirmed email, we need to update subscribers - stub_request(:get, %r{https://api.createsend.com/api/v3.3/subscribers/(camp-key|conf-key|girls-key).json}) - .to_return( - status: 200, - body: { State: "Active" }.to_json, - headers: { 'Content-Type': 'application/json' } - ) - end end diff --git a/spec/support/campaign_monitor_stubs.rb b/spec/support/campaign_monitor_stubs.rb new file mode 100644 index 00000000..1b50405b --- /dev/null +++ b/spec/support/campaign_monitor_stubs.rb @@ -0,0 +1,11 @@ +module CampaignMonitorStubs + def self.configure + WebMock + .stub_request(:get, %r{https://api.createsend.com/api/v3.3/subscribers/(camp-key|conf-key|girls-key).json}) + .to_return( + status: 200, + body: { State: "Active" }.to_json, + headers: { 'Content-Type': 'application/json' } + ) + end +end