Skip to content

Commit 3a07852

Browse files
committed
Fix specs after rebase
1 parent a8bf8ac commit 3a07852

File tree

13 files changed

+44
-42
lines changed

13 files changed

+44
-42
lines changed

sentry-rails/spec/sentry/rails/tracing/active_support_subscriber_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
transaction.finish
2424

2525
expect(transport.events.count).to eq(1)
26-
cache_transaction = transport.events.first.to_hash
26+
cache_transaction = transport.events.first.to_h
2727
expect(cache_transaction[:type]).to eq("transaction")
2828

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

4646
expect(Rails.cache.read("my_cache_key")).to eq(1)
4747
expect(transport.events.count).to eq(1)
48-
cache_transaction = transport.events.first.to_hash
48+
cache_transaction = transport.events.first.to_h
4949
expect(cache_transaction[:type]).to eq("transaction")
5050
expect(cache_transaction[:spans].count).to eq(1)
5151
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
@@ -64,7 +64,7 @@
6464
transaction.finish
6565

6666
expect(transport.events.count).to eq(1)
67-
cache_transaction = transport.events.first.to_hash
67+
cache_transaction = transport.events.first.to_h
6868
expect(cache_transaction[:type]).to eq("transaction")
6969
expect(cache_transaction[:spans].count).to eq(1)
7070
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
@@ -79,7 +79,7 @@
7979
transaction.finish
8080

8181
expect(transport.events.count).to eq(1)
82-
cache_transaction = transport.events.first.to_hash
82+
cache_transaction = transport.events.first.to_h
8383
expect(cache_transaction[:type]).to eq("transaction")
8484
expect(cache_transaction[:spans].count).to eq(1)
8585
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
@@ -95,7 +95,7 @@
9595
transaction.finish
9696

9797
expect(transport.events.count).to eq(1)
98-
cache_transaction = transport.events.first.to_hash
98+
cache_transaction = transport.events.first.to_h
9999
expect(cache_transaction[:type]).to eq("transaction")
100100
expect(cache_transaction[:spans].count).to eq(1)
101101
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
@@ -112,7 +112,7 @@
112112
transaction.finish
113113

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

131131
transaction.finish
132132
expect(transport.events.count).to eq(1)
133-
cache_transaction = transport.events.first.to_hash
133+
cache_transaction = transport.events.first.to_h
134134
expect(cache_transaction[:type]).to eq("transaction")
135135
expect(cache_transaction[:spans].count).to eq(2)
136136
expect(cache_transaction[:spans][0][:op]).to eq("cache.get")
@@ -152,7 +152,7 @@
152152

153153
transaction.finish
154154
expect(transport.events.count).to eq(1)
155-
cache_transaction = transport.events.first.to_hash
155+
cache_transaction = transport.events.first.to_h
156156
expect(cache_transaction[:type]).to eq("transaction")
157157
expect(cache_transaction[:spans].count).to eq(1)
158158
expect(cache_transaction[:spans][0][:op]).to eq("cache.remove")

sentry-rails/spec/sentry/rails/tracing_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

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

128128
params = transaction[:spans][0][:data][:params]
129129
expect(params["foo"]).to eq("bar")
@@ -145,7 +145,7 @@
145145

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

150150
params = transaction[:spans][0][:data][:params]
151151
expect(params["foo"]).to eq("bar")

sentry-ruby/lib/sentry/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ def send_logs(log_events)
286286
processed_log_event = configuration.before_send_log.call(log_event)
287287

288288
if processed_log_event
289-
envelope_items << processed_log_event.to_hash
289+
envelope_items << processed_log_event.to_h
290290
else
291291
discarded_count += 1
292292
end
293293
end
294294

295295
envelope_items
296296
else
297-
envelope_items = log_events.map(&:to_hash)
297+
envelope_items = log_events.map(&:to_h)
298298
end
299299

