Class: GoldmasterTestCase

Inherits:
ConcordionTestCase show all
Defined in:
lib/goldmaster_test_case.rb

Instance Method Summary collapse

Methods inherited from ConcordionTestCase

inherited, #is_trivial?, original_inherited, #test_something_trivial_to_shut_runit_up, #trivial

Methods included from ConcordionConfigMethods

#bind_test_method_to, #default_config

Methods included from ConcordionInternalTestMethods

#assert_concordion_document, #assert_no_failures, #parse_spec, #report_spec, #run_spec, #show_failures

Methods included from ConcordionUtility

#concordion_arguments, #concordion_cmd_attr_exists?, #concordion_cmd_attr_for, #concordion_property_reference, #concordion_variable_name, #has_property_reference?, #instrumentation, #supported_and_instrumented?

Methods included from ConcordionConvenience

#methods_for

Methods included from ConcordionStringUtility

#assignment, #attr_writer_method?, #concordion_assignment, #concordion_method_name, #ends_in_empty_parens?, #escape_single_quotes, #has_arguments?, #has_assignment?, #is_direct_method_call?

Methods included from PluralToSingularUtility

#singular

Methods included from SnakeCaseUtility

#snake_case, #snake_cased_goldmaster_name, #snake_cased_test_name

Methods included from ConcordionConstants

#concordion_command_attributes, #supported?

Constructor Details

#initialize(suite, conf = {}) ⇒ GoldmasterTestCase

Returns a new instance of GoldmasterTestCase.



9
10
11
12
13
14
15
# File 'lib/goldmaster_test_case.rb', line 9

def initialize(suite, conf = {})
  @writer = ConcordionStringWriter.new

  config = ConcordionTestCase.default_config.merge(conf)
  @write_goldmaster = config[:write_goldmaster]    
  super(suite, config)
end

Instance Method Details

#meths(o) ⇒ Object



46
47
48
# File 'lib/goldmaster_test_case.rb', line 46

def meths(o)
  (o.methods - Object.methods).sort
end

#rcor_writerObject



17
18
19
# File 'lib/goldmaster_test_case.rb', line 17

def rcor_writer
  @writer
end

#teardownObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/goldmaster_test_case.rb', line 25

def teardown
  if self.class.method_defined?(:write_goldmaster!)
    ConcordionWriter.new.write(@writer.data, snake_cased_goldmaster_name(self.class.to_s))

    assert false, "Disable write to goldmaster (erase write_goldmaster! in #{self.class})"
  end
  
  unless is_trivial?
    goldmaster = ConcordionReader.new.read(snake_cased_goldmaster_name(self.class.to_s))
    assert @writer.data.size > 0

    diffs = Diff::LCS.diff(@writer.data, goldmaster)
    pos = diffs[0].entries[0].position
    context_exp = goldmaster.slice(pos - 50, 100)
    context_act = @writer.data.slice(pos - 50, 100)
    
    assert_equal @writer.data, goldmaster, "First difference at #{pos} bytes into goldmaster:\n(#{context_exp}) goldmaster vs\n(#{context_act}) actual"
  end

end

#test_specObject



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

def test_spec
  trivial
end