File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 4
4
describe :method_to_s , shared : true do
5
5
before :each do
6
6
@m = MethodSpecs ::MySub . new . method :bar
7
- @string = @m . send ( @method ) . sub ( /0x \w +/ , '0xXXXXXX' )
7
+ @string = @m . send ( @method )
8
8
end
9
9
10
10
it "returns a String" do
32
32
@string . should =~ /MethodSpecs::MySub/
33
33
end
34
34
35
+ it "returns a String including all details" do
36
+ @string . should . start_with? "#<Method: MethodSpecs::MySub(MethodSpecs::MyMod)#bar"
37
+ end
38
+
39
+ it "does not show the defining module if it is the same as the receiver class" do
40
+ MethodSpecs ::A . new . method ( :baz ) . send ( @method ) . should . start_with? "#<Method: MethodSpecs::A#baz"
41
+ end
42
+
35
43
ruby_version_is '3.0' do
36
44
it "returns a String containing the Module containing the method if object has a singleton class but method is not defined in the singleton class" do
37
45
obj = MethodSpecs ::MySub . new
38
46
obj . singleton_class
39
47
@m = obj . method ( :bar )
40
- @string = @m . send ( @method ) . sub ( /0x \w +/ , '0xXXXXXX' )
41
- @string . should =~ / \A #<Method: MethodSpecs::MySub\ ( MethodSpecs::MyMod\ ) #bar\( \) /
48
+ @string = @m . send ( @method )
49
+ @string . should . start_with? " #<Method: MethodSpecs::MySub(MethodSpecs::MyMod)#bar"
42
50
end
43
51
end
44
52
45
53
it "returns a String containing the singleton class if method is defined in the singleton class" do
46
54
obj = MethodSpecs ::MySub . new
47
55
def obj . bar ; end
48
56
@m = obj . method ( :bar )
49
- @string = @m . send ( @method ) . sub ( /0x\w +/ , '0xXXXXXX' )
50
- @string . should =~ / \A #<Method: #<MethodSpecs::MySub:0xXXXXXX>\ . bar/
57
+ @string = @m . send ( @method ) . sub ( /0x\h +/ , '0xXXXXXX' )
58
+ @string . should . start_with? " #<Method: #<MethodSpecs::MySub:0xXXXXXX>.bar"
51
59
end
52
60
end
Original file line number Diff line number Diff line change 22
22
@from_module . send ( @method ) . should =~ /\b UnboundMethodSpecs::Mod\b /
23
23
@from_method . send ( @method ) . should =~ /\b UnboundMethodSpecs::Methods\b /
24
24
end
25
+
26
+ it "returns a String including all details" do
27
+ @from_module . send ( @method ) . should . start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod"
28
+ @from_method . send ( @method ) . should . start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod"
29
+ end
30
+
31
+ it "does not show the defining module if it is the same as the origin" do
32
+ UnboundMethodSpecs ::A . instance_method ( :baz ) . send ( @method ) . should . start_with? "#<UnboundMethod: UnboundMethodSpecs::A#baz"
33
+ end
25
34
end
You can’t perform that action at this time.
0 commit comments