summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBobby McDonald <BobbyMcWho@users.noreply.github.com>2019-10-14 14:14:47 -0400
committerDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2019-10-14 14:14:47 -0400
commit1a30427c9db1bdf974530aeddf90b305a3a621a5 (patch)
tree7dde72202b0fbfdd250113aa119239c322bac107 /spec
parentca3604516b5725b30a290482c219ca55fca5de49 (diff)
downloadhashie-1a30427c9db1bdf974530aeddf90b305a3a621a5.tar.gz
Allow mash error silencing (#488)
Diffstat (limited to 'spec')
-rw-r--r--spec/hashie/mash_spec.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb
index e2a178c..77a1c6b 100644
--- a/spec/hashie/mash_spec.rb
+++ b/spec/hashie/mash_spec.rb
@@ -160,7 +160,9 @@ describe Hashie::Mash do
end
it 'cannot disable logging on the base Mash' do
- expect { Hashie::Mash.disable_warnings }.to raise_error(Hashie::Mash::CannotDisableMashWarnings)
+ expected_error = Hashie::Extensions::KeyConflictWarning::CannotDisableMashWarnings
+
+ expect { Hashie::Mash.disable_warnings }.to raise_error(expected_error)
end
it 'carries over the disable for warnings on grandchild classes' do
@@ -200,7 +202,7 @@ describe Hashie::Mash do
grandchild_class.new('address' => { 'zip' => '90210' }, 'merge' => true)
- expect(grandchild_class.disable_warnings_blacklist).to eq(%i[zip merge])
+ expect(grandchild_class.disabled_warnings).to eq(%i[zip merge])
expect(logger_output).to be_blank
end
@@ -213,7 +215,7 @@ describe Hashie::Mash do
disable_warnings :cycle
end
- expect(child_class.disable_warnings_blacklist).to eq(%i[zip merge cycle])
+ expect(child_class.disabled_warnings).to eq(%i[zip merge cycle])
end
end
@@ -226,7 +228,7 @@ describe Hashie::Mash do
child_class.new('address' => { 'zip' => '90210' }, 'merge' => true, 'cycle' => 'bi')
- expect(child_class.disable_warnings_blacklist).to eq([])
+ expect(child_class.disabled_warnings).to eq([])
expect(logger_output).to be_blank
end
end
@@ -962,6 +964,19 @@ describe Hashie::Mash do
end
end
+ describe '.quiet' do
+ it 'returns a subclass of the calling class' do
+ expect(Hashie::Mash.quiet.new).to be_a(Hashie::Mash)
+ end
+
+ it 'memoizes and returns classes' do
+ call_one = Hashie::Mash.quiet
+ call_two = Hashie::Mash.quiet
+ expect(Hashie::Mash.instance_variable_get('@memoized_classes').count).to eq(1)
+ expect(call_one).to eq(call_two)
+ end
+ end
+
with_minimum_ruby('2.3.0') do
describe '#dig' do
subject { described_class.new(a: { b: 1 }) }