Class: Assert::ContextInfo
- Inherits:
-
Object
- Object
- Assert::ContextInfo
- Defined in:
- lib/assert/context_info.rb
Instance Attribute Summary collapse
-
#called_from ⇒ Object
readonly
Returns the value of attribute called_from.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(klass, called_from = nil, first_caller = nil) ⇒ ContextInfo
constructor
A new instance of ContextInfo.
- #test_name(name) ⇒ Object
Constructor Details
#initialize(klass, called_from = nil, first_caller = nil) ⇒ ContextInfo
Returns a new instance of ContextInfo.
7 8 9 10 11 |
# File 'lib/assert/context_info.rb', line 7 def initialize(klass, called_from = nil, first_caller = nil) @called_from = called_from || first_caller @klass = klass @file = @called_from.to_s.gsub(/\:[0-9]+.*$/, '') if @called_from end |
Instance Attribute Details
#called_from ⇒ Object (readonly)
Returns the value of attribute called_from.
5 6 7 |
# File 'lib/assert/context_info.rb', line 5 def called_from @called_from end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/assert/context_info.rb', line 5 def file @file end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/assert/context_info.rb', line 5 def klass @klass end |
Instance Method Details
#test_name(name) ⇒ Object
13 14 15 |
# File 'lib/assert/context_info.rb', line 13 def test_name(name) [klass.description.to_s, name.to_s].compact.reject(&:empty?).join(' ') end |