Skip to content

Commit

Permalink
Fix specs after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Oct 31, 2024
1 parent d7522f9 commit 7d6edaf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
transaction.finish

expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")

expect(cache_transaction[:spans].count).to eq(1)
Expand All @@ -45,7 +45,7 @@

expect(Rails.cache.read("my_cache_key")).to eq(1)
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
Expand All @@ -64,7 +64,7 @@
transaction.finish

expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
Expand All @@ -79,7 +79,7 @@
transaction.finish

expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
Expand All @@ -95,7 +95,7 @@
transaction.finish

expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
Expand All @@ -112,7 +112,7 @@
transaction.finish

expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(2)
expect(cache_transaction[:spans][1][:op]).to eq("cache.flush")
Expand All @@ -130,7 +130,7 @@

transaction.finish
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(2)
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
Expand All @@ -152,7 +152,7 @@

transaction.finish
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
cache_transaction = transport.events.first.to_h
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.remove")
Expand Down
4 changes: 2 additions & 2 deletions sentry-rails/spec/sentry/rails/tracing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

it "does not record sensitive params" do
get "/posts?foo=bar&password=42&secret=baz"
transaction = transport.events.last.to_hash
transaction = transport.events.last.to_h

params = transaction[:spans][0][:data][:params]
expect(params["foo"]).to eq("bar")
Expand All @@ -139,7 +139,7 @@

it "records all params" do
get "/posts?foo=bar&password=42&secret=baz"
transaction = transport.events.last.to_hash
transaction = transport.events.last.to_h

params = transaction[:spans][0][:data][:params]
expect(params["foo"]).to eq("bar")
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def find_matched_event(event_message, sentry_events)
end

def dump_events(sentry_events)
sentry_events.map(&Kernel.method(:Hash)).map do |hash|
sentry_events.map(&:to_h).map do |hash|
hash.select { |k, _| [:message, :contexts, :tags, :exception].include?(k) }
end.map do |hash|
JSON.pretty_generate(hash)
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/vernier/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def active_thread_id
Thread.current.object_id
end

def to_hash
def to_h
return EMPTY_RESULT unless @started

unless @sampled
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
it "doesn't overwrite already set ip address" do
Sentry.set_user({ ip_address: "3.3.3.3" })
Sentry.get_current_scope.apply_to_event(event)
expect(event.to_hash[:user][:ip_address]).to eq("3.3.3.3")
expect(event.to_h[:user][:ip_address]).to eq("3.3.3.3")
end

context "with config.trusted_proxies = [\"2.2.2.2\"]" do
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/profiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
end

it 'returns empty' do
expect(subject.to_hash).to eq({})
expect(subject.to_h).to eq({})
end

it 'records lost event' do
Expand Down
22 changes: 11 additions & 11 deletions sentry-ruby/spec/sentry/vernier/profiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
end
end

describe "#to_hash" do
describe "#to_h" do
let (:transport) { Sentry.get_current_client.transport }


Expand All @@ -160,7 +160,7 @@
profiler.start
profiler.set_initial_sample_decision(false)

expect(profiler.to_hash).to eq({})
expect(profiler.to_h).to eq({})
end
end

Expand All @@ -169,9 +169,9 @@
profiler.set_initial_sample_decision(true)
end

describe '#to_hash' do
describe '#to_h' do
it "returns empty hash if not started" do
expect(profiler.to_hash).to eq({})
expect(profiler.to_h).to eq({})
end

context 'with single-thread profiled code' do
Expand All @@ -182,7 +182,7 @@
end

it 'has correct frames' do
frames = profiler.to_hash[:profile][:frames]
frames = profiler.to_h[:profile][:frames]

foo_frame = frames.find { |f| f[:function] =~ /foo/ }

Expand All @@ -195,7 +195,7 @@
end

it 'has correct stacks' do
profile = profiler.to_hash[:profile]
profile = profiler.to_h[:profile]
frames = profile[:frames]
stacks = profile[:stacks]

Expand All @@ -213,7 +213,7 @@
end

it 'has correct samples' do
profile = profiler.to_hash[:profile]
profile = profiler.to_h[:profile]
samples = profile[:samples]
last_elapsed = 0

Expand Down Expand Up @@ -252,7 +252,7 @@
end

it "has correct thread metadata" do
thread_metadata = profiler.to_hash[:profile][:thread_metadata]
thread_metadata = profiler.to_h[:profile][:thread_metadata]

main_thread = thread_metadata.values.find { |metadata| metadata[:name].include?("rspec") }
thread1 = thread_metadata.values.find { |metadata| metadata[:name] == "thread-bar-0" }
Expand All @@ -268,7 +268,7 @@
end

it 'has correct frames', when: { ruby_version?: [:>=, "3.3"] } do
frames = profiler.to_hash[:profile][:frames]
frames = profiler.to_h[:profile][:frames]

foo_frame = frames.find { |f| f[:function] =~ /foo/ }

Expand All @@ -281,7 +281,7 @@
end

it 'has correct stacks', when: { ruby_version?: [:>=, "3.3"] } do
profile = profiler.to_hash[:profile]
profile = profiler.to_h[:profile]
frames = profile[:frames]
stacks = profile[:stacks]

Expand All @@ -299,7 +299,7 @@
end

it 'has correct samples' do
profile = profiler.to_hash[:profile]
profile = profiler.to_h[:profile]
samples = profile[:samples]

samples.group_by { |sample| sample[:thread_id] }.each do |thread_id, thread_samples|
Expand Down

0 comments on commit 7d6edaf

Please sign in to comment.