diff --git a/.github/workflows/sentry_sidekiq_test.yml b/.github/workflows/sentry_sidekiq_test.yml index 34904339c..409c3db92 100644 --- a/.github/workflows/sentry_sidekiq_test.yml +++ b/.github/workflows/sentry_sidekiq_test.yml @@ -80,8 +80,6 @@ jobs: redis-version: ${{ (contains(matrix.sidekiq_version, '7.0') || contains(matrix.sidekiq_version, '8.0')) && 6 || 5 }} - name: Run specs with Sidekiq ${{ matrix.sidekiq_version }} - env: - WITH_SENTRY_RAILS: 1 run: bundle exec rake - name: Upload Coverage diff --git a/sentry-sidekiq/.rspec b/sentry-sidekiq/.rspec index 8c18f1abd..7a2cc1a6e 100644 --- a/sentry-sidekiq/.rspec +++ b/sentry-sidekiq/.rspec @@ -1,2 +1,3 @@ +--require spec_helper --format documentation --color diff --git a/sentry-sidekiq/Rakefile b/sentry-sidekiq/Rakefile index 13afab191..c8e4e1685 100644 --- a/sentry-sidekiq/Rakefile +++ b/sentry-sidekiq/Rakefile @@ -1,10 +1,17 @@ # frozen_string_literal: true -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require "rake/clean" +require "bundler/gem_helper" -RSpec::Core::RakeTask.new(:spec).tap do |task| - task.rspec_opts = "--order rand" -end +Bundler::GemHelper.install_tasks(name: "sentry-sidekiq") -task default: :spec +require_relative "../lib/sentry/test/rake_tasks" + +ISOLATED_SPECS = "spec/isolated/**/*_spec.rb" + +Sentry::Test::RakeTasks.define_spec_tasks( + isolated_specs_pattern: ISOLATED_SPECS, + spec_exclude_pattern: ISOLATED_SPECS +) + +task default: [:spec, :"spec:isolated"] diff --git a/sentry-sidekiq/spec/isolated/rails_spec.rb b/sentry-sidekiq/spec/isolated/rails_spec.rb new file mode 100644 index 000000000..72f79b0d7 --- /dev/null +++ b/sentry-sidekiq/spec/isolated/rails_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +begin + require "simplecov" + SimpleCov.command_name "SidekiqRails" +rescue LoadError +end + +require "sentry-rails" + +RSpec.describe Sentry::Sidekiq do + def make_basic_app + app = Class.new(Rails::Application) do + def self.name + "RailsTestApp" + end + end + + app.config.hosts = nil + app.config.secret_key_base = "test" + app.config.eager_load = false + + app.initializer :configure_sentry do + Sentry.init do |config| + config.release = 'beta' + config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42" + config.transport.transport_class = Sentry::DummyTransport + # for sending events synchronously + config.background_worker_threads = 0 + yield(config, app) if block_given? + end + end + + app.initialize! + Rails.application = app + app + end + + context "with default config" do + before do + make_basic_app + end + + it "adds sidekiq adapter to config.rails.skippable_job_adapters" do + expect(Sentry.configuration.rails.skippable_job_adapters).to include("ActiveJob::QueueAdapters::SidekiqAdapter") + end + end +end diff --git a/sentry-sidekiq/spec/sentry/rails_spec.rb b/sentry-sidekiq/spec/sentry/rails_spec.rb deleted file mode 100644 index 4026ed4d6..000000000 --- a/sentry-sidekiq/spec/sentry/rails_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -return unless ENV["WITH_SENTRY_RAILS"] - -require "logger" - -require "rails" -require "sentry-rails" -require "spec_helper" - -require "action_controller/railtie" - -class TestApp < Rails::Application -end - -def make_basic_app - app = Class.new(TestApp) do - def self.name - "RailsTestApp" - end - end - - app.config.hosts = nil - app.config.secret_key_base = "test" - app.config.eager_load = false - app.initializer :configure_sentry do - Sentry.init do |config| - config.release = 'beta' - config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42" - config.transport.transport_class = Sentry::DummyTransport - # for sending events synchronously - config.background_worker_threads = 0 - yield(config, app) if block_given? - end - end - - app.initialize! - Rails.application = app - app -end - -RSpec.describe Sentry::Sidekiq do - before do - make_basic_app - end - - it "adds sidekiq adapter to config.rails.skippable_job_adapters" do - expect(Sentry.configuration.rails.skippable_job_adapters).to include("ActiveJob::QueueAdapters::SidekiqAdapter") - end -end