Skip to content

Commit

Permalink
set a default root_directory so source code highlighting works out of…
Browse files Browse the repository at this point in the history
… the box
  • Loading branch information
grosser committed Feb 22, 2017
1 parent 8c8344e commit 0b43f2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions lib/airbrake-ruby/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def initialize(user_config = {})
self.blacklist_keys = []
self.whitelist_keys = []

self.root_directory = (
(defined?(Bundler) && Bundler.root) ||
File.expand_path(Dir.pwd)
)

merge(user_config)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/airbrake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# rubocop:disable Metrics/LineLength
expected_body = %r|
{"errors":\[{"type":"RuntimeError","message":"bingo","backtrace":\[
{"file":"[\w/\-\.]+spec/airbrake_spec.rb","line":\d+,"function":"[\w/\s\(\)<>]+"},
{"file":"\[PROJECT_ROOT\]/spec/airbrake_spec.rb","line":\d+,"function":"[\w/\s\(\)<>]+"},
{"file":"\[GEM_ROOT\]/gems/rspec-core-.+/.+","line":\d+,"function":"[\w/\s\(\)<>]+"}
|x
# rubocop:enable Metrics/LineLength
Expand Down Expand Up @@ -167,11 +167,11 @@
filter_chain = notifier.instance_variable_get(:@filter_chain)
filters = filter_chain.instance_variable_get(:@filters)

expect(filters.size).to eq(2)
expect(filters.size).to eq(3)

described_class.add_filter {}

expect(filters.size).to eq(3)
expect(filters.size).to eq(4)
expect(filters.last).to be_a(Proc)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
expect(config.queue_size).to eq(100)
end

it "doesn't set the default root_directory" do
expect(config.root_directory).to be_nil
it "sets the default root_directory" do
expect(config.root_directory).to eq Bundler.root
end

it "doesn't set the default environment" do
Expand Down

0 comments on commit 0b43f2c

Please sign in to comment.