From 94bf5d63d01a5af375099ecd8ecb33256ce5da28 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 18 Dec 2012 00:41:43 -0800 Subject: [PATCH] Remove arg from select_prompt in the specs --- spec/pry_defaults_spec.rb | 68 ++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/spec/pry_defaults_spec.rb b/spec/pry_defaults_spec.rb index 73151fbb..4cf4d4ec 100644 --- a/spec/pry_defaults_spec.rb +++ b/spec/pry_defaults_spec.rb @@ -136,63 +136,50 @@ describe "test Pry defaults" do before do @empty_input_buffer = "" @non_empty_input_buffer = "def hello" - @context = Pry.binding_for(0) + end + + def get_prompts(pry) + a = pry.select_prompt + pry.accept_line "def hello" + b = pry.select_prompt + pry.accept_line "end" + [a, b] end it 'should set the prompt default, and the default should be overridable (single prompt)' do - new_prompt = proc { "test prompt> " } - Pry.prompt = new_prompt - - pry = Pry.new - pry.push_binding @context - - pry.prompt.should == Pry.prompt - pry.select_prompt(@empty_input_buffer).should == "test prompt> " - pry.select_prompt(@non_empty_input_buffer).should == "test prompt> " - + Pry.prompt = proc { "test prompt> " } new_prompt = proc { "A" } - pry = Pry.new(:prompt => new_prompt) - pry.push_binding @context + pry = Pry.new + pry.prompt.should == Pry.prompt + get_prompts(pry).should == ["test prompt> ", "test prompt> "] + + pry = Pry.new(:prompt => new_prompt) pry.prompt.should == new_prompt - pry.select_prompt(@empty_input_buffer).should == "A" - pry.select_prompt(@non_empty_input_buffer).should == "A" + get_prompts(pry).should == ["A", "A"] pry = Pry.new - pry.push_binding @context - pry.prompt.should == Pry.prompt - pry.select_prompt(@empty_input_buffer).should == "test prompt> " - pry.select_prompt(@non_empty_input_buffer).should == "test prompt> " + get_prompts(pry).should == ["test prompt> ", "test prompt> "] end it 'should set the prompt default, and the default should be overridable (multi prompt)' do - new_prompt = [proc { "test prompt> " }, proc { "test prompt* " }] - Pry.prompt = new_prompt - - pry = Pry.new - pry.push_binding @context - - pry.prompt.should == Pry.prompt - pry.select_prompt(@empty_input_buffer).should == "test prompt> " - pry.select_prompt(@non_empty_input_buffer).should == "test prompt* " - + Pry.prompt = [proc { "test prompt> " }, proc { "test prompt* " }] new_prompt = [proc { "A" }, proc { "B" }] - pry = Pry.new(:prompt => new_prompt) - pry.push_binding @context + pry = Pry.new + pry.prompt.should == Pry.prompt + get_prompts(pry).should == ["test prompt> ", "test prompt* "] + + pry = Pry.new(:prompt => new_prompt) pry.prompt.should == new_prompt - pry.select_prompt(@empty_input_buffer).should == "A" - pry.select_prompt(@non_empty_input_buffer).should == "B" + get_prompts(pry).should == ["A", "B"] pry = Pry.new - pry.push_binding @context - pry.prompt.should == Pry.prompt - pry.select_prompt(@empty_input_buffer).should == "test prompt> " - pry.select_prompt(@non_empty_input_buffer).should == "test prompt* " + get_prompts(pry).should == ["test prompt> ", "test prompt* "] end describe 'storing and restoring the prompt' do @@ -217,12 +204,11 @@ describe "test Pry defaults" do it 'should restore overridden prompts when returning from file-mode' do pry = Pry.new(:prompt => [ proc { 'P>' } ] * 2) - pry.push_binding @context - pry.select_prompt(@empty_input_buffer).should == "P>" + pry.select_prompt.should == "P>" pry.process_command('shell-mode') - pry.select_prompt(@empty_input_buffer).should =~ /\Apry .* \$ \z/ + pry.select_prompt.should =~ /\Apry .* \$ \z/ pry.process_command('shell-mode') - pry.select_prompt(@empty_input_buffer).should == "P>" + pry.select_prompt.should == "P>" end it '#pop_prompt should return the popped prompt' do