Skip to content

Commit 3fff872

Browse files
authored
Merge pull request #69 from Sija/develop
v1.7
2 parents 16d04fa + 11d5ff9 commit 3fff872

31 files changed

+230
-203
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ crystal:
44
- latest
55
- nightly
66

7-
matrix:
7+
jobs:
88
allow_failures:
99
- crystal: nightly
1010

@@ -16,5 +16,7 @@ script:
1616
- crystal spec --no-debug
1717
- crystal spec --release
1818
- crystal spec --release --no-debug
19+
- shards build crash_handler
20+
- shards build crash_handler --release
1921
- crystal tool format --check
20-
- bin/ameba src
22+
- bin/ameba

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</h1>
88

99
<p align="center">
10-
<a href="https://travis-ci.org/Sija/raven.cr"><img src="https://travis-ci.org/Sija/raven.cr.svg?branch=master" alt="Build Status" /></a>
10+
<a href="https://travis-ci.com/Sija/raven.cr"><img src="https://travis-ci.com/Sija/raven.cr.svg?branch=master" alt="Build Status" /></a>
1111
<a href="https://www.codacy.com/app/Sija/raven.cr"><img src="https://api.codacy.com/project/badge/Grade/32cb8814a14d4a6cbe39d6768142c59b" alt="Codacy Badge" /></a>
1212
<a href="https://github.com/Sija/raven.cr/releases"><img src="https://img.shields.io/github/release/Sija/raven.cr.svg" alt="Releases" /></a>
1313
<a href="https://github.com/Sija/raven.cr/blob/master/LICENSE"><img src="https://img.shields.io/github/license/Sija/raven.cr.svg" alt="License" /></a>

shard.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: raven
2-
version: 1.6.0
2+
version: 1.7.0
33

44
authors:
55
- Sijawusz Pur Rahnama <[email protected]>
@@ -15,12 +15,12 @@ development_dependencies:
1515
version: ~> 0.4.0
1616
ameba:
1717
github: crystal-ameba/ameba
18-
version: ~> 0.11.0
18+
version: ~> 0.13.0
1919

2020
targets:
2121
crash_handler:
2222
main: src/crash_handler.cr
2323

24-
crystal: 0.32.0
24+
crystal: 0.35.0
2525

2626
license: MIT

spec/raven/backtrace_line_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "../spec_helper"
22

3-
def with_line(path = "#{__DIR__}/foo.cr", method = "foo_bar?")
3+
private def with_line(path = "#{__DIR__}/foo.cr", method = "foo_bar?")
44
line = "#{path}:1:7 in '#{method}'"
55
yield Raven::Backtrace::Line.parse(line)
66
end

spec/raven/breadcrumb_buffer_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "../spec_helper"
22

3-
def with_breadcrumb_buffer
3+
private def with_breadcrumb_buffer
44
breadcrumbs = Raven::BreadcrumbBuffer.new(10)
55
yield breadcrumbs
66
end

spec/raven/client_spec.cr

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "../spec_helper"
22

3-
class ClientTest < Raven::Client
3+
private class ClientTest < Raven::Client
44
def generate_auth_header
55
super
66
end
@@ -10,12 +10,7 @@ class ClientTest < Raven::Client
1010
end
1111
end
1212

13-
def build_configuration
14-
Raven::Configuration.new
15-
.tap(&.dsn = "dummy://12345:[email protected]:3000/sentry/42")
16-
end
17-
18-
def with_client
13+
private def with_client
1914
yield ClientTest.new(build_configuration)
2015
end
2116

@@ -96,7 +91,7 @@ describe Raven::Client do
9691
last_event[:options].should eq({:content_type => "application/octet-stream"})
9792
last_event[:data].should be_a(String)
9893
io = IO::Memory.new(last_event[:data].as(String))
99-
Gzip::Reader.open(io) do |gzip|
94+
Compress::Gzip::Reader.open(io) do |gzip|
10095
data = JSON.parse(gzip.gets_to_end)
10196
data.as_h?.should_not be_nil
10297
data["event_id"].should eq(event.id)

spec/raven/client_state_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "../spec_helper"
22
require "timecop"
33

4-
def with_client_state
4+
private def with_client_state
55
yield Raven::Client::State.new
66
end
77

spec/raven/configuration_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ private class RandomSampleFail < Random::PCG32
1212
end
1313
end
1414

15-
def with_configuration
15+
private def with_configuration
1616
with_clean_env do
1717
yield Raven::Configuration.new
1818
end
1919
end
2020

21-
def with_configuration_with_dsn
21+
private def with_configuration_with_dsn
2222
with_configuration do |configuration|
2323
configuration.dsn = "http://12345:[email protected]:3000/sentry/42"
2424
yield configuration

