From 5dd061c3406aa84e5cafd489a5c77e550b00d122 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Sun, 12 Apr 2020 15:03:44 +0800 Subject: config: return `nil` on unknown option instead of raising Returning `nil` on unknown option was default behaviour for Pry v0.12.x. In e5556a2be8627ec3fe594c738f10422d5a1f5d43 I changed that but I am not sure if it was intentional. This breaks plugins such as pry-theme (https://github.com/kyrylo/pry-theme/issues/59). Returning `nil` makes more sense, because we can write code like this: ``` Pry.config.foo ||= 123 ``` ...whereas as of now this is no longer possible and you would need to use `respond_to?` to achieve the same effect. --- spec/config_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/config_spec.rb b/spec/config_spec.rb index db91f7cb..f1cf5ea6 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -150,8 +150,8 @@ RSpec.describe Pry::Config do end context "when invoked method is not an option" do - it "raises NoMethodError" do - expect { subject.foo }.to raise_error(NoMethodError) + it "returns nil" do + expect(subject.foo).to be_nil end end -- cgit v1.2.1