Sha256: 166d2c6e8a9b0e96b257c3dda86bdf611fd01fe62dd7e7ec8f50a9c7bbd02b56

Contents?: true

Size: 1.15 KB

Versions: 88

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Configuration::Context, api: true 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

88 entries across 88 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.39.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.38.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/configuration/context_spec.rb
blacklight-8.2.2 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.2.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.2.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.37.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.36.2 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.36.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.36.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.35.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.1.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-7.34.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.0.beta8 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.0.beta7 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.0.beta6 spec/models/blacklight/configuration/context_spec.rb
blacklight-8.0.0.beta5 spec/models/blacklight/configuration/context_spec.rb