Sha256: e6ef3f5e467181e25593a612d7c750ef56ece018e34aa30e480708f0f9a32adc

Contents?: true

Size: 1.19 KB

Versions: 14

Compression:

Stored size: 1.19 KB

Contents

module RSpec
  module Rails
    module Matchers
      # Matcher for template rendering.
      module RenderTemplate
        # @private
        class RenderTemplateMatcher < RSpec::Matchers::BuiltIn::BaseMatcher
          def initialize(scope, expected, message = nil)
            @expected = 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
            rescued_exception.message
          end

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

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

        alias_method :render_template, :have_rendered
      end
    end
  end
end

Version data entries

14 entries across 13 versions & 3 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.3.3/lib/rspec/rails/matchers/have_rendered.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/have_rendered.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.3.3 lib/rspec/rails/matchers/have_rendered.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/have_rendered.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.1.0/lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.3.2 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.3.1 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.3.0 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.2.3 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.2.2 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.2.1 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.2.0 lib/rspec/rails/matchers/have_rendered.rb
rspec-rails-3.1.0 lib/rspec/rails/matchers/have_rendered.rb