Sha256: 440ef106605d4447b1b07306f6ada455b0a4c7e572890aee58b9a94f61664d8b

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe Blacklight::Configuration::Context do

  subject { described_class.new(context) }
  let(:context) { double }

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

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

    it "should call 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 "should evaluate a Proc to determine if it should render a field" do
      one_arg_lambda = lambda { |context, a| true }
      two_arg_lambda = 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

7 entries across 7 versions & 1 rubygems

Version Path
blacklight-6.3.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.3.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.2.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.1.0 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.0.2 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.0.1 spec/models/blacklight/configuration/context_spec.rb
blacklight-6.0.0 spec/models/blacklight/configuration/context_spec.rb