Class: Rtml::Test::ResemblanceTest

Inherits:
Object
  • Object
show all
Defined in:
lib/rtml/test/resemblance_test.rb

Overview

Used to see if a specified TML structure (given in the form of a Hash) resembles the overall structure of the given TML document.

This is used to validate that the document conforms to a particular set of expectations without the overhead of loading it into the simulator.

This class is tied into RSpec with the #resemble_tml method, as well as into Test::Unit with the #assert_tml_resembles method:

RSpec Example

get :index
response.should resemble_tml(:tml => { :screen => [ :setvar, :submit => { :getvar } ] })

response.should_not resemble_tml(. . .) # negative test

Test::Unit Examples

get :index
assert_tml_resembles(:tml => { :screen => [ :setvar, :submit => { :getvar } ] }, response)

assert_tml_not_resemble(. . .) # negative test

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expectation, tml) ⇒ ResemblanceTest

Returns a new instance of ResemblanceTest.



31
32
33
34
35
# File 'lib/rtml/test/resemblance_test.rb', line 31

def initialize(expectation, tml)
  build_expectation(expectation)
  find_tml(tml)
  @xml = Hpricot::XML(@tml).root
end

Instance Attribute Details

#expectationObject (readonly)

Returns the value of attribute expectation.



25
26
27
# File 'lib/rtml/test/resemblance_test.rb', line 25

def expectation
  @expectation
end

#tmlObject (readonly)

Returns the value of attribute tml.



25
26
27
# File 'lib/rtml/test/resemblance_test.rb', line 25

def tml
  @tml
end

Instance Method Details

#pass?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rtml/test/resemblance_test.rb', line 27

def pass?
  pass_recursively?
end