From 27b4dc1b69b584529a894a0bb20a2e8852f71168 Mon Sep 17 00:00:00 2001 From: Ryan Bone Date: Thu, 4 Apr 2019 10:29:28 -0400 Subject: [PATCH] Allow disabling hashie log when initializing client This will save on log space and noise by preventing these kinds of warnings from being dumped into the Rails log. ``` You are setting a key that conflicts with a built-in method Hashie::Mash#method defined in Kernel. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. ``` --- lib/cover_my_meds/client.rb | 3 +++ spec/client_spec.rb | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/cover_my_meds/client.rb b/lib/cover_my_meds/client.rb index b5ecce5..4055708 100644 --- a/lib/cover_my_meds/client.rb +++ b/lib/cover_my_meds/client.rb @@ -40,5 +40,8 @@ def default_host @default_host ||= "https://api.covermymeds.com" end + def disable_hashie_log + Hashie.logger = Logger.new('/dev/null') + end end end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 7091372..4d99fbf 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -49,4 +49,12 @@ class CoverMyMeds::Client client = CoverMyMeds::Client.new(username) expect(client.default_host).to eq("https://api.covermymeds.com") end + + describe '#disable_hashie_log' do + it 'sets the Hashie logger' do + client = CoverMyMeds::Client.new(username) + client.disable_hashie_log + expect(Hashie.logger.instance_variable_get(:@logdev).filename).to eq('/dev/null') + end + end end