instance method assert_template

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

assert_template(expected = nil, message=nil)

Asserts that the request was rendered with the appropriate template file.

Examples

# assert that the "new" view template was rendered
assert_template "new"

Parameters

expected opt = nil
message opt = nil
Source
# File actionpack/lib/action_controller/assertions/response_assertions.rb, line 88
      def assert_template(expected = nil, message=nil)
        clean_backtrace do
          rendered = @response.rendered_template.to_s
          msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
          assert_block(msg) do
            if expected.nil?
              @response.rendered_template.blank?
            else
              rendered.to_s.match(expected)
            end
          end
        end
      end

Defined in actionpack/lib/action_controller/assertions/response_assertions.rb line 88 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::Assertions::ResponseAssertions

Type at least 2 characters to search.

↑↓ navigate · open · esc close