Sha256: 545b11dd99587791c9ea8be39e4249ce364bb0a01e2c9fc1f81b80399a421924

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Configuration::Context, :api do
  subject { described_class.new(context) }

  let(:context) { double }

  describe "#evaluate_configuration_conditional" do
    it "passes through regular values" do
      val = double
      expect(subject.evaluate_configuration_conditional(val)).to eq val
    end

    it "executes a helper method" do
      allow(context).to receive_messages(my_check: true)
      expect(subject.evaluate_configuration_conditional(:my_check)).to be true
    end

    it "calls a helper to determine if it should render a field" do
      a = double
      allow(context).to receive(:my_check_with_an_arg).with(a).and_return(true)
      expect(subject.evaluate_configuration_conditional(:my_check_with_an_arg, a)).to be true
    end

    it "evaluates a Proc to determine if it should render a field" do
      one_arg_lambda = ->(_context, _a) { true }
      two_arg_lambda = ->(_context, _a, _b) { true }
      expect(subject.evaluate_configuration_conditional(one_arg_lambda, 1)).to be true
      expect(subject.evaluate_configuration_conditional(two_arg_lambda, 1, 2)).to be true
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
blacklight-8.8.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.7.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.6.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.6.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.5.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.5.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.4.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/models/blacklight/configuration/context_spec.rb
blacklight-8.3.0 spec/models/blacklight/configuration/context_spec.rb