forked from jimweirich/irb-setup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlustro_test.rb
68 lines (55 loc) · 1.52 KB
/
lustro_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
require 'test/unit'
require 'shoulda'
require 'lustro'
class Parent
def im_parent; end
def self.cm_parent; end
end
class Sample < Parent
def im_sample; end
def self.cm_sample; end
end
class LustroTest < Test::Unit::TestCase
def sample_object
@sample_object ||= Sample.new
end
def methods
@methdos ||= Lustro.methods_for(sample_object)
end
context "The methods_for" do
context "a regular object" do
should "contain the sample class methods" do
assert_equal Sample, methods[0].first
assert_equal ['im_sample'], methods[0][1]
end
should "containt the parent class methods" do
assert_equal Parent, methods[1].first
assert_equal ['im_parent'], methods[1][1]
end
should 'contain the object class methods' do
assert_equal Object, methods[2].first
end
should 'contain the kernel module methods' do
k_methods = methods.assoc(Kernel)
assert_equal Kernel, k_methods.first
assert_include "to_s", k_methods[1]
end
should "be sorted" do
assert_sorted methods.assoc(Kernel)[1]
end
end
context "an object with a singleton method" do
should "have the singleton methods first" do
end
end
end
def assert_sorted(list)
list.inject { |prev, item|
assert prev < item, "#{prev} does not preceed #{item}"
item
}
end
def assert_include(expected, list)
assert list.include?(expected), "<#{expected.inspect}> not included in\n<#{list.inspect}>"
end
end