Sha256: 7ada32d56920b3dd017c247637b271f1c6cf23a84b8dadefce41beb7ea110e58

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

RSpec.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

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-7.0.0.rc1 spec/models/blacklight/configuration/context_spec.rb