Class: GreenPepper::RuleForOutputHeader

Inherits:
ExampleBaseHeader
  • Object
show all
Defined in:
lib/greenpepper/example/ruleforexample.rb

Instance Method Summary collapse

Instance Method Details

#execute(value, fixture, value_format) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/greenpepper/example/ruleforexample.rb', line 81

def execute(value, fixture, value_format)
  return NoExampleResult.new if !fixture.respond_to? @formated_name

  begin
    result = get_result fixture
  rescue Exception => e
    if value.is_a? Exception
      return SuccessExampleResult.new
    end
    return WriteExceptionExampleResult.new(e)
  end

  return SuccessExampleResult.new if value == result

  formated_result = TypeConverter.instance.auto_convert_object(
    fixture,
    @name,
    value_format,
    result)

  formated_value = TypeConverter.instance.auto_convert_object(
    fixture,
    @name,
    value_format,
    value)

  return WriteIgnoredExampleResult.new(formated_result) if value == ''
  return WriteExpectedExampleResult.new(formated_value, formated_result)
end