forked from pry/pry-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.rb
executable file
·76 lines (64 loc) · 1.96 KB
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
direc = File.dirname(__FILE__)
require 'rubygems'
require 'pry'
require "#{direc}/../lib/pry-doc"
require "#{direc}/test_helper"
require 'bacon'
require 'set'
puts "Testing pry-doc version #{PryDoc::VERSION}..."
puts "Ruby version: #{RUBY_VERSION}"
describe PryDoc do
describe "core C methods" do
it 'should look up core (C) methods' do
obj = Pry::MethodInfo.info_for(method(:puts))
obj.source.should.not == nil
end
it 'should look up core (C) instance methods' do
Module.module_eval do
obj = Pry::MethodInfo.info_for(instance_method(:include))
obj.source.should.not == nil
end
end
it 'should look up core (C) class method (by Method object)' do
Module.module_eval do
obj = Pry::MethodInfo.info_for(Dir.method(:glob))
obj.source.should.not == nil
end
end
it 'should look up core (C) class method (by UnboundMethod object)' do
Module.module_eval do
obj = Pry::MethodInfo.info_for(class << Dir; instance_method(:glob); end)
obj.source.should.not == nil
end
end
end
describe "eval methods" do
it 'should return nil for eval methods' do
eval("def hello; end")
obj = Pry::MethodInfo.info_for(method(:hello))
obj.should == nil
end
end
describe "pure ruby methods" do
it 'should look up ruby methods' do
obj = Pry::MethodInfo.info_for(C.new.method(:message))
obj.should.not == nil
end
it 'should look up ruby instance methods' do
obj = Pry::MethodInfo.info_for(C.instance_method(:message))
obj.should.not == nil
end
end
describe "Ruby stdlib methods" do
it "should look up ruby stdlib method" do
obj = Pry::MethodInfo.info_for(Set.instance_method(:union))
obj.should.not == nil
end
end
describe "C stdlib methods" do
it "should return nil for C stdlib methods" do
obj = Pry::MethodInfo.info_for(Readline.method(:readline))
obj.should == nil
end
end
end