that_object_is_so_basic 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toisb/version.rb +1 -1
- data/lib/toisb/wrapper.rb +13 -1
- data/uspec/wrapper_spec.rb +27 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8be7b4a1087d0056cc8d2df54495cc2bb7cf48d6596882fc2caca31be68f50d9
|
4
|
+
data.tar.gz: c7390074074b3c5731a7caf870b3de1a55d07930c6bc3f9b0bf17d4fa1ee49a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5868ebf2199362ea9b57c80a741930fa78f76569aad23c17facd9c96b93daa9c08ef9ff10e4db786117082003419f2171d2870e0d88e11f8e814f73e83234a1f
|
7
|
+
data.tar.gz: 472d1a89f3cb15c5cf2df1fb973c43d085385216acd9f875a357cb38e1adc1c4853ba58697bba48933a3219302ed19fbe921c54cd9e9f0918307ff78372c68b8
|
data/lib/toisb/version.rb
CHANGED
data/lib/toisb/wrapper.rb
CHANGED
@@ -19,7 +19,19 @@ module TOISB; class Wrapper
|
|
19
19
|
|
20
20
|
# Simple inspect-ish output with a low chance of failure
|
21
21
|
def simple_inspector
|
22
|
-
"#<#{
|
22
|
+
"#<#{klassinfo}:0x#{get_id}>"
|
23
|
+
end
|
24
|
+
|
25
|
+
# show a nicely formated version of the class and its superclass
|
26
|
+
# displays it in the style of a path, with the superclass as the parent directory
|
27
|
+
def klassinfo
|
28
|
+
[superklass, klass].compact.join "/"
|
29
|
+
end
|
30
|
+
|
31
|
+
# show a nicely formated version of the class and its superclass
|
32
|
+
# displays it in the same style as the class definition
|
33
|
+
def subklassinfo
|
34
|
+
[klass, superklass].compact.join " < "
|
23
35
|
end
|
24
36
|
|
25
37
|
# Obtain the singleton class of an object
|
data/uspec/wrapper_spec.rb
CHANGED
@@ -4,6 +4,8 @@ class ::TestObject < BasicObject; end
|
|
4
4
|
obj = ::TestObject.new
|
5
5
|
toisb = TOISB.wrap obj
|
6
6
|
|
7
|
+
bowrap = TOISB.wrap BasicObject.new
|
8
|
+
|
7
9
|
spec "can inspect BasicObject subclasses" do
|
8
10
|
expected = "BasicObject/TestObject"
|
9
11
|
actual = toisb.inspector
|
@@ -37,7 +39,7 @@ end
|
|
37
39
|
|
38
40
|
spec "can get the superclass (nil) of a BasicObject" do
|
39
41
|
expected = nil
|
40
|
-
actual =
|
42
|
+
actual = bowrap.superklass
|
41
43
|
actual == expected || actual
|
42
44
|
end
|
43
45
|
|
@@ -59,3 +61,27 @@ spec "#inspector! doesn't mask exceptions if the associated inspect method fails
|
|
59
61
|
error.message.include?("supposed to fail") || error
|
60
62
|
end
|
61
63
|
end
|
64
|
+
|
65
|
+
spec "generates correct klassinfo for BasicObject" do
|
66
|
+
expected = "BasicObject"
|
67
|
+
actual = bowrap.klassinfo
|
68
|
+
actual == expected || actual
|
69
|
+
end
|
70
|
+
|
71
|
+
spec "generates correct subklassinfo for BasicObject" do
|
72
|
+
expected = "BasicObject"
|
73
|
+
actual = bowrap.subklassinfo
|
74
|
+
actual == expected || actual
|
75
|
+
end
|
76
|
+
|
77
|
+
spec "generates correct klassinfo for BasicObject subclasses" do
|
78
|
+
expected = "BasicObject/TestObject"
|
79
|
+
actual = toisb.klassinfo
|
80
|
+
actual == expected || actual
|
81
|
+
end
|
82
|
+
|
83
|
+
spec "generates correct subklassinfo for BasicObject subclasses" do
|
84
|
+
expected = "TestObject < BasicObject"
|
85
|
+
actual = toisb.subklassinfo
|
86
|
+
actual == expected || actual
|
87
|
+
end
|