Class: JsonRspecMatchMaker::TargetValue

Inherits:
Object
  • Object
show all
Defined in:
lib/json_rspec_match_maker/target_value.rb

Overview

Handles fetching the target value from the target object

Constant Summary collapse

NUMBER =
/^\d+$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, target) ⇒ TargetValue

Returns a new instance of TargetValue.



10
11
12
13
# File 'lib/json_rspec_match_maker/target_value.rb', line 10

def initialize(key, target)
  @error_key = key
  @value = value_for_key(key, target)
end

Instance Attribute Details

#error_keyObject (readonly)

Returns the value of attribute error_key.



6
7
8
# File 'lib/json_rspec_match_maker/target_value.rb', line 6

def error_key
  @error_key
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/json_rspec_match_maker/target_value.rb', line 6

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
# File 'lib/json_rspec_match_maker/target_value.rb', line 15

def ==(other)
  raise ArgumentError unless other.is_a? ExpectedValue
  other.value == value
end