Sha256: c6de5da8611ee9f90685fd330369d9f8a864e5b434eb082297b1897dc808eacc

Contents?: true

Size: 1.41 KB

Versions: 41

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Component do
  let(:component_class) { Blacklight::DocumentTitleComponent }

  context "subclassed" do
    it "returns our Compiler implementation" do
      expect(component_class.ancestors).to include described_class
      expect(component_class.compiler).to be_a Blacklight::Component::EngineCompiler
    end
  end

  describe Blacklight::Component::EngineCompiler do
    subject(:compiler) { described_class.new(component_class) }

    let(:original_compiler) { ViewComponent::Compiler.new(component_class) }
    let(:original_path) { original_compiler.send(:templates).first[:path] }
    let(:resolved_path) { compiler.templates.first[:path] }

    context "without overrides" do
      it "links to engine template" do
        expect(resolved_path).not_to include(".internal_test_app")
        expect(resolved_path).to eql(original_path)
      end
    end

    context "with overrides" do
      let(:path_match) do
        Regexp.new(Regexp.escape(File.join(".internal_test_app", component_class.view_component_path)))
      end

      before do
        allow(File).to receive(:exist?).and_call_original
        allow(File).to receive(:exist?).with(path_match).and_return(true)
      end

      it "links to application template" do
        expect(resolved_path).to include(".internal_test_app")
        expect(resolved_path).not_to eql(original_path)
      end
    end
  end
end

Version data entries

41 entries across 40 versions & 2 rubygems

Version Path
blacklight-7.39.0 spec/lib/blacklight/component_spec.rb
blacklight-8.4.0 spec/lib/blacklight/component_spec.rb
blacklight-7.38.0 spec/lib/blacklight/component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/lib/blacklight/component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/lib/blacklight/component_spec.rb
blacklight-8.3.0 spec/lib/blacklight/component_spec.rb
blacklight-8.2.2 spec/lib/blacklight/component_spec.rb
blacklight-8.2.1 spec/lib/blacklight/component_spec.rb
blacklight-8.2.0 spec/lib/blacklight/component_spec.rb
blacklight-7.37.0 spec/lib/blacklight/component_spec.rb
blacklight-7.36.2 spec/lib/blacklight/component_spec.rb
blacklight-7.36.1 spec/lib/blacklight/component_spec.rb
blacklight-7.36.0 spec/lib/blacklight/component_spec.rb
blacklight-7.35.0 spec/lib/blacklight/component_spec.rb
blacklight-8.1.0 spec/lib/blacklight/component_spec.rb
blacklight-7.34.0 spec/lib/blacklight/component_spec.rb
blacklight-8.0.1 spec/lib/blacklight/component_spec.rb
blacklight-8.0.0 spec/lib/blacklight/component_spec.rb
blacklight-8.0.0.beta8 spec/lib/blacklight/component_spec.rb
blacklight-8.0.0.beta7 spec/lib/blacklight/component_spec.rb