Skip to content

Commit

Permalink
Fix Rollbar::JSON for MultiJson <= 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon de Andres committed Oct 26, 2015
1 parent d2b1f33 commit 06c1c74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/rollbar/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def find_options_module
#
# In this method we just get the last module name.
def multi_json_adapter_module_name
MultiJson.current_adapter.name[/^MultiJson::Adapters::(.*)$/, 1]
detect_multi_json_adapter.name[/^MultiJson::Adapters::(.*)$/, 1]
end
end
end
Expand Down
19 changes: 8 additions & 11 deletions spec/rollbar/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ module MissingCustomOptions
end
end

describe '.detect_multi_json_adapter' do

end

describe '.adapter_options' do
it 'calls .options in adapter module' do
expect(described_class.options_module).to receive(:options)
Expand All @@ -88,25 +84,26 @@ module MissingCustomOptions
end

describe '.options_module' do
before { described_class.options_module = nil }
before do
described_class.options_module = nil
allow(MultiJson).to receive(:current_adapter).and_return(multi_json_module)
end

context 'with a defined rollbar adapter' do
let(:multi_json_module) { MultiJson::Adapters::MockAdapter }
let(:expected_adapter) { Rollbar::JSON::MockAdapter }

it 'returns the correct options' do
MultiJson.with_adapter(MultiJson::Adapters::MockAdapter) do
expect(described_class.options_module).to be(expected_adapter)
end
expect(described_class.options_module).to be(expected_adapter)
end
end

context 'without a defined rollbar adapter' do
let(:multi_json_module) { MultiJson::Adapters::MissingCustomOptions }
let(:expected_adapter) { Rollbar::JSON::Default }

it 'returns the correct options' do
MultiJson.with_adapter(MultiJson::Adapters::MissingCustomOptions) do
expect(described_class.options_module).to be(expected_adapter)
end
expect(described_class.options_module).to be(expected_adapter)
end
end
end
Expand Down

0 comments on commit 06c1c74

Please sign in to comment.