Class: Fit::PrimitiveFixture

Inherits:
Fixture
  • Object
show all
Defined in:
lib/fit/primitive_fixture.rb

Direct Known Subclasses

Eg::ArithmeticFixture, Fat::Color, Fat::Equals

Constant Summary

Constants inherited from Fixture

Fixture::GRAY, Fixture::GREEN, Fixture::RED, Fixture::YELLOW

Instance Attribute Summary

Attributes inherited from Fixture

#args, #counts, #listener, #summary

Instance Method Summary collapse

Methods inherited from Fixture

camel, #do_cell, #do_cells, #do_row, #do_rows, #do_table, #do_tables, #error, escape, #exception, #find_class, #fixture_name, #get_args_for_table, #get_linked_fixture_with_args, gray, #ignore, #info, #initialize, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong

Constructor Details

This class inherits a constructor from Fit::Fixture

Instance Method Details

#check(cell, expected, value) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/fit/primitive_fixture.rb', line 42

def check cell, expected, value
  if expected == value
    right cell
  else
    wrong cell, value
  end
end

#check_boolean(cell, value) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/fit/primitive_fixture.rb', line 34

def check_boolean cell, value
  if value == parse_boolean(cell)
    right cell
  else
    wrong cell, value.to_s
  end
end

#check_value(cell, value) ⇒ Object

Answer comparison



26
27
28
29
30
31
32
# File 'lib/fit/primitive_fixture.rb', line 26

def check_value cell, value
  if value.to_s == cell.text
    right cell
  else
    wrong cell, value.to_s
  end
end

#parse_boolean(cell) ⇒ Object



20
21
22
# File 'lib/fit/primitive_fixture.rb', line 20

def parse_boolean cell
  cell.text.downcase == 'true' ? true : false
end

#parse_double(cell) ⇒ Object



16
17
18
# File 'lib/fit/primitive_fixture.rb', line 16

def parse_double cell
  Float cell.text
end

#parse_integer(cell) ⇒ Object

Format converters



12
13
14
# File 'lib/fit/primitive_fixture.rb', line 12

def parse_integer cell
  Integer cell.text
end