Sha256: 76668404eddb62ac2019fbf8ecb8281ca31ebd9ef5d9a361db47380b2120bcd8

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe "Pundit RSpec DSL" do
  let(:fake_rspec) do
    double = class_double(RSpec::ExampleGroups)
    double.extend(::Pundit::RSpec::DSL)
    double
  end
  let(:block) { proc { "block content" } }

  it "calls describe with the correct metadata and without :focus" do
    expected_metadata = { permissions: %i[item1 item2], caller: instance_of(Array) }
    expect(fake_rspec).to receive(:describe).with("item1 and item2", match(expected_metadata)) do |&block|
      expect(block.call).to eq("block content")
    end

    fake_rspec.permissions(:item1, :item2, &block)
  end

  it "calls describe with the correct metadata and with :focus" do
    expected_metadata = { permissions: %i[item1 item2], caller: instance_of(Array), focus: true }
    expect(fake_rspec).to receive(:describe).with("item1 and item2", match(expected_metadata)) do |&block|
      expect(block.call).to eq("block content")
    end

    fake_rspec.permissions(:item1, :item2, :focus, &block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pundit-2.4.0 spec/dsl_spec.rb