spec/raven/event_spec.cr

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Raven::Test
44
class Exception < ::Exception; end
55
end
66

7-
def with_event(clear = true, **opts)
7+
private def with_event(clear = true, **opts)
88
if clear
99
Raven::Context.clear!
1010
Raven::BreadcrumbBuffer.clear!
@@ -13,18 +13,24 @@ def with_event(clear = true, **opts)
1313
yield event
1414
end
1515

16-
def with_event_hash(**opts)
16+
private def with_event_hash(**opts)
1717
with_event(**opts) do |event|
1818
yield event.to_hash
1919
end
2020
end
2121

22-
def exception_value_from_event_hash(hash, index)
22+
private def exception_value_from_event_hash(hash, index)
2323
ex_values = hash.to_any_json[:exception, :values].as(Array)
2424
ex_values[index].as(Hash)
2525
end
2626

2727
describe Raven::Event do
28+
around_each do |example|
29+
Raven::Context.clear!
30+
example.run
31+
Raven::Context.clear!
32+
end
33+
2834
context "with fully implemented event" do
2935
opts = {
3036
message: "test",
@@ -190,8 +196,6 @@ describe Raven::Event do
190196
{% for key in %i(user extra tags) %}
191197
context "with {{key.id}} context specified" do
192198
it "prioritizes event context" do
193-
Raven::Context.clear!
194-
195199
Raven.{{key.id}}_context({
196200
"context_event_key" => "context_value",
197201
"context_key" => "context_value",

spec/raven/instance_spec.cr

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,7 @@ private class InstanceTest < Raven::Instance
1616
end
1717
end
1818

19-
private class LoggerTest < Raven::Logger
20-
getter infos = [] of String
21-
22-
def info(message, *args)
23-
super.tap do
24-
@infos << message
25-
end
26-
end
27-
end
28-
29-
def build_configuration
30-
Raven::Configuration.new.tap do |config|
31-
config.dsn = "dummy://12345:[email protected]:3000/sentry/42"
32-
config.logger = LoggerTest.new(nil)
33-
end
34-
end
35-
36-
def with_instance(context = nil)
19+
private def with_instance(context = nil)
3720
yield InstanceTest.new(context, build_configuration)
3821
end
3922

@@ -214,17 +197,21 @@ describe Raven::Instance do
214197
with_instance do |instance|
215198
instance.configuration.silence_ready = false
216199

217-
instance.report_status
218-
instance.logger.as(LoggerTest).infos.should contain(ready_message)
200+
Log.capture do |logs|
201+
instance.report_status
202+
logs.check(:info, ready_message)
203+
end
219204
end
220205
end
221206

222207
it "logs nothing if 'silence_ready' option is true" do
223208
with_instance do |instance|
224209
instance.configuration.silence_ready = true
225210

226-
instance.report_status
227-
instance.logger.as(LoggerTest).infos.should_not contain(ready_message)
211+
Log.capture do |logs|
212+
instance.report_status
213+
logs.empty
214+
end
228215
end
229216
end
230217

@@ -233,8 +220,10 @@ describe Raven::Instance do
233220
instance.configuration.silence_ready = false
234221
instance.configuration.dsn = "dummy://foo"
235222

236-
instance.report_status
237-
instance.logger.as(LoggerTest).infos.first.should contain(not_ready_message)
223+
Log.capture do |logs|
224+
instance.report_status
225+
logs.check(:info, /#{not_ready_message}/)
226+
end
238227
end
239228
end
240229

@@ -243,10 +232,12 @@ describe Raven::Instance do
243232
instance.configuration.silence_ready = false
244233
instance.configuration.environments = %w(production)
245234

246-
instance.report_status
247-
instance.logger.as(LoggerTest).infos.should contain(
248-
"#{not_ready_message}: Not configured to send/capture in environment 'default'"
249-
)
235+
Log.capture do |logs|
236+
instance.report_status
237+
logs.check(:info,
238+
"#{not_ready_message}: Not configured to send/capture in environment 'default'"
239+
)
240+
end
250241
end
251242
end
252243
end
@@ -255,7 +246,9 @@ describe Raven::Instance do
255246
it "sends the result of Event.capture" do
256247
with_instance do |instance|
257248
event = instance.capture("Test message")
258-
instance.last_sent_event.try(&.id).should eq(event.as?(Raven::Event).try(&.id))
249+
250+
last_sent_event = instance.last_sent_event.should_not be_nil
251+
last_sent_event.id.should eq(event.as(Raven::Event).id)
259252
end
260253
end
261254
end

0 commit comments

Comments
 (0)