Skip to content

Commit dd4b688

Browse files
author
James A. Rosen
committed
Add warning when using ok_json. Closes #23
1 parent 0e72e90 commit dd4b688

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/multi_json.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def engine
2525
["json/pure", :json_pure]
2626
]
2727

28+
DEFAULT_ENGINE_WARNING = 'Warning: multi_json is using default ok_json engine. Suggested action: require and load an appropriate JSON library.'
29+
2830
# The default engine based on what you currently
2931
# have loaded and installed. First checks to see
3032
# if any engines are already loaded, then checks
@@ -42,6 +44,7 @@ def default_engine
4244
end
4345
end
4446

47+
Kernel.warn DEFAULT_ENGINE_WARNING
4548
:ok_json
4649
end
4750

spec/multi_json_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
it 'defaults to ok_json if no other json implementions are available' do
2727
MultiJson.default_engine.should == :ok_json
2828
end
29+
30+
it 'prints a warning' do
31+
Kernel.should_receive(:warn).with(/warning/i)
32+
MultiJson.default_engine
33+
end
2934
end
3035

3136
it 'defaults to the best available gem' do

0 commit comments

Comments
 (0)