summaryrefslogtreecommitdiff
path: root/spec/commands
diff options
context:
space:
mode:
Diffstat (limited to 'spec/commands')
-rw-r--r--spec/commands/edit_spec.rb18
-rw-r--r--spec/commands/exit_all_spec.rb12
-rw-r--r--spec/commands/exit_spec.rb6
-rw-r--r--spec/commands/find_method_spec.rb34
-rw-r--r--spec/commands/gem_list_spec.rb4
-rw-r--r--spec/commands/show_source_spec.rb31
-rw-r--r--spec/commands/whereami_spec.rb25
7 files changed, 69 insertions, 61 deletions
diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb
index 34f8f64f..d5e5cea6 100644
--- a/spec/commands/edit_spec.rb
+++ b/spec/commands/edit_spec.rb
@@ -65,7 +65,7 @@ describe "edit" do
it "should not delete the file!" do
pry_eval 'edit Rakefile'
- File.exist?(@file).should == true
+ File.exist?(@file).should.be_true
end
it "works with files that contain blanks in their names" do
@@ -88,11 +88,11 @@ describe "edit" do
nil
}
pry_eval "edit #@tf_path"
- Pad.required.should == true
+ Pad.required.should.be_true
end
end
- describe do
+ describe "with a counter" do
before do
Pad.counter = 0
Pry.config.editor = lambda { |file, line|
@@ -144,7 +144,7 @@ describe "edit" do
end
end
- describe do
+ describe "when invoking an editor proc" do
before do
@reloading = nil
Pry.config.editor = lambda do |file, line, reloading|
@@ -155,9 +155,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit lib/pry.rb'
- @reloading.should == true
+ @reloading.should.be_true
pry_eval 'edit -n lib/pry.rb'
- @reloading.should == false
+ @reloading.should.be_false
end
end
end
@@ -670,7 +670,7 @@ describe "edit" do
pry_eval 'edit -p X#c'
- Pry::Method.from_str("X#c").alias?.should == true
+ Pry::Method.from_str("X#c").alias?.should.be_true
X.new.b.should == :kinda
X.new.c.should == :kindaaa
@@ -689,9 +689,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit X.x'
- @reloading.should == true
+ @reloading.should.be_true
pry_eval 'edit -n X.x'
- @reloading.should == false
+ @reloading.should.be_false
end
end
end
diff --git a/spec/commands/exit_all_spec.rb b/spec/commands/exit_all_spec.rb
index 7a771c93..1c53c84c 100644
--- a/spec/commands/exit_all_spec.rb
+++ b/spec/commands/exit_all_spec.rb
@@ -4,24 +4,24 @@ describe "exit-all" do
before { @pry = Pry.new }
it "should break out of the repl and return nil" do
- @pry.eval("exit-all").should.be.false
+ @pry.eval("exit-all").should.be_false
@pry.exit_value.should.be.nil
end
it "should break out of the repl wth a user specified value" do
- @pry.eval("exit-all 'message'").should.be.false
+ @pry.eval("exit-all 'message'").should.be_false
@pry.exit_value.should == "message"
end
it "should break out of the repl even if multiple bindings still on stack" do
- ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be.true }
- @pry.eval("exit-all 'message'").should.be.false
+ ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be_true }
+ @pry.eval("exit-all 'message'").should.be_false
@pry.exit_value.should == "message"
end
it "should have empty binding_stack after breaking out of the repl" do
- ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be.true }
- @pry.eval("exit-all").should.be.false
+ ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be_true }
+ @pry.eval("exit-all").should.be_false
@pry.binding_stack.should.be.empty
end
end
diff --git a/spec/commands/exit_spec.rb b/spec/commands/exit_spec.rb
index 8cd75876..d6d0ccbc 100644
--- a/spec/commands/exit_spec.rb
+++ b/spec/commands/exit_spec.rb
@@ -11,18 +11,18 @@ describe "exit" do
end
it "should break out of the repl when binding_stack has only one binding" do
- @pry.eval("exit").should.be.false
+ @pry.eval("exit").should.be_false
@pry.exit_value.should.be.nil
end
it "should break out of the repl and return user-given value" do
- @pry.eval("exit :john").should.be.false
+ @pry.eval("exit :john").should.be_false
@pry.exit_value.should == :john
end
it "should break out of the repl even after an exception" do
@pry.eval "exit = 42"
@pry.output.string.should =~ /^SyntaxError/
- @pry.eval("exit").should.be.false
+ @pry.eval("exit").should.be_false
end
end
diff --git a/spec/commands/find_method_spec.rb b/spec/commands/find_method_spec.rb
index a00e8b90..a579cc71 100644
--- a/spec/commands/find_method_spec.rb
+++ b/spec/commands/find_method_spec.rb
@@ -1,21 +1,27 @@
require_relative '../helper'
-MyKlass = Class.new do
- def hello
- "timothy"
- end
- def goodbye
- "jenny"
- end
- def tea_tim?
- "timothy"
+describe "find-method" do
+ before do
+ class MyKlass
+ def hello
+ "timothy"
+ end
+ def goodbye
+ "jenny"
+ end
+ def tea_tim?
+ "timothy"
+ end
+ def tea_time?
+ "polly"
+ end
+ end
end
- def tea_time?
- "polly"
+
+ after do
+ Object.remove_const :MyKlass
end
-end
-describe "find-method" do
describe "find matching methods by name regex (-n option)" do
it "should find a method by regex" do
pry_eval("find-method hell MyKlass").should =~
@@ -59,5 +65,3 @@ describe "find-method" do
pry_eval('find-method tea_time\? MyKlass').should =~ good
end
end
-
-Object.remove_const(:MyKlass)
diff --git a/spec/commands/gem_list_spec.rb b/spec/commands/gem_list_spec.rb
index cef5c745..11ce6c6d 100644
--- a/spec/commands/gem_list_spec.rb
+++ b/spec/commands/gem_list_spec.rb
@@ -10,13 +10,13 @@ describe "gem-list" do
it 'should work arglessly' do
list = pry_eval('gem-list')
list.should =~ /slop \(/
- list.should =~ /bacon \(/
+ list.should =~ /minitest \(/
end
it 'should find arg' do
prylist = pry_eval('gem-list slop')
prylist.should =~ /slop \(/
- prylist.should.not =~ /bacon/
+ prylist.should.not =~ /minitest/
end
it 'should return non-results as silence' do
diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb
index db34a68f..e465fbe9 100644
--- a/spec/commands/show_source_spec.rb
+++ b/spec/commands/show_source_spec.rb
@@ -301,7 +301,7 @@ describe "show-source" do
end
end
- class ShowSourceTestClass<ShowSourceTestSuperClass
+ class ShowSourceTestClass < ShowSourceTestSuperClass
def alpha
end
end
@@ -374,26 +374,26 @@ describe "show-source" do
end
end
- before do
- pry_eval unindent(<<-EOS)
- class Dog
- def woof
+ describe "in REPL" do
+ before do
+ pry_eval unindent(<<-EOS)
+ class Dog
+ def woof
+ end
end
- end
- class TobinaMyDog < Dog
- def woof
+ class TobinaMyDog < Dog
+ def woof
+ end
end
+ EOS
end
- EOS
- end
- after do
- Object.remove_const :Dog
- Object.remove_const :TobinaMyDog
- end
+ after do
+ Object.remove_const :Dog
+ Object.remove_const :TobinaMyDog
+ end
- describe "in REPL" do
it 'should find class defined in repl' do
pry_eval('show-source TobinaMyDog').should =~ /class TobinaMyDog/
end
@@ -404,7 +404,6 @@ describe "show-source" do
end
it 'should lookup module name with respect to current context' do
-
constant_scope(:AlphaClass, :BetaClass) do
class BetaClass
def alpha
diff --git a/spec/commands/whereami_spec.rb b/spec/commands/whereami_spec.rb
index f19f49d0..2f4dd298 100644
--- a/spec/commands/whereami_spec.rb
+++ b/spec/commands/whereami_spec.rb
@@ -202,24 +202,29 @@ describe "whereami" do
out.should.not =~ /\=\>/
end
end
+
Cor.new.blimey!
- Object.remove_const(:Cor)
+ Object.remove_const :Cor
end
it 'should use Pry.config.default_window_size for window size when outside a method context' do
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
- :litella
- :pig
- out = pry_eval(binding, 'whereami')
- :punk
- :sanders
- out.should.not =~ /:litella/
- out.should =~ /:pig/
- out.should =~ /:punk/
- out.should.not =~ /:sanders/
+ class TemporaryClass
+ :litella
+ :pig
+ out = pry_eval(binding, 'whereami')
+ :punk
+ :sanders
+
+ out.should.not =~ /:litella/
+ out.should =~ /:pig/
+ out.should =~ /:punk/
+ out.should.not =~ /:sanders/
+ end
Pry.config.default_window_size = old_size
+ Object.remove_const :TemporaryClass
end
it "should work at the top level" do