Skip to content

Commit

Permalink
Merge pull request #145 from oriolgual/patch-1
Browse files Browse the repository at this point in the history
[Fix] Oj expects indent as a Fixnum
  • Loading branch information
rwz committed Apr 14, 2014
2 parents 3b62e64 + b3db833 commit 676ae6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/multi_json/adapters/oj.rb
Expand Up @@ -17,6 +17,7 @@ def load(string, options={})

def dump(object, options={})
options.merge!(:indent => 2) if options[:pretty]
options[:indent] = options[:indent].to_i if options[:indent]
::Oj.dump(object, options)
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/oj_adapter_spec.rb
Expand Up @@ -7,4 +7,16 @@

describe MultiJson::Adapters::Oj do
it_behaves_like 'an adapter', described_class

describe '.dump' do
describe '#dump_options' do
before{ MultiJson.use :oj }
before{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }
after{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }

it 'ensures indent is a Fixnum' do
expect { MultiJson.dump(42, :indent => '')}.not_to raise_error
end
end
end
end

0 comments on commit 676ae6c

Please sign in to comment.