diff --git a/Gemfile.lock b/Gemfile.lock index 9b656bb0f..9d04c10c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,7 +120,7 @@ GEM cssbundling-rails (1.4.3) railties (>= 6.0.0) csv (3.3.6) - date (3.5.1) + date (3.6.0) debug (1.11.1) irb (~> 1.10) reline (>= 0.3.8) @@ -156,7 +156,7 @@ GEM goldiloader (6.0.0) activerecord (>= 7.2, < 8.3) activesupport (>= 7.2, < 8.3) - good_job (4.20.0) + good_job (4.22.0) activejob (>= 6.1.0) activerecord (>= 6.1.0) concurrent-ruby (>= 1.3.1) @@ -223,7 +223,7 @@ GEM pg (1.7.0) pp (0.6.4) prettyprint - prettyprint (0.2.0) + prettyprint (0.2.1) prism (1.9.0) private_address_check (0.8.0) propshaft (1.3.2) @@ -325,14 +325,14 @@ GEM rspec-support (3.13.7) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.91.0) + rubocop (1.92.0) json (>= 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) parallel (>= 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.9.3, < 3.0) + regexp_parser (>= 2.11.3, < 3.0) rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) @@ -361,9 +361,9 @@ GEM lint_roller (~> 1.1) regexp_parser (>= 2.0) rubocop (~> 1.86, >= 1.86.2) - rubocop-rspec_rails (2.32.0) + rubocop-rspec_rails (2.33.0) lint_roller (~> 1.1) - rubocop (~> 1.72, >= 1.72.1) + rubocop (~> 1.89) rubocop-rspec (~> 3.5) ruby-progressbar (1.13.0) rubyzip (3.7.0) @@ -376,7 +376,7 @@ GEM scout_apm (6.3.1) parser securerandom (0.4.1) - selenium-webdriver (4.50.0) + selenium-webdriver (4.51.0) base64 (~> 0.2) logger (~> 1.4) rubyzip (>= 1.2.2, < 4.0) @@ -397,7 +397,7 @@ GEM thor (1.5.0) thread (0.2.2) timeout (0.6.1) - tins (1.60.0) + tins (1.61.0) bigdecimal irb mize (~> 0.6) @@ -412,13 +412,13 @@ GEM unicode-display_width (3.3.0) unicode-emoji (~> 4.3) unicode-emoji (4.3.0) - uri (1.1.1) + uri (1.1.2) useragent (0.16.11) web-console (4.3.0) actionview (>= 8.0.0) bindex (>= 0.4.0) railties (>= 8.0.0) - webmock (3.26.4) + webmock (3.29.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ced21387b..282318182 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -23,6 +23,7 @@ RSpec.configure do |config| config.include(RequestHelpers, type: :request) config.include(SystemHelpers, type: :system) + config.include(JobHelpers) config.include(ActiveSupport::Testing::TimeHelpers) config.use_transactional_fixtures = true diff --git a/spec/requests/feeds_controller_spec.rb b/spec/requests/feeds_controller_spec.rb index 54b5ce561..ce359f5b6 100644 --- a/spec/requests/feeds_controller_spec.rb +++ b/spec/requests/feeds_controller_spec.rb @@ -120,15 +120,6 @@ def params(feed, **overrides) end end - def with_test_adapter - adapter = ActiveJob::Base.queue_adapter - ActiveJob::Base.queue_adapter = :test - - yield - - ActiveJob::Base.queue_adapter = adapter - end - describe "#create" do context "when the feed url is valid" do feed_url = "http://example.com/" diff --git a/spec/support/job_helpers.rb b/spec/support/job_helpers.rb new file mode 100644 index 000000000..7ebc83634 --- /dev/null +++ b/spec/support/job_helpers.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module JobHelpers + def with_test_adapter + adapter = ActiveJob::Base.queue_adapter + ActiveJob::Base.queue_adapter = :test + + yield + ensure + ActiveJob::Base.queue_adapter = adapter + end +end diff --git a/spec/system/add_feed_spec.rb b/spec/system/add_feed_spec.rb index 8e85ebe87..f0796d7be 100644 --- a/spec/system/add_feed_spec.rb +++ b/spec/system/add_feed_spec.rb @@ -15,11 +15,13 @@ def submit_feed(url) it "allows adding a new feed" do login_as(default_user) stub_discovery(url: "http://example.com/feed.xml") - expect(CallableJob).to receive(:perform_later) - submit_feed("http://example.com/feed.xml") + with_test_adapter do + submit_feed("http://example.com/feed.xml") - expect(page).to have_text("We've added your new feed") + expect(page).to have_text("We've added your new feed") + expect(CallableJob).to have_been_enqueued + end end it "shows an error when the feed is not found" do diff --git a/spec/system/tutorial_spec.rb b/spec/system/tutorial_spec.rb index 0b53537d4..398e27e10 100644 --- a/spec/system/tutorial_spec.rb +++ b/spec/system/tutorial_spec.rb @@ -1,23 +1,21 @@ # frozen_string_literal: true RSpec.describe "tutorial" do - def visit_tutorial - expect(CallableJob).to receive(:perform_later) - visit(setup_tutorial_path) - end + around { |example| with_test_adapter(&example) } it "displays the tutorial page" do login_as(default_user) - visit_tutorial + visit(setup_tutorial_path) expect(page).to have_text("Stringer is simple") + expect(CallableJob).to have_been_enqueued end it "displays sample stories" do login_as(default_user) - visit_tutorial + visit(setup_tutorial_path) expect(page).to have_text("Darin' Fireballs") end