Sha256: b67fc45b935b5c586efef662da94fb1bfa3ae36c6c7cab4e2dd236ec3cf5816d

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

module RSpec::Rails::Matchers
  module RenderTemplate
    class RenderTemplateMatcher
      include RSpec::Matchers::BaseMatcher

      def initialize(scope, expected, message=nil)
        super(Symbol === expected ? expected.to_s : expected)
        @message = message
        @scope = scope
      end

      # @api private
      def matches?(*)
        match_unless_raises ActiveSupport::TestCase::Assertion do
          @scope.assert_template expected, @message
        end
      end

      # @api private
      def failure_message_for_should
        rescued_exception.message
      end

      # @api private
      def failure_message_for_should_not
        "expected not to render #{expected.inspect}, but did"
      end
    end

    # Delegates to `assert_template`
    #
    # @example
    #
    #     response.should render_template("new")
    def render_template(options, message=nil)
      RenderTemplateMatcher.new(self, options, message)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-rails-2.8.1 lib/rspec/rails/matchers/render_template.rb
rspec-rails-2.8.0 lib/rspec/rails/matchers/render_template.rb
rspec-rails-2.8.0.rc2 lib/rspec/rails/matchers/render_template.rb