diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-03-25 02:40:05 +0200 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-05-02 00:10:37 +0300 |
commit | e5556a2be8627ec3fe594c738f10422d5a1f5d43 (patch) | |
tree | a1758a1f39915a4eb076793a36d485cb7145d638 /spec | |
parent | 03afca9eafe4f2981edad1cfe4346a643fb64d72 (diff) | |
download | pry-e5556a2be8627ec3fe594c738f10422d5a1f5d43.tar.gz |
Refactor Config
Fixes #1843 (Rework the Pry config)
There are a few breaking changes. They are mostly minor, so I decided not to
indroduce deprecations because it will considerable slow things down.
Key changes:
* `Pry.lazy` was replaced with `Pry::Configuration::LazyValue`
The config accepts three values now `LazyValue`, `MemoizedValue` and simply
`Value`. The main difference is that:
- `Value` is any value, including procs (so that an option returns a raw
proc)
- `LazyValue` is a proc that is call on every invocation of an option
- `MemoizedValue` is a value that is called only once (and then the option
always returns the return value of the )
* `Pry.config.history` was a meta-option that held suboptions. However, the new
config doesn't permit that (unless you know what you do)
Instead, we introduce a few options. For example:
- `Pry.config.history.histignore` becomes `Pry.config.history_ignorelist`
- `Pry.config.history.file` becomes `Pry.config.history_file`
- and so on
This was done so we can simplify configuration merging. Inlining option makes
configuration implementation simpler, without losing much. The rule is that
you want to keep your options under your prefix (if you are a
plugin). Therefore, say, `Pry.config.pry_rescue.*` should be
`Pry.config.pry_rescue_*` if you need merging.
The rest should behave in a similar fashion (and I rely heavily on our test
suite to claim so).
Diffstat (limited to 'spec')
-rw-r--r-- | spec/command_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/edit_spec.rb | 14 | ||||
-rw-r--r-- | spec/commands/hist_spec.rb | 8 | ||||
-rw-r--r-- | spec/commands/show_doc_spec.rb | 12 | ||||
-rw-r--r-- | spec/config/attributable_spec.rb | 27 | ||||
-rw-r--r-- | spec/config/behavior_spec.rb | 21 | ||||
-rw-r--r-- | spec/config/lazy_value_spec.rb | 9 | ||||
-rw-r--r-- | spec/config/memoized_value_spec.rb | 9 | ||||
-rw-r--r-- | spec/config/value_spec.rb | 37 | ||||
-rw-r--r-- | spec/config_spec.rb | 345 | ||||
-rw-r--r-- | spec/history_spec.rb | 18 | ||||
-rw-r--r-- | spec/prompt_spec.rb | 2 | ||||
-rw-r--r-- | spec/pry_defaults_spec.rb | 4 | ||||
-rw-r--r-- | spec/pry_output_spec.rb | 2 | ||||
-rw-r--r-- | spec/pry_repl_spec.rb | 2 |
15 files changed, 207 insertions, 305 deletions
diff --git a/spec/command_spec.rb b/spec/command_spec.rb index b01cff07..56ee27b3 100644 --- a/spec/command_spec.rb +++ b/spec/command_spec.rb @@ -480,7 +480,7 @@ RSpec.describe Pry::Command do subject { Class.new(described_class).new(pry_instance: Pry.new) } - it "returns a state hash" do + it "returns a state object" do expect(subject.state).to be_an(OpenStruct) end diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb index 114906f6..cc741053 100644 --- a/spec/commands/edit_spec.rb +++ b/spec/commands/edit_spec.rb @@ -195,7 +195,7 @@ describe "edit" do end it "should reload the file" do - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') { |f| f << "FOO = 'BAR'" } nil } @@ -244,7 +244,7 @@ describe "edit" do describe "with --patch" do # Original source code must be untouched. it "should apply changes only in memory (monkey patching)" do - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') { |f| f << "FOO3 = 'PIYO'" } @patched_def = File.open(file, 'r').read nil @@ -265,7 +265,7 @@ describe "edit" do describe "with --ex NUM" do before do - Pry.config.editor = proc do |file, line| + @t.pry.config.editor = proc do |file, line| @__ex_file__ = file @__ex_line__ = line nil @@ -341,7 +341,7 @@ describe "edit" do end it "should evaluate the expression" do - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') { |f| f << "'FOO'\n" } nil } @@ -350,7 +350,7 @@ describe "edit" do end it "should ignore -n for tempfiles" do - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') { |f| f << "'FOO'\n" } nil } @@ -359,7 +359,7 @@ describe "edit" do end it "should not evaluate a file with -n" do - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') { |f| f << "'FOO'\n" } nil } @@ -374,7 +374,7 @@ describe "edit" do it "should write the evaluated command to history" do quote = 'history repeats itself, first as tradegy...' - Pry.config.editor = lambda { |file, _line| + @t.pry.config.editor = lambda { |file, _line| File.open(file, 'w') do |f| f << quote end diff --git a/spec/commands/hist_spec.rb b/spec/commands/hist_spec.rb index 29315cba..558b4f99 100644 --- a/spec/commands/hist_spec.rb +++ b/spec/commands/hist_spec.rb @@ -176,13 +176,13 @@ describe "hist" do describe "sessions" do before do - @old_file = Pry.config.history.file - Pry.config.history.file = File.expand_path('spec/fixtures/pry_history') + @old_file = Pry.config.history_file + Pry.config.history_file = File.expand_path('spec/fixtures/pry_history') @hist.load end after do - Pry.config.history.file = @old_file + Pry.config.history_file = @old_file end it "displays history only for current session" do @@ -202,7 +202,7 @@ describe "hist" do end it "should not display histignore words in history" do - Pry.config.history.histignore = [ + Pry.config.history_ignorelist = [ "well", "hello", "beautiful", diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb index 82e6b208..e0bba4da 100644 --- a/spec/commands/show_doc_spec.rb +++ b/spec/commands/show_doc_spec.rb @@ -178,14 +178,10 @@ describe "show-doc" do def decolumnize(output); end end - begin - t = pry_tester(binding) - Pry.config.color = true - expect(t.eval("show-doc _c#decolumnize")).to match(/ls -l \$HOME/) - expect(t.eval("show-doc _c#decolumnize")).not_to match(/`ls -l \$HOME`/) - ensure - Pry.config.color = false - end + t = pry_tester(binding) + t.pry.config.color = true + expect(t.eval("show-doc _c#decolumnize")).to match(/ls -l \$HOME/) + expect(t.eval("show-doc _c#decolumnize")).not_to match(/`ls -l \$HOME`/) end end diff --git a/spec/config/attributable_spec.rb b/spec/config/attributable_spec.rb new file mode 100644 index 00000000..c0c2b167 --- /dev/null +++ b/spec/config/attributable_spec.rb @@ -0,0 +1,27 @@ +RSpec.describe Pry::Config::Attributable do + subject { klass.new } + + describe "#attribute" do + let(:klass) do + Class.new do + extend Pry::Config::Attributable + attribute :foo + end + end + + it "creates a reader attribute for the given name" do + expect(klass.instance_method(:foo)).to be_a(UnboundMethod) + end + + it "creates a writer attribute for the given name" do + expect(klass.instance_method(:foo=)).to be_a(UnboundMethod) + end + + context "and when the attribute is invoked" do + it "sends the 'call' message to the value" do + expect_any_instance_of(Pry::Config::Value).to receive(:call) + subject.foo + end + end + end +end diff --git a/spec/config/behavior_spec.rb b/spec/config/behavior_spec.rb deleted file mode 100644 index 9a789a16..00000000 --- a/spec/config/behavior_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -RSpec.describe Pry::Config::Behavior do - let(:behavior) do - Class.new do - include Pry::Config::Behavior - end - end - - describe "#last_default" do - it "returns the last default" do - last = behavior.from_hash({}, nil) - middle = behavior.from_hash({}, last) - expect(behavior.from_hash({}, middle).last_default).to be(last) - end - end - - describe "#eager_load!" do - it "returns nil when the default is nil" do - expect(behavior.from_hash({}, nil).eager_load!).to be(nil) - end - end -end diff --git a/spec/config/lazy_value_spec.rb b/spec/config/lazy_value_spec.rb new file mode 100644 index 00000000..dc2aaa1e --- /dev/null +++ b/spec/config/lazy_value_spec.rb @@ -0,0 +1,9 @@ +RSpec.describe Pry::Config::LazyValue do + describe "#call" do + subject { described_class.new { rand } } + + it "doesn't memoize the result of call" do + expect(subject.call).not_to eq(subject.call) + end + end +end diff --git a/spec/config/memoized_value_spec.rb b/spec/config/memoized_value_spec.rb new file mode 100644 index 00000000..1601bff2 --- /dev/null +++ b/spec/config/memoized_value_spec.rb @@ -0,0 +1,9 @@ +RSpec.describe Pry::Config::MemoizedValue do + describe "#call" do + subject { described_class.new { rand } } + + it "memoizes the result of call" do + expect(subject.call).to eq(subject.call) + end + end +end diff --git a/spec/config/value_spec.rb b/spec/config/value_spec.rb new file mode 100644 index 00000000..efb8eca4 --- /dev/null +++ b/spec/config/value_spec.rb @@ -0,0 +1,37 @@ +RSpec.describe Pry::Config::Value do + describe "#call" do + context "when given value is a MemoizedValue" do + subject { described_class.new(Pry::Config::MemoizedValue.new { 123 }) } + + it "calls the MemoizedLazy object" do + expect(subject.call).to eq(123) + end + end + + context "when given value is a LazyValue" do + subject { described_class.new(Pry::Config::LazyValue.new { 123 }) } + + it "calls the LazyValue object" do + expect(subject.call).to eq(123) + end + end + + context "when given value is a Proc" do + let(:callable) { proc {} } + + subject { described_class.new(callable) } + + it "returns the value as is" do + expect(subject.call).to eq(callable) + end + end + + context "when given value is a non-callable object" do + subject { described_class.new('test') } + + it "returns the value as is" do + expect(subject.call).to eq('test') + end + end + end +end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index a4e09613..1cd9cdb2 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -1,289 +1,134 @@ RSpec.describe Pry::Config do - describe ".from_hash" do - it "returns an object without a default" do - local = described_class.from_hash({}) - expect(local.default).to eq(nil) - end - - it "returns an object with a default" do - default = described_class.new(nil) - local = described_class.from_hash({}, default) - expect(local.default).to eq(local) - end + specify { expect(subject.input).to respond_to(:readline) } + specify { expect(subject.output).to be_an(IO) } + specify { expect(subject.commands).to be_a(Pry::CommandSet) } + specify { expect(subject.prompt_name).to be_a(String) } + specify { expect(subject.prompt).to be_a(Pry::Prompt) } + specify { expect(subject.prompt_safe_contexts).to be_an(Array) } + specify { expect(subject.print).to be_a(Method) } + specify { expect(subject.quiet).to be(true).or be(false) } + specify { expect(subject.exception_handler).to be_a(Method) } + specify { expect(subject.unrescued_exceptions).to be_an(Array) } + specify { expect(subject.hooks).to be_a(Pry::Hooks) } + specify { expect(subject.pager).to be(true).or be(false) } + specify { expect(subject.system).to be_a(Method) } + specify { expect(subject.color).to be(true).or be(false) } + specify { expect(subject.default_window_size).to be_a(Numeric) } + specify { expect(subject.editor).to be_a(String) } + specify { expect(subject.should_load_rc).to be(true).or be(false) } + specify { expect(subject.should_load_local_rc).to be(true).or be(false) } + specify { expect(subject.should_trap_interrupts).to be(true).or be(false) } + specify { expect(subject.disable_auto_reload).to be(true).or be(false) } + specify { expect(subject.command_prefix).to be_a(String) } + specify { expect(subject.auto_indent).to be(true).or be(false) } + specify { expect(subject.correct_indent).to be(true).or be(false) } + specify { expect(subject.collision_warning).to be(true).or be(false) } + specify { expect(subject.output_prefix).to be_a(String) } + specify { expect(subject.requires).to be_an(Array) } + specify { expect(subject.should_load_requires).to be(true).or be(false) } + specify { expect(subject.should_load_plugins).to be(true).or be(false) } + specify { expect(subject.windows_console_warning).to be(true).or be(false) } + specify { expect(subject.control_d_handler).to be_a(Method) } + specify { expect(subject.memory_size).to be_a(Numeric) } + specify { expect(subject.extra_sticky_locals).to be_a(Hash) } + specify { expect(subject.command_completions).to be_a(Proc) } + specify { expect(subject.file_completions).to be_a(Proc) } + specify { expect(subject.ls).to be_an(OpenStruct) } + specify { expect(subject.completer).to eq(Pry::InputCompleter) } + specify { expect(subject.history).to be_a(Pry::History) } + specify { expect(subject.history_save).to eq(true).or be(false) } + specify { expect(subject.history_load).to eq(true).or be(false) } + specify { expect(subject.history_file).to be_a(String) } + specify { expect(subject.exec_string).to be_a(String) } - it "recursively walks a Hash" do - h = { 'foo1' => { 'foo2' => { 'foo3' => 'foobar' } } } - default = described_class.from_hash(h) - expect(default.foo1).to be_instance_of(described_class) - expect(default.foo1.foo2).to be_instance_of(described_class) - end + describe "#merge!" do + it "merges given hash with the config instance" do + subject.merge!(output_prefix: '~> ', exec_string: '!') - it "recursively walks an Array" do - c = described_class.from_hash(ary: [{ number: 2 }, Object]) - expect(c.ary[0].number).to eq(2) - expect(c.ary[1]).to eq(Object) + expect(subject.output_prefix).to eq('~> ') + expect(subject.exec_string).to eq('!') end - end - describe "bug #1552" do - specify( - "a local key has precendence over its default when the stored value is false" - ) do - local = described_class.from_hash({}, described_class.from_hash('color' => true)) - local.color = false - expect(local.color).to eq(false) + it "returns self" do + config = subject.merge!(output_prefix: '~> ') + expect(subject).to eql(config) end - end - describe "bug #1277" do - specify "a local key has precendence over an inherited method of the same name" do - local = described_class.from_hash(output: 'foobar') - local.extend( - Module.new do - def output - 'broken' - end - end - ) - expect(local.output).to eq('foobar') - end - end + context "when an undefined option is given" do + it "adds the option to the config" do + subject.merge!(new_option: 1, other_option: 2) - describe "reserved keys" do - it "raises ReservedKeyError on assignment of a reserved key" do - local = described_class.new - local.instance_variable_get(:@reserved_keys).each do |key| - expect { local[key] = 1 }.to raise_error(described_class::ReservedKeyError) + expect(subject.new_option).to eq(1) + expect(subject.other_option).to eq(2) end end end - describe "traversal to parent" do - it "traverses back to the parent when a local key is not found" do - local = described_class.new described_class.from_hash(foo: 1) - expect(local.foo).to eq(1) + describe "#merge" do + it "returns a new config object" do + expect(subject).not_to equal(subject.merge(new_option: 1, other_option: 2)) end - it "stores a local key and prevents traversal to the parent" do - local = described_class.new described_class.from_hash(foo: 1) - local.foo = 2 - expect(local.foo).to eq(2) - end + it "doesn't mutate the original config" do + subject.merge(new_option: 1, other_option: 2) - it "traverses through a chain of parents" do - root = described_class.from_hash(foo: 21) - local1 = described_class.new(root) - local2 = described_class.new(local1) - local3 = described_class.new(local2) - expect(local3.foo).to eq(21) - end - - it "stores a local copy of the parents hooks upon accessing them" do - parent = described_class.from_hash(hooks: "parent_hooks") - local = described_class.new parent - local.hooks.gsub! 'parent', 'local' - expect(local.hooks).to eq 'local_hooks' - expect(parent.hooks).to eq('parent_hooks') + expect(subject).not_to respond_to(:new_option) + expect(subject).not_to respond_to(:other_option) end end - describe "#respond_to_missing?" do - before do - @config = described_class.new(nil) + describe "#method_missing" do + context "when invoked method ends with =" do + it "assigns a new custom option" do + subject.foo = 1 + expect(subject.foo).to eq(1) + end end - it "returns a Method object for a dynamic key" do - @config["key"] = 1 - method_obj = @config.method(:key) - expect(method_obj.name).to eq :key - expect(method_obj.call).to eq(1) + context "when invoked method is not an option" do + it "raises NoMethodError" do + expect { subject.foo }.to raise_error(NoMethodError) + end end - it "returns a Method object for a setter on a parent" do - config = described_class.from_hash({}, described_class.from_hash(foo: 1)) - expect(config.method(:foo=)).to be_an_instance_of(Method) + context "when invoked method is a LazyValue" do + it "defines a callable attribute" do + subject.foo = Pry::Config::LazyValue.new { 1 } + expect(subject.foo).to eq(1) + end end end describe "#respond_to?" do - before do - @config = described_class.new(nil) - end - - it "returns true for a local key" do - @config.zzfoo = 1 - expect(@config.respond_to?(:zzfoo)).to eq(true) - end - - it "returns false for an unknown key" do - expect(@config.respond_to?(:blahblah)).to eq(false) - end - end - - describe "#default" do - it "returns nil" do - local = described_class.new(nil) - expect(local.default).to eq(nil) - end - - it "returns the default" do - default = described_class.new(nil) - local = described_class.new(default) - expect(local.default).to eq(default) - end - end - - describe "#keys" do - it "returns an array of local keys" do - root = described_class.from_hash({ zoo: "boo" }, nil) - local = described_class.from_hash({ foo: "bar" }, root) - expect(local.keys).to eq(["foo"]) - end - end - - describe "#==" do - it "compares equality through the underlying lookup table" do - local1 = described_class.new(nil) - local2 = described_class.new(nil) - local1.foo = "hi" - local2.foo = "hi" - expect(local1).to eq(local2) - end - - it "compares equality against an object who does not implement #to_hash" do - local1 = described_class.new(nil) - expect(local1).not_to eq(Object.new) - end - - it "returns false when compared against nil" do - # rubocop:disable Style/NilComparison - expect(described_class.new(nil) == nil).to eq(false) - # rubocop:enable Style/NilComparison - end - end - - describe '#forget' do - it 'restores a key to its default value' do - last_default = described_class.from_hash(a: 'c') - middle_default = described_class.from_hash({ a: 'b' }, last_default) - c = described_class.from_hash({ a: 'a' }, middle_default) - c.forget(:a) - expect(c.a).to eq('c') - end - end - - describe "#to_hash" do - it "provides a copy of local key & value pairs as a Hash" do - local = described_class.new described_class.from_hash(bar: true) - local.foo = "21" - expect(local.to_hash).to eq("foo" => "21") - end - - it "returns a duplicate of the lookup table" do - local = described_class.new(nil) - local.to_hash["foo"] = 42 - expect(local.foo).not_to eq(42) - end - end - - describe "#merge!" do - before do - @config = described_class.new(nil) - end - - it "merges an object who returns a Hash through #to_hash" do - obj = Class.new do - def to_hash - { epoch: 1 } - end - end.new - @config.merge!(obj) - expect(@config.epoch).to eq(1) - end - - it "merges an object who returns a Hash through #to_h" do - obj = Class.new do - def to_h - { epoch: 2 } - end - end.new - @config.merge!(obj) - expect(@config.epoch).to eq(2) - end - - it "merges a Hash" do - @config[:epoch] = 420 - expect(@config.epoch).to eq(420) - end - - it "raises a TypeError for objects who can't become a Hash" do - expect { @config.merge!(Object.new) }.to raise_error TypeError - end - end - - describe "#clear" do - before do - @local = described_class.new(nil) + context "when checking an undefined option" do + it "returns false" do + expect(subject.respond_to?(:foo)).to be(false) + end end - it "returns true" do - expect(@local.clear).to eq(true) - end + context "when checking a defined option" do + before { subject.foo = 1 } - it "clears local assignments" do - @local.foo = 1 - @local.clear - expect(@local.to_hash).to eq({}) - end - end + it "returns true for the reader" do + expect(subject.respond_to?(:foo)).to be(true) + end - describe "#[]=" do - it "stores keys as strings" do - local = described_class.from_hash({}) - local[:zoo] = "hello" - expect(local.to_hash).to eq("zoo" => "hello") + it "returns true for the writer" do + expect(subject.respond_to?(:foo=)).to be(true) + end end end describe "#[]" do - it "traverses back to a default" do - default = described_class.from_hash(k: 1) - local = described_class.new(default) - expect(local['k']).to eq(1) - end - - it "traverses back to a default (2 deep)" do - default1 = described_class.from_hash(k: 1) - default2 = described_class.from_hash({}, default1) - local = described_class.new(default2) - expect(local['k']).to eq(1) - end - - it "traverses back to a default that doesn't exist, and returns nil" do - local = described_class.from_hash({}, nil) - expect(local['output']).to eq(nil) + it "reads the config value" do + expect_any_instance_of(Pry::Config::Value).to receive(:call) + subject[:foo] = 1 + subject[:foo] end - context "when returning a Pry::Config::Lazy object" do - it "invokes #call on it" do - c = described_class.from_hash foo: Pry.lazy { 10 } - expect(c['foo']).to eq(10) - end - - it "invokes #call upon each access" do - c = described_class.from_hash foo: Pry.lazy { 'foo' } - expect(c['foo']).to_not equal(c['foo']) - end - end - end - - describe "#eager_load!" do - it "eagerly loads keys from the last default into self" do - last_default = described_class.from_hash(foo: 1, bar: 2, baz: 3) - c = described_class.from_hash({}, last_default) - expect(c.keys.size).to eq(0) - c.eager_load! - expect(c.keys.size).to eq(3) + it "returns the config value" do + subject[:foo] = 1 + expect(subject[:foo]).to eq(1) end end end diff --git a/spec/history_spec.rb b/spec/history_spec.rb index f69fea0c..0e3f4b6e 100644 --- a/spec/history_spec.rb +++ b/spec/history_spec.rb @@ -68,15 +68,15 @@ RSpec.describe Pry::History do describe "#clear" do before do - @old_file = Pry.config.history.file + @old_file = Pry.config.history_file @hist_file_path = File.expand_path('spec/fixtures/pry_history') - Pry.config.history.file = @hist_file_path + Pry.config.history_file = @hist_file_path Pry.history.clear Pry.load_history end after do - Pry.config.history.file = @old_file + Pry.config.history_file = @old_file end it "clears this session's history" do @@ -130,12 +130,12 @@ RSpec.describe Pry::History do before do @histfile = Tempfile.new(%w[pryhistory txt]) @history = Pry::History.new(file_path: @histfile.path) - Pry.config.history.should_save = true + Pry.config.history_save = true end after do @histfile.close(true) - Pry.config.history.should_save = false + Pry.config.history_save = false end it "saves lines to a file as they are written" do @@ -152,7 +152,7 @@ RSpec.describe Pry::History do end it "should not write histignore words to the history file" do - Pry.config.history.histignore = ["ls", /hist*/, 'exit'] + Pry.config.history_ignorelist = ["ls", /hist*/, 'exit'] @history.push "ls" @history.push "hist" @history.push "kakaroto" @@ -164,8 +164,8 @@ RSpec.describe Pry::History do end describe "expanding the history file path" do - before { Pry.config.history.should_save = true } - after { Pry.config.history.should_save = false } + before { Pry.config.history_save = true } + after { Pry.config.history_save = false } it "recognizes ~ (#1262)" do # This is a pretty dumb way of testing this, but at least it shouldn't @@ -193,7 +193,7 @@ RSpec.describe Pry::History do end it "handles #{error_class} failure to write history" do - Pry.config.history.should_save = true + Pry.config.history_save = true expect(File).to receive(:open).with(file_path, "a", 0o600).and_raise(error_class) expect(history).to receive(:warn).with(/Unable to write history file:/) expect { history.push("anything") }.to_not raise_error diff --git a/spec/prompt_spec.rb b/spec/prompt_spec.rb index 9e57045f..58616cd5 100644 --- a/spec/prompt_spec.rb +++ b/spec/prompt_spec.rb @@ -90,7 +90,7 @@ describe Pry::Prompt do it "computes prompt name dynamically" do proc = described_class[:default].wait_proc - pry.config.prompt_name = Pry.lazy { enum.next } + pry.config.prompt_name = Pry::Config::LazyValue.new { enum.next } expect(proc.call(Object.new, 1, pry, '>')).to eq('[1] a(#<Object>):1> ') expect(proc.call(Object.new, 1, pry, '>')).to eq('[1] b(#<Object>):1> ') end diff --git a/spec/pry_defaults_spec.rb b/spec/pry_defaults_spec.rb index 133d9b02..24fa54c5 100644 --- a/spec/pry_defaults_spec.rb +++ b/spec/pry_defaults_spec.rb @@ -373,7 +373,7 @@ describe "test Pry defaults" do binding, input: InputTester.new("1", "exit-all"), output: @str_output, - hooks: Pry::Config.defaults.hooks + hooks: Pry::Config.new.hooks ) expect(@str_output.string).to match(/[w]hereami by default/) @@ -384,7 +384,7 @@ describe "test Pry defaults" do input: InputTester.new('exit-all'), output: @str_output, quiet: true, - hooks: Pry::Config.defaults.hooks + hooks: Pry::Config.new.hooks ) expect(@str_output.string).to eq "" diff --git a/spec/pry_output_spec.rb b/spec/pry_output_spec.rb index 2facc4f8..8f905d02 100644 --- a/spec/pry_output_spec.rb +++ b/spec/pry_output_spec.rb @@ -1,6 +1,6 @@ describe Pry do describe "output failsafe" do - after { Pry.config.print = Pry::Config.defaults.print } + after { Pry.config.print = Pry::Config.new.print } it "should catch serialization exceptions" do Pry.config.print = proc { raise "catch-22" } diff --git a/spec/pry_repl_spec.rb b/spec/pry_repl_spec.rb index 5430a0a7..f407240a 100644 --- a/spec/pry_repl_spec.rb +++ b/spec/pry_repl_spec.rb @@ -45,7 +45,7 @@ describe Pry::REPL do it "shouldn't break if we start a nested instance" do ReplTester.start do - input 'Pry.start(10, pry_instance.config)' + input 'Pry.start(10)' output '' prompt(/10.*> $/) |