pry 0.9.6-i386-mswin32 → 0.9.6.1-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +16 -0
- data/README.markdown +2 -1
- data/Rakefile +9 -4
- data/lib/pry.rb +3 -0
- data/lib/pry/command_context.rb +1 -0
- data/lib/pry/command_set.rb +2 -0
- data/lib/pry/default_commands/basic.rb +5 -7
- data/lib/pry/default_commands/context.rb +5 -2
- data/lib/pry/default_commands/documentation.rb +28 -79
- data/lib/pry/default_commands/input.rb +3 -7
- data/lib/pry/default_commands/introspection.rb +33 -42
- data/lib/pry/default_commands/shell.rb +2 -2
- data/lib/pry/extended_commands/experimental.rb +2 -6
- data/lib/pry/helpers/base_helpers.rb +1 -1
- data/lib/pry/helpers/command_helpers.rb +11 -247
- data/lib/pry/method.rb +184 -0
- data/lib/pry/rbx_method.rb +20 -0
- data/lib/pry/rbx_path.rb +34 -0
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +7 -4
- data/test/helper.rb +1 -0
- data/test/test_command_helpers.rb +1 -69
- data/test/test_command_set.rb +29 -28
- data/test/test_default_commands/test_introspection.rb +5 -0
- data/test/test_method.rb +72 -0
- data/test/test_pry.rb +9 -9
- data/test/test_pry_output.rb +2 -1
- metadata +33 -16
@@ -0,0 +1,20 @@
|
|
1
|
+
class Pry
|
2
|
+
module RbxMethod
|
3
|
+
private
|
4
|
+
def core?
|
5
|
+
source_file and RbxPath.is_core_path?(source_file)
|
6
|
+
end
|
7
|
+
|
8
|
+
def core_code
|
9
|
+
MethodSource.source_helper(core_path_line)
|
10
|
+
end
|
11
|
+
|
12
|
+
def core_doc
|
13
|
+
MethodSource.comment_helper(core_path_line)
|
14
|
+
end
|
15
|
+
|
16
|
+
def core_path_line
|
17
|
+
[RbxPath.convert_path_to_full(source_file), source_line]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/pry/rbx_path.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Pry
|
2
|
+
module RbxPath
|
3
|
+
module_function
|
4
|
+
def is_core_path?(path)
|
5
|
+
path.start_with?("kernel")
|
6
|
+
end
|
7
|
+
|
8
|
+
def convert_path_to_full(path)
|
9
|
+
if rvm_ruby?(Rubinius::BIN_PATH)
|
10
|
+
rvm_convert_path_to_full(path)
|
11
|
+
else
|
12
|
+
std_convert_path_to_full(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def rvm_ruby?(path)
|
17
|
+
!!(path =~ /\.rvm/)
|
18
|
+
end
|
19
|
+
|
20
|
+
def rvm_convert_path_to_full(path)
|
21
|
+
ruby_name = File.dirname(Rubinius::BIN_PATH).split("/").last
|
22
|
+
source_path = File.join(File.dirname(File.dirname(File.dirname(Rubinius::BIN_PATH))), "src", ruby_name)
|
23
|
+
file_name = File.join(source_path, path)
|
24
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
25
|
+
file_name
|
26
|
+
end
|
27
|
+
|
28
|
+
def std_convert_path_to_full(path)
|
29
|
+
file_name = File.join(Rubinius::BIN_PATH, "..", path)
|
30
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
31
|
+
file_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{pry}
|
5
|
-
s.version = "0.9.6"
|
5
|
+
s.version = "0.9.6.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{John Mair (banisterfiend)}]
|
9
|
-
s.date = %q{2011-09-
|
9
|
+
s.date = %q{2011-09-27}
|
10
10
|
s.description = %q{An IRB alternative and runtime developer console}
|
11
11
|
s.email = %q{jrmair@gmail.com}
|
12
12
|
s.executables = [%q{pry}]
|
13
|
-
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
13
|
+
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/method.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/rbx_method.rb}, %q{lib/pry/rbx_path.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
14
14
|
s.homepage = %q{http://pry.github.com}
|
15
15
|
s.require_paths = [%q{lib}]
|
16
16
|
s.rubygems_version = %q{1.8.6}
|
17
17
|
s.summary = %q{An IRB alternative and runtime developer console}
|
18
|
-
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}]
|
18
|
+
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}]
|
19
19
|
|
20
20
|
if s.respond_to? :specification_version then
|
21
21
|
s.specification_version = 3
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency(%q<method_source>, [">= 0.6.5"])
|
28
28
|
s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
|
29
29
|
s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
|
30
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
30
31
|
else
|
31
32
|
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
32
33
|
s.add_dependency(%q<coderay>, [">= 0.9.8"])
|
@@ -34,6 +35,7 @@ Gem::Specification.new do |s|
|
|
34
35
|
s.add_dependency(%q<method_source>, [">= 0.6.5"])
|
35
36
|
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
36
37
|
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
38
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
37
39
|
end
|
38
40
|
else
|
39
41
|
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
@@ -42,5 +44,6 @@ Gem::Specification.new do |s|
|
|
42
44
|
s.add_dependency(%q<method_source>, [">= 0.6.5"])
|
43
45
|
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
44
46
|
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
47
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
45
48
|
end
|
46
49
|
end
|
data/test/helper.rb
CHANGED
@@ -5,73 +5,5 @@ describe Pry::Helpers::CommandHelpers do
|
|
5
5
|
@helper = Pry::Helpers::CommandHelpers
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
it 'should look up instance methods if no methods available and no options provided' do
|
10
|
-
klass = Class.new { def hello; end }
|
11
|
-
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
12
|
-
meth.should == klass.instance_method(:hello)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should look up methods if no instance methods available and no options provided' do
|
16
|
-
klass = Class.new { def self.hello; end }
|
17
|
-
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
18
|
-
meth.should == klass.method(:hello)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should look up instance methods first even if methods available and no options provided' do
|
22
|
-
klass = Class.new { def hello; end; def self.hello; end }
|
23
|
-
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
24
|
-
meth.should == klass.instance_method(:hello)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should look up instance methods if "instance-methods" option provided' do
|
28
|
-
klass = Class.new { def hello; end; def self.hello; end }
|
29
|
-
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {"instance-methods" => true})
|
30
|
-
meth.should == klass.instance_method(:hello)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should look up methods if :methods option provided' do
|
34
|
-
klass = Class.new { def hello; end; def self.hello; end }
|
35
|
-
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {:methods => true})
|
36
|
-
meth.should == klass.method(:hello)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should look up instance methods using the Class#method syntax' do
|
40
|
-
klass = Class.new { def hello; end; def self.hello; end }
|
41
|
-
meth = @helper.get_method_object("klass#hello", Pry.binding_for(binding), {})
|
42
|
-
meth.should == klass.instance_method(:hello)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should look up methods using the object.method syntax' do
|
46
|
-
klass = Class.new { def hello; end; def self.hello; end }
|
47
|
-
meth = @helper.get_method_object("klass.hello", Pry.binding_for(binding), {})
|
48
|
-
meth.should == klass.method(:hello)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should NOT look up instance methods using the Class#method syntax if no instance methods defined' do
|
52
|
-
klass = Class.new { def self.hello; end }
|
53
|
-
meth = @helper.get_method_object("klass#hello", Pry.binding_for(binding), {})
|
54
|
-
meth.should == nil
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should NOT look up methods using the object.method syntax if no methods defined' do
|
58
|
-
klass = Class.new { def hello; end }
|
59
|
-
meth = @helper.get_method_object("klass.hello", Pry.binding_for(binding), {})
|
60
|
-
meth.should == nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should look up methods using klass.new.method syntax' do
|
64
|
-
klass = Class.new { def hello; :hello; end }
|
65
|
-
meth = @helper.get_method_object("klass.new.hello", Pry.binding_for(binding), {})
|
66
|
-
meth.name.to_sym.should == :hello
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should look up instance methods using klass.meth#method syntax' do
|
70
|
-
klass = Class.new { def self.meth; Class.new; end }
|
71
|
-
meth = @helper.get_method_object("klass.meth#initialize", Pry.binding_for(binding), {})
|
72
|
-
meth.name.to_sym.should == :initialize
|
73
|
-
end
|
74
|
-
end
|
8
|
+
# FIXME: currently no tests
|
75
9
|
end
|
76
|
-
|
77
|
-
|
data/test/test_command_set.rb
CHANGED
@@ -3,6 +3,7 @@ require 'helper'
|
|
3
3
|
describe Pry::CommandSet do
|
4
4
|
before do
|
5
5
|
@set = Pry::CommandSet.new
|
6
|
+
@ctx = Pry::CommandContext.new
|
6
7
|
end
|
7
8
|
|
8
9
|
it 'should call the block used for the command when it is called' do
|
@@ -11,7 +12,7 @@ describe Pry::CommandSet do
|
|
11
12
|
run = true
|
12
13
|
end
|
13
14
|
|
14
|
-
@set.run_command
|
15
|
+
@set.run_command @ctx, 'foo'
|
15
16
|
run.should == true
|
16
17
|
end
|
17
18
|
|
@@ -20,21 +21,23 @@ describe Pry::CommandSet do
|
|
20
21
|
args.should == [1, 2, 3]
|
21
22
|
end
|
22
23
|
|
23
|
-
@set.run_command
|
24
|
+
@set.run_command @ctx, 'foo', 1, 2, 3
|
24
25
|
end
|
25
26
|
|
26
27
|
it 'should use the first argument as self' do
|
28
|
+
ctx = @ctx
|
29
|
+
|
27
30
|
@set.command 'foo' do
|
28
|
-
self.should ==
|
31
|
+
self.should == ctx
|
29
32
|
end
|
30
33
|
|
31
|
-
@set.run_command
|
34
|
+
@set.run_command @ctx, 'foo'
|
32
35
|
end
|
33
36
|
|
34
37
|
it 'should raise an error when calling an undefined command' do
|
35
38
|
@set.command('foo') {}
|
36
39
|
lambda {
|
37
|
-
@set.run_command
|
40
|
+
@set.run_command @ctx, 'bar'
|
38
41
|
}.should.raise(Pry::NoCommandError)
|
39
42
|
end
|
40
43
|
|
@@ -43,7 +46,7 @@ describe Pry::CommandSet do
|
|
43
46
|
@set.delete 'foo'
|
44
47
|
|
45
48
|
lambda {
|
46
|
-
@set.run_command
|
49
|
+
@set.run_command @ctx, 'foo'
|
47
50
|
}.should.raise(Pry::NoCommandError)
|
48
51
|
end
|
49
52
|
|
@@ -57,11 +60,11 @@ describe Pry::CommandSet do
|
|
57
60
|
|
58
61
|
@set.import_from(other_set, 'foo')
|
59
62
|
|
60
|
-
@set.run_command
|
63
|
+
@set.run_command @ctx, 'foo'
|
61
64
|
run.should == true
|
62
65
|
|
63
66
|
lambda {
|
64
|
-
@set.run_command
|
67
|
+
@set.run_command @ctx, 'bar'
|
65
68
|
}.should.raise(Pry::NoCommandError)
|
66
69
|
end
|
67
70
|
|
@@ -75,8 +78,8 @@ describe Pry::CommandSet do
|
|
75
78
|
|
76
79
|
@set.import other_set
|
77
80
|
|
78
|
-
@set.run_command
|
79
|
-
@set.run_command
|
81
|
+
@set.run_command @ctx, 'foo'
|
82
|
+
@set.run_command @ctx, 'bar'
|
80
83
|
run.should == [true, true]
|
81
84
|
end
|
82
85
|
|
@@ -84,7 +87,7 @@ describe Pry::CommandSet do
|
|
84
87
|
run = false
|
85
88
|
@set.command('foo') { run = true }
|
86
89
|
|
87
|
-
Pry::CommandSet.new(@set).run_command
|
90
|
+
Pry::CommandSet.new(@set).run_command @ctx, 'foo'
|
88
91
|
run.should == true
|
89
92
|
end
|
90
93
|
|
@@ -101,7 +104,7 @@ describe Pry::CommandSet do
|
|
101
104
|
@set.commands['bar'].name.should == 'bar'
|
102
105
|
@set.commands['bar'].description.should == ''
|
103
106
|
|
104
|
-
@set.run_command
|
107
|
+
@set.run_command @ctx, 'bar'
|
105
108
|
run.should == true
|
106
109
|
end
|
107
110
|
|
@@ -114,17 +117,17 @@ describe Pry::CommandSet do
|
|
114
117
|
|
115
118
|
it 'should return Pry::CommandContext::VOID_VALUE for commands by default' do
|
116
119
|
@set.command('foo') { 3 }
|
117
|
-
@set.run_command(
|
120
|
+
@set.run_command(@ctx, 'foo').should == Pry::CommandContext::VOID_VALUE
|
118
121
|
end
|
119
122
|
|
120
123
|
it 'should be able to keep return values' do
|
121
124
|
@set.command('foo', '', :keep_retval => true) { 3 }
|
122
|
-
@set.run_command(
|
125
|
+
@set.run_command(@ctx, 'foo').should == 3
|
123
126
|
end
|
124
127
|
|
125
128
|
it 'should be able to keep return values, even if return value is nil' do
|
126
129
|
@set.command('foo', '', :keep_retval => true) { nil }
|
127
|
-
@set.run_command(
|
130
|
+
@set.run_command(@ctx, 'foo').should == nil
|
128
131
|
end
|
129
132
|
|
130
133
|
it 'should be able to have its own helpers' do
|
@@ -136,7 +139,7 @@ describe Pry::CommandSet do
|
|
136
139
|
def my_helper; end
|
137
140
|
end
|
138
141
|
|
139
|
-
@set.run_command(
|
142
|
+
@set.run_command(@ctx, 'foo')
|
140
143
|
Pry::CommandContext.new.should.not.respond_to :my_helper
|
141
144
|
end
|
142
145
|
|
@@ -154,7 +157,7 @@ describe Pry::CommandSet do
|
|
154
157
|
def my_other_helper; end
|
155
158
|
end
|
156
159
|
|
157
|
-
@set.run_command(
|
160
|
+
@set.run_command(@ctx, 'foo')
|
158
161
|
end
|
159
162
|
|
160
163
|
it 'should import helpers from imported sets' do
|
@@ -166,7 +169,7 @@ describe Pry::CommandSet do
|
|
166
169
|
|
167
170
|
@set.import imported_set
|
168
171
|
@set.command('foo') { should.respond_to :imported_helper_method }
|
169
|
-
@set.run_command(
|
172
|
+
@set.run_command(@ctx, 'foo')
|
170
173
|
end
|
171
174
|
|
172
175
|
it 'should import helpers even if only some commands are imported' do
|
@@ -180,7 +183,7 @@ describe Pry::CommandSet do
|
|
180
183
|
|
181
184
|
@set.import_from imported_set, 'bar'
|
182
185
|
@set.command('foo') { should.respond_to :imported_helper_method }
|
183
|
-
@set.run_command(
|
186
|
+
@set.run_command(@ctx, 'foo')
|
184
187
|
end
|
185
188
|
|
186
189
|
it 'should provide a :listing for a command that defaults to its name' do
|
@@ -194,12 +197,11 @@ describe Pry::CommandSet do
|
|
194
197
|
end
|
195
198
|
|
196
199
|
it "should provide a 'help' command" do
|
197
|
-
|
198
|
-
|
199
|
-
context.output = StringIO.new
|
200
|
+
@ctx.command_set = @set
|
201
|
+
@ctx.output = StringIO.new
|
200
202
|
|
201
203
|
lambda {
|
202
|
-
@set.run_command(
|
204
|
+
@set.run_command(@ctx, 'help')
|
203
205
|
}.should.not.raise
|
204
206
|
end
|
205
207
|
|
@@ -209,13 +211,12 @@ describe Pry::CommandSet do
|
|
209
211
|
@set.command 'moo', "Mooerizes" do; end
|
210
212
|
@set.command 'boo', "Booerizes" do; end
|
211
213
|
|
212
|
-
|
213
|
-
|
214
|
-
context.output = StringIO.new
|
214
|
+
@ctx.command_set = @set
|
215
|
+
@ctx.output = StringIO.new
|
215
216
|
|
216
|
-
@set.run_command(
|
217
|
+
@set.run_command(@ctx, 'help')
|
217
218
|
|
218
|
-
doc =
|
219
|
+
doc = @ctx.output.string
|
219
220
|
|
220
221
|
order = [doc.index("boo"),
|
221
222
|
doc.index("foo"),
|
@@ -211,6 +211,11 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
211
211
|
}
|
212
212
|
mock_pry("edit -n").should.not =~ /FOO/
|
213
213
|
end
|
214
|
+
|
215
|
+
it "should edit the nth line of _in_" do
|
216
|
+
mock_pry("10", "11", "edit --in -2")
|
217
|
+
@contents.should == "10\n"
|
218
|
+
end
|
214
219
|
end
|
215
220
|
end
|
216
221
|
|
data/test/test_method.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Pry::Method do
|
4
|
+
describe ".from_str" do
|
5
|
+
it 'should look up instance methods if no methods available and no options provided' do
|
6
|
+
klass = Class.new { def hello; end }
|
7
|
+
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass))
|
8
|
+
meth.should == klass.instance_method(:hello)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should look up methods if no instance methods available and no options provided' do
|
12
|
+
klass = Class.new { def self.hello; end }
|
13
|
+
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass))
|
14
|
+
meth.should == klass.method(:hello)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should look up instance methods first even if methods available and no options provided' do
|
18
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
19
|
+
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass))
|
20
|
+
meth.should == klass.instance_method(:hello)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should look up instance methods if "instance-methods" option provided' do
|
24
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
25
|
+
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {"instance-methods" => true})
|
26
|
+
meth.should == klass.instance_method(:hello)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should look up methods if :methods option provided' do
|
30
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
31
|
+
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {:methods => true})
|
32
|
+
meth.should == klass.method(:hello)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should look up instance methods using the Class#method syntax' do
|
36
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
37
|
+
meth = Pry::Method.from_str("klass#hello", Pry.binding_for(binding))
|
38
|
+
meth.should == klass.instance_method(:hello)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should look up methods using the object.method syntax' do
|
42
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
43
|
+
meth = Pry::Method.from_str("klass.hello", Pry.binding_for(binding))
|
44
|
+
meth.should == klass.method(:hello)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should NOT look up instance methods using the Class#method syntax if no instance methods defined' do
|
48
|
+
klass = Class.new { def self.hello; end }
|
49
|
+
meth = Pry::Method.from_str("klass#hello", Pry.binding_for(binding))
|
50
|
+
meth.should == nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should NOT look up methods using the object.method syntax if no methods defined' do
|
54
|
+
klass = Class.new { def hello; end }
|
55
|
+
meth = Pry::Method.from_str("klass.hello", Pry.binding_for(binding))
|
56
|
+
meth.should == nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should look up methods using klass.new.method syntax' do
|
60
|
+
klass = Class.new { def hello; :hello; end }
|
61
|
+
meth = Pry::Method.from_str("klass.new.hello", Pry.binding_for(binding))
|
62
|
+
meth.name.to_sym.should == :hello
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should look up instance methods using klass.meth#method syntax' do
|
66
|
+
klass = Class.new { def self.meth; Class.new; end }
|
67
|
+
meth = Pry::Method.from_str("klass.meth#initialize", Pry.binding_for(binding))
|
68
|
+
meth.name.to_sym.should == :initialize
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|