Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ group :test do
gem 'simplecov', require: false
gem 'simplecov-lcov', require: false
gem 'timecop', '~> 0.9.10'
gem 'webmock'
end

group :production do
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ GEM
commonmarker (2.5.0-x86_64-linux)
concurrent-ruby (1.3.5)
connection_pool (2.5.5)
crack (1.0.1)
bigdecimal
rexml
crass (1.0.6)
css_parser (1.14.0)
addressable
Expand Down Expand Up @@ -221,6 +224,7 @@ GEM
rainbow
rubocop (>= 1.0)
sysexits (~> 1.1)
hashdiff (1.2.1)
hashie (5.0.0)
high_voltage (4.0.0)
htmlentities (4.3.4)
Expand Down Expand Up @@ -568,6 +572,10 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.26.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.11)
websocket-driver (0.8.0)
base64
Expand Down Expand Up @@ -668,6 +676,7 @@ DEPENDENCIES
turbo-rails
tzinfo-data
web-console (>= 4.1.0)
webmock

RUBY VERSION
ruby 3.4.7p58
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'simplecov'
require 'simplecov-lcov'
require 'shoulda/matchers'
require 'webmock/rspec'

# Fix incompatibility of simplecov-lcov with older versions of simplecov that are not expresses in its gemspec.
# https://github.com/fortissimo1997/simplecov-lcov/pull/25
Expand Down Expand Up @@ -33,6 +34,9 @@ def self.branch_coverage?
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'

# Block all external HTTP requests in tests; allows localhost for Capybara
WebMock.disable_net_connect!(allow_localhost: true)

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

ActiveRecord::Migration.check_all_pending! if defined?(ActiveRecord::Migration)
Expand Down Expand Up @@ -70,6 +74,11 @@ def self.branch_coverage?
end

config.before(:each) do
# Stub all Flodesk API endpoints globally so tests don't make external requests
# when fabricating members (which trigger Subscription.after_create callback)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good context!

WebMock.stub_request(:any, %r{api\.flodesk\.com}).
to_return(status: 200, body: '{"status":"active","segments":[]}', headers: { 'Content-Type' => 'application/json' })

DatabaseCleaner.strategy = :transaction
end

Expand Down