2014-03-14 05:31:24 +01:00
|
|
|
require_relative '../helper'
|
2012-06-11 16:36:16 +03:00
|
|
|
|
2011-10-08 17:44:14 -07:00
|
|
|
describe "ls" do
|
|
|
|
describe "below ceiling" do
|
|
|
|
it "should stop before Object by default" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("cd Class.new{ def goo; end }.new", "ls").should_not =~ /Object/
|
|
|
|
pry_eval("cd Class.new{ def goo; end }", "ls -M").should_not =~ /Object/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should include object if -v is given" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("cd Class.new{ def goo; end }.new", "ls -m -v").should =~ /Object/
|
|
|
|
pry_eval("cd Class.new{ def goo; end }", "ls -vM").should =~ /Object/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should include super-classes by default" do
|
2012-09-05 23:20:40 -07:00
|
|
|
pry_eval(
|
|
|
|
"cd Class.new(Class.new{ def goo; end; public :goo }).new",
|
|
|
|
"ls").should =~ /goo/
|
|
|
|
|
|
|
|
pry_eval(
|
|
|
|
"cd Class.new(Class.new{ def goo; end; public :goo })",
|
|
|
|
"ls -M").should =~ /goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not include super-classes when -q is given" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("cd Class.new(Class.new{ def goo; end }).new", "ls -q").should_not =~ /goo/
|
|
|
|
pry_eval("cd Class.new(Class.new{ def goo; end })", "ls -M -q").should_not =~ /goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-17 18:57:42 +13:00
|
|
|
describe "help" do
|
|
|
|
it 'should show help with -h' do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("ls -h").should =~ /Usage: ls/
|
2011-12-17 18:57:42 +13:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-23 22:58:26 -07:00
|
|
|
describe "BasicObject" do
|
|
|
|
it "should work on BasicObject" do
|
|
|
|
pry_eval("ls BasicObject.new").should =~ /BasicObject#methods:.*__send__/m
|
|
|
|
end
|
2013-10-19 20:58:57 -07:00
|
|
|
|
2013-10-23 22:58:26 -07:00
|
|
|
it "should work on subclasses of BasicObject" do
|
|
|
|
pry_eval(
|
|
|
|
"class LessBasic < BasicObject; def jaroussky; 5; end; end",
|
|
|
|
"ls LessBasic.new"
|
|
|
|
).should =~ /LessBasic#methods:.*jaroussky/m
|
2013-10-19 20:58:57 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-05 15:32:45 -08:00
|
|
|
describe "immediates" do
|
|
|
|
it "should work on Fixnum" do
|
|
|
|
pry_eval("ls 5").should =~ /Fixnum#methods:.*modulo/m
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-17 18:57:42 +13:00
|
|
|
describe "methods" do
|
2011-10-08 17:44:14 -07:00
|
|
|
it "should show public methods by default" do
|
2012-09-05 23:20:40 -07:00
|
|
|
output = pry_eval("ls Class.new{ def goo; end; public :goo }.new")
|
2013-01-16 23:29:32 -06:00
|
|
|
output.should =~ /methods: goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not show protected/private by default" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("ls -M Class.new{ def goo; end; private :goo }").should_not =~ /goo/
|
|
|
|
pry_eval("ls Class.new{ def goo; end; protected :goo }.new").should_not =~ /goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show public methods with -p" do
|
2013-01-16 23:29:32 -06:00
|
|
|
pry_eval("ls -p Class.new{ def goo; end }.new").should =~ /methods: goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show protected/private methods with -p" do
|
2013-01-16 23:29:32 -06:00
|
|
|
pry_eval("ls -pM Class.new{ def goo; end; protected :goo }").should =~ /methods: goo/
|
|
|
|
pry_eval("ls -p Class.new{ def goo; end; private :goo }.new").should =~ /methods: goo/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
2011-10-25 13:37:41 -07:00
|
|
|
|
|
|
|
it "should work for objects with an overridden method method" do
|
|
|
|
require 'net/http'
|
|
|
|
# This doesn't actually touch the network, promise!
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("ls Net::HTTP::Get.new('localhost')").should =~ /Net::HTTPGenericRequest#methods/
|
2011-10-25 13:37:41 -07:00
|
|
|
end
|
2013-02-26 07:28:37 -06:00
|
|
|
|
2013-04-16 19:25:33 +04:00
|
|
|
it "should work for objects which instance_variables returns array of symbol but there is no Symbol#downcase" do
|
|
|
|
test_case = "class Object; alias :fg :instance_variables; def instance_variables; fg.map(&:to_sym); end end;"
|
|
|
|
normalize = "class Object; def instance_variables; fg; end end;"
|
|
|
|
|
|
|
|
test = lambda do
|
|
|
|
begin
|
|
|
|
pry_eval(test_case, "class GeFromulate2; @flurb=1.3; end", "cd GeFromulate2", "ls")
|
|
|
|
pry_eval(normalize)
|
|
|
|
rescue
|
|
|
|
pry_eval(normalize)
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
expect(test).to_not raise_error
|
2013-04-16 19:25:33 +04:00
|
|
|
end
|
|
|
|
|
2013-12-23 22:53:17 +09:00
|
|
|
it "should show error message when instance is given with -M option" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
expect { pry_eval("ls -M String.new") }.to raise_error(Pry::CommandError, /-M only makes sense with a Module or a Class/)
|
2013-12-23 22:53:17 +09:00
|
|
|
end
|
|
|
|
|
2013-04-16 19:25:33 +04:00
|
|
|
|
2013-03-13 20:12:53 +02:00
|
|
|
# see: https://travis-ci.org/pry/pry/jobs/5071918
|
|
|
|
unless Pry::Helpers::BaseHelpers.rbx?
|
|
|
|
it "should handle classes that (pathologically) define .ancestors" do
|
|
|
|
output = pry_eval("ls Class.new{ def self.ancestors; end; def hihi; end }")
|
2013-02-26 08:42:08 -06:00
|
|
|
output.should =~ /hihi/
|
|
|
|
end
|
2013-02-26 07:28:37 -06:00
|
|
|
end
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
2012-10-02 06:37:01 -05:00
|
|
|
describe 'with -l' do
|
2014-08-10 18:28:44 -06:00
|
|
|
focus 'should find locals and sort by descending size' do
|
|
|
|
result = pry_eval(Object.new, "aa = 'asdf'; bb = 'xyz'", 'ls -l')
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
result.should_not =~ /=>/
|
|
|
|
result.should_not =~ /0x\d{5}/
|
2012-10-15 08:20:18 +00:00
|
|
|
result.should =~ /asdf.*xyz/m
|
2012-10-02 06:37:01 -05:00
|
|
|
end
|
|
|
|
it 'should not list pry noise' do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval('ls -l').should_not =~ /_(?:dir|file|ex|pry|out|in)_/
|
2012-10-02 06:37:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-02 16:13:32 -07:00
|
|
|
describe "when inside Modules" do
|
|
|
|
it "should still work" do
|
2012-09-05 23:20:40 -07:00
|
|
|
pry_eval(
|
|
|
|
"cd Module.new{ def foobie; end; public :foobie }",
|
|
|
|
"ls -M").should =~ /foobie/
|
2011-11-02 16:13:32 -07:00
|
|
|
end
|
2012-04-14 14:12:32 -07:00
|
|
|
|
|
|
|
it "should work for ivars" do
|
2012-09-05 23:20:40 -07:00
|
|
|
pry_eval(
|
|
|
|
"module StigmaT1sm; def foobie; @@gharble = 456; end; end",
|
|
|
|
"Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie",
|
|
|
|
"cd StigmaT1sm",
|
|
|
|
"ls -i").should =~ /@@gharble/
|
2012-04-14 14:12:32 -07:00
|
|
|
end
|
2012-04-16 23:28:24 -07:00
|
|
|
|
|
|
|
it "should include instance methods by default" do
|
2012-09-05 23:20:40 -07:00
|
|
|
output = pry_eval(
|
|
|
|
"ls Module.new{ def shinanagarns; 4; end; public :shinanagarns }")
|
|
|
|
output.should =~ /shinanagarns/
|
2012-04-16 23:28:24 -07:00
|
|
|
end
|
2013-01-27 15:33:53 -08:00
|
|
|
|
|
|
|
it "should behave normally when invoked on Module itself" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("ls Module").should_not =~ /Pry/
|
2013-01-27 15:33:53 -08:00
|
|
|
end
|
2011-11-02 16:13:32 -07:00
|
|
|
end
|
|
|
|
|
2011-10-08 17:44:14 -07:00
|
|
|
describe "constants" do
|
2013-11-30 02:27:46 +02:00
|
|
|
it "works on top-level" do
|
|
|
|
toplevel_consts = pry_eval('ls -c')
|
|
|
|
[/RUBY_PLATFORM/, /ARGF/, /STDOUT/].each do |const|
|
|
|
|
toplevel_consts.should =~ const
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-08 17:44:14 -07:00
|
|
|
it "should show constants defined on the current module" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("class TempFoo1; BARGHL = 1; end", "ls TempFoo1").should =~ /BARGHL/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not show constants defined on parent modules by default" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("class TempFoo2; LHGRAB = 1; end; class TempFoo3 < TempFoo2; BARGHL = 1; end", "ls TempFoo3").should_not =~ /LHGRAB/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show constants defined on ancestors with -v" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("class TempFoo4; LHGRAB = 1; end; class TempFoo5 < TempFoo4; BARGHL = 1; end", "ls -v TempFoo5").should =~ /LHGRAB/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
2011-10-09 22:34:19 -07:00
|
|
|
|
|
|
|
it "should not autoload constants!" do
|
|
|
|
autoload :McflurgleTheThird, "/tmp/this-file-d000esnat-exist.rb"
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
expect { pry_eval("ls -c") }.to_not raise_error
|
2011-10-09 22:34:19 -07:00
|
|
|
end
|
2013-11-29 17:14:44 -08:00
|
|
|
|
|
|
|
it "should show constants for an object's class regardless of mixins" do
|
|
|
|
pry_eval(
|
|
|
|
"cd Pry.new",
|
|
|
|
"extend Module.new",
|
|
|
|
"ls -c"
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
).should match(/Method/)
|
2013-11-29 17:14:44 -08:00
|
|
|
end
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
2011-10-08 18:13:43 -07:00
|
|
|
describe "grep" do
|
|
|
|
it "should reduce the number of outputted things" do
|
2013-11-09 16:32:52 -05:00
|
|
|
pry_eval("ls -c Object").should =~ /ArgumentError/
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval("ls -c Object --grep Run").should_not =~ /ArgumentError/
|
2011-10-08 18:13:43 -07:00
|
|
|
end
|
2012-06-11 16:36:16 +03:00
|
|
|
|
2011-10-08 18:13:43 -07:00
|
|
|
it "should still output matching things" do
|
2013-11-09 16:32:52 -05:00
|
|
|
pry_eval("ls -c Object --grep Run").should =~ /RuntimeError/
|
2011-10-08 18:13:43 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-08 17:44:14 -07:00
|
|
|
describe "when no arguments given" do
|
|
|
|
describe "when at the top-level" do
|
|
|
|
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
2011-12-27 22:38:25 +00:00
|
|
|
unless Pry::Helpers::BaseHelpers.rbx?
|
2011-10-08 17:44:14 -07:00
|
|
|
it "should show local variables" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("ls").should =~ /_pry_/
|
|
|
|
pry_eval("arbitrar = 1", "ls").should =~ /arbitrar/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when in a class" do
|
|
|
|
it "should show constants" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("class GeFromulate1; FOOTIFICATE=1.3; end", "cd GeFromulate1", "ls").should =~ /FOOTIFICATE/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show class variables" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("class GeFromulate2; @@flurb=1.3; end", "cd GeFromulate2", "ls").should =~ /@@flurb/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show methods" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("class GeFromulate3; def self.mooflight; end ; end", "cd GeFromulate3", "ls").should =~ /mooflight/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when in an object" do
|
|
|
|
it "should show methods" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("cd Class.new{ def self.fooerise; end; self }", "ls").should =~ /fooerise/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should show instance variables" do
|
2012-08-18 21:02:53 -07:00
|
|
|
pry_eval("cd Class.new", "@alphooent = 1", "ls").should =~ /@alphooent/
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-04-01 19:25:11 -07:00
|
|
|
|
|
|
|
if Pry::Helpers::BaseHelpers.jruby?
|
|
|
|
describe 'on java objects' do
|
|
|
|
it 'should omit java-esque aliases by default' do
|
2012-12-09 22:08:56 -08:00
|
|
|
pry_eval('ls java.lang.Thread.current_thread').should =~ /\bthread_group\b/
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 16:26:47 -06:00
|
|
|
pry_eval('ls java.lang.Thread.current_thread').should_not =~ /\bgetThreadGroup\b/
|
2012-04-01 19:25:11 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should include java-esque aliases if requested' do
|
2012-12-09 22:08:56 -08:00
|
|
|
pry_eval('ls java.lang.Thread.current_thread -J').should =~ /\bthread_group\b/
|
|
|
|
pry_eval('ls java.lang.Thread.current_thread -J').should =~ /\bgetThreadGroup\b/
|
2012-04-01 19:25:11 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:44:14 -07:00
|
|
|
end
|