300300
envelope.add_item(

sentry-ruby/lib/sentry/log_event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def initialize(configuration: Sentry.configuration, **options)
8585
@contexts = {}
8686
end
8787

88-
def to_hash
88+
def to_h
8989
SERIALIZEABLE_ATTRIBUTES.each_with_object({}) do |name, memo|
9090
memo[name] = serialize(name)
9191
end

sentry-ruby/lib/sentry/rspec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def find_matched_event(event_message, sentry_events)
7070
end
7171

7272
def dump_events(sentry_events)
73-
sentry_events.map(&Kernel.method(:Hash)).map do |hash|
73+
sentry_events.map(&:to_h).map do |hash|
7474
hash.select { |k, _| [:message, :contexts, :tags, :exception].include?(k) }
7575
end.map do |hash|
7676
JSON.pretty_generate(hash)

sentry-ruby/lib/sentry/vernier/profiler.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def active_thread_id
9090
Thread.current.object_id
9191
end
9292

93-
def to_hash
93+
def to_h
94+
return EMPTY_RESULT unless @started
95+
9496
unless @sampled
9597
record_lost_event(:sample_rate)
9698
return EMPTY_RESULT

sentry-ruby/spec/sentry/breadcrumb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
end
108108

109109
it "rescues data serialization issue for extremely nested data and ditch the data" do
110-
result = very_deep_crumb.to_hash
110+
result = very_deep_crumb.to_h
111111

112112
expect(result[:category]).to eq("cow")
113113
expect(result[:message]).to eq("I cause too much recursion")

sentry-ruby/spec/sentry/event_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
it "doesn't overwrite already set ip address" do
145145
Sentry.set_user({ ip_address: "3.3.3.3" })
146146
Sentry.get_current_scope.apply_to_event(event)
147-
expect(event.to_hash[:user][:ip_address]).to eq("3.3.3.3")
147+
expect(event.to_h[:user][:ip_address]).to eq("3.3.3.3")
148148
end
149149

150150
context "with config.trusted_proxies = [\"2.2.2.2\"]" do

sentry-ruby/spec/sentry/log_event_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
end
3838
end
3939

40-
describe "#to_hash" do
40+
describe "#to_h" do
4141
before do
4242
configuration.release = "1.2.3"
4343
configuration.environment = "test"
@@ -54,7 +54,7 @@
5454
attributes: attributes
5555
)
5656

57-
hash = event.to_hash
57+
hash = event.to_h
5858

5959
expect(hash[:body]).to eq("Hello John, today is Monday")
6060

@@ -71,7 +71,7 @@
7171
body: "User John has logged in!"
7272
)
7373

74-
hash = event.to_hash
74+
hash = event.to_h
7575

7676
expect(hash[:level]).to eq("info")
7777
expect(hash[:body]).to eq("User John has logged in!")
@@ -91,7 +91,7 @@
9191
body: "User John has logged in!"
9292
)
9393

94-
hash = event.to_hash
94+
hash = event.to_h
9595

9696
expect(hash[:attributes]).not_to have_key("sentry.message.template")
9797
end
@@ -103,7 +103,7 @@
103103
body: "Hello %{name}, today is %{day}"
104104
)
105105

106-
hash = event.to_hash
106+
hash = event.to_h
107107

108108
expect(hash[:attributes]).not_to have_key("sentry.message.template")
109109
expect(hash[:attributes]).not_to have_key("sentry.message.parameter.name")
@@ -122,7 +122,7 @@
122122
attributes: attributes
123123
)
124124

125-
hash = event.to_hash
125+
hash = event.to_h
126126

127127
expect(hash[:attributes]).to have_key("sentry.message.template")
128128
expect(hash[:attributes]["sentry.message.template"]).to eq({ value: "User %s has logged in!", type: "string" })
@@ -144,7 +144,7 @@
144144
attributes: attributes
145145
)
146146

147-
hash = event.to_hash
147+
hash = event.to_h
148148

149149
expect(hash[:attributes]["string_attr"]).to eq({ value: "string value", type: "string" })
150150
expect(hash[:attributes]["integer_attr"]).to eq({ value: 42, type: "integer" })
@@ -166,7 +166,7 @@
166166
user: user
167167
)
168168

169-
hash = event.to_hash
169+
hash = event.to_h
170170

171171
expect(hash[:attributes]["user.id"]).to eq(123)
172172
expect(hash[:attributes]["user.name"]).to eq("john_doe")

sentry-ruby/spec/sentry/profiler_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
end
180180

181181
it 'returns empty' do
182-
expect(subject.to_hash).to eq({})
182+
expect(subject.to_h).to eq({})
183183
end
184184

185185
it 'records lost event' do

0 commit comments

Comments
 (0)