Sha256: 38a578d9427600134448c355c84fccd64fecce443e2c3979f69da983f0221368

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

# Adds the `render_with` matcher.
# Ex:
#   expect(controller).to render_with(template: :show, locals: { alpha: "beta" })
#
module RenderWithMatcher
  def self.included(base)
    # Setup spying for our "render_with" matcher
    base.before do
      allow(controller).to receive(:render).and_wrap_original do |original, *args, **kwargs, &block|
        original.call(*args, **kwargs, &block)
      end
    end
  end

  RSpec::Matchers.define :render_with do |expected|
    match do |actual|
      have_received(:render).with(expected).matches?(actual)
    end
  end
end

RSpec.configure do |config|
  config.include RenderWithMatcher, type: :controller
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper-mongodb-5.4.0 spec/support/render_with_matcher.rb