class NeuronCheckSystem::MatcherBase
Attributes
declared_caller_locations[RW]
Public Class Methods
new(expected, declared_caller_locations)
click to toggle source
# File lib/neuroncheck/matcher.rb, line 42 def initialize(expected, declared_caller_locations) @expected = expected @declared_caller_locations = declared_caller_locations end
Public Instance Methods
expected_caption()
click to toggle source
# File lib/neuroncheck/matcher.rb, line 76 def expected_caption raise NotImplementedError end
expected_short_caption()
click to toggle source
# File lib/neuroncheck/matcher.rb, line 80 def expected_short_caption @expected.inspect end
get_error_message(signature_decl, context_caption, value, phrase_after_but: 'was')
click to toggle source
# File lib/neuroncheck/matcher.rb, line 51 def get_error_message(signature_decl, context_caption, value, phrase_after_but: 'was') locs = Utils.backtrace_locations_to_captions(@declared_caller_locations) ret = "" ret.concat(<<MSG) #{context_caption} must be #{expected_caption}, but #{phrase_after_but} #{Utils.truncate(value.inspect, 40)} got: #{value.inspect} MSG if signature_decl and signature_decl.assigned_method then ret.concat(<<MSG) signature: #{signature_decl.signature_caption} MSG end if locs.size >= 1 then ret.concat(<<MSG) declared at: #{locs.join("\n" + ' ' * 15)} MSG end ret end
match?(value, self_object)
click to toggle source
# File lib/neuroncheck/matcher.rb, line 47 def match?(value, self_object) raise NotImplementedError end
meta_info_as_json()
click to toggle source
# File lib/neuroncheck/matcher.rb, line 84 def meta_info_as_json re = {} re['type'] = self.class.name.split('::')[-1] re['expected'] = @expected re end