Class: ActionController::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/action_controller/response.rb

Instance Method Summary collapse

Instance Method Details

#tml_should_not_resemble(structure) ⇒ Object

Verifies that the produced TML does NOT resemble the given structure. See Rtml::Rules::DomValidation#validate_tml_dom for more information.



20
21
22
23
24
25
26
27
28
# File 'lib/extensions/action_controller/response.rb', line 20

def tml_should_not_resemble(structure)
  inspected = structure.inspect
  begin
    body.validate_tml_structure(structure)
  rescue
    return true
  end
  raise Rtml::Errors::ProcessingError, "TML was expected not to resemble #{inspected}, but it did!", caller
end

#tml_should_resemble(structure) ⇒ Object

Verifies that the produced TML resembles the given structure. See Rtml::Rules::DomValidation#validate_tml_dom for more information.



14
15
16
# File 'lib/extensions/action_controller/response.rb', line 14

def tml_should_resemble(structure)
  body.validate_tml_structure(structure)
end

#valid_tml?Boolean

Returns true if this response is well-formed XML, follows the TML syntactic rules, and has a format :rtml_helpers or :tml. Raises an error if any of these are false.

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/extensions/action_controller/response.rb', line 5

def valid_tml?
  unless template.template_format == :rtml || template.template_format == :tml
    raise "Expected format to be :rtml or :tml, found #{template.template_format.inspect}"
  end
  body.valid_tml?
end