Module: RSpec::Covers::MethodLabel
- Defined in:
- lib/rspec/covers/method_label.rb
Class Method Summary collapse
- .from_trace_point(trace_point) ⇒ Object
- .instance(owner, method_name) ⇒ Object
- .owner_name(owner) ⇒ Object
- .singleton(owner, method_name) ⇒ Object
- .singleton_owner?(owner) ⇒ Boolean
Class Method Details
.from_trace_point(trace_point) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rspec/covers/method_label.rb', line 16 def from_trace_point(trace_point) owner = trace_point.defined_class if singleton_owner?(owner) singleton(trace_point.self.is_a?(Module) ? trace_point.self : trace_point.self.class, trace_point.method_id) else instance(owner, trace_point.method_id) end end |
.instance(owner, method_name) ⇒ Object
8 9 10 |
# File 'lib/rspec/covers/method_label.rb', line 8 def instance(owner, method_name) "#{owner_name(owner)}##{method_name}" end |
.owner_name(owner) ⇒ Object
26 27 28 29 30 |
# File 'lib/rspec/covers/method_label.rb', line 26 def owner_name(owner) return owner.name if owner.respond_to?(:name) && owner.name owner.to_s end |
.singleton(owner, method_name) ⇒ Object
12 13 14 |
# File 'lib/rspec/covers/method_label.rb', line 12 def singleton(owner, method_name) "#{owner_name(owner)}.#{method_name}" end |
.singleton_owner?(owner) ⇒ Boolean
32 33 34 |
# File 'lib/rspec/covers/method_label.rb', line 32 def singleton_owner?(owner) owner.inspect.start_with?("#<Class:") end |