diff --git a/lib/rollbar/lazy_store.rb b/lib/rollbar/lazy_store.rb index 0fc1e8da..9022696a 100644 --- a/lib/rollbar/lazy_store.rb +++ b/lib/rollbar/lazy_store.rb @@ -41,8 +41,6 @@ def []=(key, value) raw[key] = value loaded_data.delete(key) - - value end def data @@ -76,8 +74,8 @@ def method_missing(method_sym, *args, &block) super end - def respond_to?(method_sym) - super || raw.respond_to?(method_sym) + def respond_to_missing?(method_sym, include_all) + raw.respond_to?(method_sym, include_all) end end end diff --git a/spec/rollbar/lazy_store_spec.rb b/spec/rollbar/lazy_store_spec.rb index 1ab80f61..644523a0 100644 --- a/spec/rollbar/lazy_store_spec.rb +++ b/spec/rollbar/lazy_store_spec.rb @@ -95,4 +95,19 @@ expect(new_scope.raw).to be_eql(subject.raw) end end + + describe '#respond_to_missing?' do + it 'forwards methods existing on :raw to :raw' do + expect(subject.respond_to?(:store)).to be(true) + expect { subject.method(:store) }.not_to raise_error + + expect(data).to receive(:store).with(:foo, :bar) + subject.store(:foo, :bar) + end + + it 'does not have methods that do not exist on raw' do + expect(subject.respond_to?(:baz)).to be(false) + expect { subject.baz }.to raise_error(NoMethodError) + end + end end