This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coerce context and event attributes (#45)
* Coerce context and event attributes * Coerce System.pid * More tests
- Loading branch information
1 parent
a4445cd
commit 873e350
Showing
12 changed files
with
74 additions
and
5 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
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,13 @@ | ||
module Timber | ||
# @private | ||
module Object | ||
# @private | ||
def self.try(object, method) | ||
if object == nil | ||
nil | ||
else | ||
object.send(method) rescue object | ||
end | ||
end | ||
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,11 @@ | ||
require "spec_helper" | ||
|
||
describe Timber::Contexts::Custom, :rails_23 => true do | ||
describe ".as_json" do | ||
it "should coerce type into an atom" do | ||
custom_context = described_class.new(:type => "my type", :data => {:key => "value"}) | ||
json = custom_context.as_json() | ||
expect(json.keys.first).to eq(:"my type") | ||
end | ||
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,11 @@ | ||
require "spec_helper" | ||
|
||
describe Timber::Contexts::Organization, :rails_23 => true do | ||
describe ".as_json" do | ||
it "should coerce id into a string" do | ||
user_context = described_class.new(:id => 1) | ||
json = user_context.as_json() | ||
expect(json[:id]).to eq("1") | ||
end | ||
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,11 @@ | ||
require "spec_helper" | ||
|
||
describe Timber::Contexts::System, :rails_23 => true do | ||
describe ".as_json" do | ||
it "should coerce pid into an string" do | ||
custom_context = described_class.new(:pid => 1) | ||
json = custom_context.as_json() | ||
expect(json[:pid]).to eq("1") | ||
end | ||
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,11 @@ | ||
require "spec_helper" | ||
|
||
describe Timber::Contexts::User, :rails_23 => true do | ||
describe ".as_json" do | ||
it "should coerce id into a string" do | ||
user_context = described_class.new(:id => 1) | ||
json = user_context.as_json() | ||
expect(json[:id]).to eq("1") | ||
end | ||
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,11 @@ | ||
require "spec_helper" | ||
|
||
describe Timber::Events::Custom, :rails_23 => true do | ||
describe ".to_hash" do | ||
it "should coerce type into an atom" do | ||
custom_context = described_class.new(:type => "my type", :message => "hello", :data => {:key => "value"}) | ||
hash = custom_context.to_hash() | ||
expect(hash.keys.first).to eq(:"my type") | ||
end | ||
end | ||
end |