5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/rspec/describe_method/class_extensions.rb', line 5
def describe_method( method, *args, &block )
throw ArgumentError.new 'Supplied method must be a String' unless method.kind_of? String
throw ArgumentError.new 'No block supplied to .describe_method' unless block.kind_of? Proc
describe "when calling #{method}" do
subject do
old = super()
case method[0]
when '#' if old.kind_of? Class then old.new else old end
when '.' if old.kind_of? Class then old else old.class end
else throw ArgumentError.new 'describe_method expects method name to begin with # or .'
end.send method[1..-1], *args
end
instance_eval &block
end
end
|