Class: Fat::StandardAnnotationFixture

Inherits:
Fit::ColumnFixture show all
Defined in:
lib/fat/standard_annotation_fixture.rb

Constant Summary

Constants inherited from Fit::Fixture

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

Instance Attribute Summary collapse

Attributes inherited from Fit::Fixture

#args, #counts, #listener, #summary

Instance Method Summary collapse

Methods inherited from Fit::ColumnFixture

#check, #do_row, #do_rows, #execute, #reset

Methods inherited from Fit::Fixture

camel, #check, #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, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong

Constructor Details

#initializeStandardAnnotationFixture

Returns a new instance of StandardAnnotationFixture.



13
14
15
16
# File 'lib/fat/standard_annotation_fixture.rb', line 13

def initialize
  super
  @original_html = 'Text'
end

Instance Attribute Details

#annotationObject

Returns the value of attribute annotation.



11
12
13
# File 'lib/fat/standard_annotation_fixture.rb', line 11

def annotation
  @annotation
end

#original_htmlObject

Returns the value of attribute original_html.



11
12
13
# File 'lib/fat/standard_annotation_fixture.rb', line 11

def original_html
  @original_html
end

#textObject

Returns the value of attribute text.



11
12
13
# File 'lib/fat/standard_annotation_fixture.rb', line 11

def text
  @text
end

Instance Method Details

#do_cell(cell, column) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fat/standard_annotation_fixture.rb', line 32

def do_cell cell, column
  begin
    if column == 4
      cell.body = rendered_output
    else
      super
    end
  rescue Exception => e
    exception cell, e
  end
end

#outputObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fat/standard_annotation_fixture.rb', line 18

def output
  parse = Fit::Parse.new @original_html, ['td']
  testbed = Fit::Fixture.new
  case @annotation
    when 'right' then testbed.right(parse)
    when 'wrong' then testbed.wrong(parse, @text)
    when 'error' then testbed.error(parse, @text)
    when 'info' then testbed.info(parse, @text)
    when 'ignore' then testbed.ignore(parse)
    else return "unknown type: #@type"
  end
  generate_output parse
end

#rendered_outputObject



44
45
46
# File 'lib/fat/standard_annotation_fixture.rb', line 44

def rendered_output
  '<table border="1"><tr>' + output + '</tr></table>'
end