Class: RiotRails::ActionController::RendersMacro

Inherits:
Riot::AssertionMacro
  • Object
show all
Defined in:
lib/riot/action_controller/assertion_macros.rb

Overview

Asserts that the body of the response equals or matches the expected expression. Expects actual to be the controller.

controller.renders("a bunch of html")
controller.renders(/bunch of/)

Instance Method Summary collapse

Instance Method Details

#evaluate(actual, expected) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/riot/action_controller/assertion_macros.rb', line 11

def evaluate(actual, expected)
  actual_body = actual.response.body
  if (expected.kind_of?(Regexp) ? (actual_body =~ expected) : (expected == actual_body))
    pass
  else
    verb = expected.kind_of?(Regexp) ? "match" : "equal"
    fail("expected response body #{actual_body.inspect} to #{verb} #{expected.inspect}")
  end
end