-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
38 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Lamian::SidekiqRavenMiddleware, :cool_loggers do | ||
it "call Raven.extra_context with proper lamian_log" do | ||
expect(Raven).to receive(:extra_context).with(lamian_log: "some log\n") | ||
|
||
it "calls Raven.extra_context and adds Lamian.run" do | ||
middleware_call = proc do | ||
Lamian::SidekiqRavenMiddleware.new.call do | ||
generic_logger.info "some log" | ||
raise "some error" | ||
end | ||
end | ||
|
||
expect(Raven.extra_context).not_to have_key(:lamian_log) | ||
expect(middleware_call).to raise_error(RuntimeError, "some error") | ||
expect(Raven.extra_context[:lamian_log]).to eq("some log\n") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
shared_context "cool loggers", :cool_loggers do | ||
let(:generic_logger_buffer) { StringIO.new } | ||
let(:generic_logger) { ::Logger.new(generic_logger_buffer) } | ||
|
||
let(:cool_formatter) do | ||
-> (_severity, _date, _progname, message) { "#{message}\n" } | ||
end | ||
|
||
before("extend generic_logger") { Lamian.extend_logger(generic_logger) } | ||
|
||
before("stub formatter") do | ||
allow(Lamian.config).to receive(:formatter).and_return(cool_formatter) | ||
generic_logger.formatter = cool_formatter | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "raven" | ||
require "raven/transports/dummy" | ||
|
||
Raven::Context.prepend(Lamian::RavenContextExtension) | ||
|
||
Raven.configure do |config| | ||
config.dsn = "dummy://public@example.com/project-id" | ||
config.encoding = "json" | ||
config.logger = Logger.new(nil) | ||
end |