Skip to content

Commit 213558f

Browse files
authored
[sentry-ruby] fix and improve spec suite setup (#2640)
1 parent 4e520fc commit 213558f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+11
-132
lines changed

sentry-ruby/.rspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
--format documentation
1+
--require spec_helper
2+
--format progress
23
--color
4+
--order rand

sentry-ruby/Rakefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ Bundler::GemHelper.install_tasks(name: "sentry-ruby")
88

99
require "rspec/core/rake_task"
1010

11+
ISOLATED_SPECS = "spec/isolated/**/*_spec.rb"
12+
1113
RSpec::Core::RakeTask.new(:spec).tap do |task|
12-
task.rspec_opts = "--order rand"
13-
task.exclude_pattern = "spec/isolated/**/*_spec.rb"
14+
task.exclude_pattern = ISOLATED_SPECS
1415
end
1516

16-
task :isolated_specs do
17-
Dir["spec/isolated/**/*_spec.rb"].each do |file|
18-
sh "bundle exec rspec #{file}"
19-
end
17+
RSpec::Core::RakeTask.new(:isolated_specs).tap do |task|
18+
task.pattern = ISOLATED_SPECS
2019
end
2120

2221
task default: [:spec, :isolated_specs]

sentry-ruby/spec/initialization_check_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe "with uninitialized SDK" do
64
before do
75
# completely nuke any initialized hubs

sentry-ruby/spec/isolated/init_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require_relative "../spec_helper"
4-
53
# isolated tests need a SimpleCov name otherwise they will overwrite coverage
64
SimpleCov.command_name "RSpecIsolatedInit"
75

sentry-ruby/spec/isolated/puma_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
22

33
require "puma"
4-
require_relative "../spec_helper"
4+
5+
# Force-load the patches so that we don't depend on require order
6+
load Pathname(__FILE__).join("../../../lib/sentry/puma.rb").realpath
57

68
# Because puma doesn't have any dependency, if Rack is not installed the entire test won't work
79
return if ENV["RACK_VERSION"] == "0"

sentry-ruby/spec/sentry/background_worker_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::BackgroundWorker do
64
let(:string_io) { StringIO.new }
75

sentry-ruby/spec/sentry/backpressure_monitor_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::BackpressureMonitor do
64
let(:string_io) { StringIO.new }
75

sentry-ruby/spec/sentry/backtrace/lines_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::Backtrace::Line do
64
before do
75
perform_basic_setup

sentry-ruby/spec/sentry/backtrace_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Backtrace do
64
let(:fixture_root) { File.join(Dir.pwd, "spec", "support") }
75
let(:fixture_file) { File.join(fixture_root, "stacktrace_test_fixture.rb") }

sentry-ruby/spec/sentry/baggage_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::Baggage do
64
let(:malformed_baggage) { "," }
75
let(:third_party_baggage) { "other-vendor-value-1=foo;bar;baz, other-vendor-value-2=foo;bar;" }

sentry-ruby/spec/sentry/breadcrumb/http_logger_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
43
require 'contexts/with_request_mock'
54

65
RSpec.describe :http_logger do

sentry-ruby/spec/sentry/breadcrumb/redis_logger_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe :redis_logger do
64
let(:redis) { Redis.new(host: REDIS_HOST) }
75

sentry-ruby/spec/sentry/breadcrumb/sentry_logger_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe "Sentry::Breadcrumbs::SentryLogger" do
64
before do
75
perform_basic_setup do |config|

sentry-ruby/spec/sentry/breadcrumb_buffer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::BreadcrumbBuffer do
64
before do
75
perform_basic_setup

sentry-ruby/spec/sentry/breadcrumb_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::Breadcrumb do
64
let(:stringio) { StringIO.new }
75

sentry-ruby/spec/sentry/client/event_sending_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Client do
64
let(:configuration) do
75
Sentry::Configuration.new.tap do |config|

sentry-ruby/spec/sentry/client_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
class ExceptionWithContext < StandardError
64
def sentry_context
75
{

sentry-ruby/spec/sentry/configuration_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Configuration do
64
describe "#capture_exception_frame_locals" do
75
it "passes/received the value to #include_local_variables" do

sentry-ruby/spec/sentry/cron/monitor_check_ins_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Cron::MonitorCheckIns do
64
before { perform_basic_setup }
75

sentry-ruby/spec/sentry/cron/monitor_config_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Cron::MonitorConfig do
64
before { perform_basic_setup }
75

sentry-ruby/spec/sentry/cron/monitor_schedule_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Cron::MonitorSchedule::Crontab do
64
let(:subject) { described_class.new('5 * * * *') }
75

sentry-ruby/spec/sentry/dsn_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::DSN do
64
subject do
75
described_class.new(

sentry-ruby/spec/sentry/envelope/item_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::Envelope::Item do
64
describe '.data_category' do
75
[

sentry-ruby/spec/sentry/event_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Event do
64
let(:configuration) do
75
Sentry::Configuration.new.tap do |config|

sentry-ruby/spec/sentry/excon_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
43
require "contexts/with_request_mock"
54
require "excon"
65

sentry-ruby/spec/sentry/graphql_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
with_graphql = begin
64
require 'graphql'
75
true

sentry-ruby/spec/sentry/hub_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Hub do
64
let(:string_io) { StringIO.new }
75
let(:logger) do
@@ -260,7 +258,6 @@
260258
end
261259
end
262260

263-
264261
it "raises error when passing a non-exception object" do
265262
expect do
266263
subject.capture_exception("String")

sentry-ruby/spec/sentry/integrable_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
43
require "sentry/integrable"
54

65
RSpec.describe Sentry::Integrable do

sentry-ruby/spec/sentry/interface_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
43
require 'sentry/interface'
54

65
class TestInterface < Sentry::Interface

sentry-ruby/spec/sentry/interfaces/request_interface_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
return unless defined?(Rack)
64

75
RSpec.describe Sentry::RequestInterface do

sentry-ruby/spec/sentry/interfaces/stacktrace_builder_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::StacktraceBuilder do
64
let(:fixture_root) { File.join(Dir.pwd, "spec", "support") }
75
let(:fixture_file) { File.join(fixture_root, "stacktrace_test_fixture.rb") }

sentry-ruby/spec/sentry/interfaces/stacktrace_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::StacktraceInterface::Frame do
64
describe "#initialize" do
75
let(:configuration) { Sentry::Configuration.new }

sentry-ruby/spec/sentry/linecache_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
43
# rubocop:disable Style/WordArray
54
RSpec.describe Sentry::LineCache do
65
describe "#get_file_context" do

sentry-ruby/spec/sentry/log_event_buffer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::LogEventBuffer do
64
subject(:log_event_buffer) { described_class.new(Sentry.configuration, client) }
75

sentry-ruby/spec/sentry/log_event_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::LogEvent do
64
let(:configuration) do
75
Sentry::Configuration.new.tap do |config|

sentry-ruby/spec/sentry/metrics/aggregator_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::Aggregator do
64
let(:string_io) { StringIO.new }
75

sentry-ruby/spec/sentry/metrics/configuration_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::Configuration do
64
describe '#before_emit=' do
75
it 'raises error when setting before_emit to anything other than callable or nil' do

sentry-ruby/spec/sentry/metrics/counter_metric_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::CounterMetric do
64
subject { described_class.new(1) }
75
before { subject.add(2) }

sentry-ruby/spec/sentry/metrics/distribution_metric_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::DistributionMetric do
64
subject { described_class.new(1) }
75
before { subject.add(2) }

sentry-ruby/spec/sentry/metrics/gauge_metric_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::GaugeMetric do
64
subject { described_class.new(0) }
75
before { 9.times { |i| subject.add(i + 1) } }

sentry-ruby/spec/sentry/metrics/local_aggregator_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::LocalAggregator do
64
let(:tags) { [['foo', 1], ['foo', 2], ['bar', 'baz']] }
75
let(:key) { [:c, 'incr', 'second', tags] }

sentry-ruby/spec/sentry/metrics/metric_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::Metric do
64
describe '#add' do
75
it 'raises not implemented error' do

sentry-ruby/spec/sentry/metrics/set_metric_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::SetMetric do
64
subject { described_class.new('foo') }
75

sentry-ruby/spec/sentry/metrics/timing_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics::Timing do
64
let(:fake_time) { Time.new(2024, 1, 2, 3, 4, 5) }
75
before { allow(Time).to receive(:now).and_return(fake_time) }

sentry-ruby/spec/sentry/metrics_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Sentry::Metrics do
64
before do
75
perform_basic_setup do |config|

sentry-ruby/spec/sentry/net/http_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
43
require 'contexts/with_request_mock'
54

65
RSpec.describe Sentry::Net::HTTP do
@@ -113,7 +112,6 @@
113112
transaction = Sentry.start_transaction
114113
Sentry.get_current_scope.set_span(transaction)
115114

116-
117115
response = http.request(request)
118116

119117
expect(response.code).to eq("200")

sentry-ruby/spec/sentry/profiler_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
53
RSpec.describe Sentry::Profiler, when: :stack_prof_installed? do
64
before do
75
perform_basic_setup do |config|

0 commit comments

Comments
 (0)