Class: GreenPepper::DoWithLineCheck

Inherits:
DoWithLine show all
Defined in:
lib/greenpepper/example/dowithexample.rb

Instance Attribute Summary

Attributes inherited from DoWithLine

#function, #parameters, #result_column

Instance Method Summary collapse

Methods inherited from DoWithLine

#accept?, #function?, #reject?

Constructor Details

#initialize(func, column, expected_value, params) ⇒ DoWithLineCheck

Returns a new instance of DoWithLineCheck.



135
136
137
138
# File 'lib/greenpepper/example/dowithexample.rb', line 135

def initialize(func, column, expected_value, params)
  super func, column, params
  @expected_value = expected_value
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/greenpepper/example/dowithexample.rb', line 158

def check?
  true
end

#execute(fixture) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/greenpepper/example/dowithexample.rb', line 140

def execute(fixture)
  res = call_func fixture
  #For Check functions, we need to have a way in the fixture to 
  #convert the string in the fixture. The function called by the
  #converter will be parse_check_#{@function}
  expected = TypeConverter.instance.auto_convert_string(
      fixture, 'check_' + @function, @expected_value)
  return SuccessExampleResult.new if res == expected

  formated_result = TypeConverter.instance.auto_convert_object(
      fixture, 
      'check_' + @function, 
      @expected_value,
      res)

  WriteExpectedExampleResult.new formated_result, @expected_value
end