Sha256: dd10d2dab1aec0a957875f8dcc75357ef91bbed5133ce7d256e4d682a3cd22c5

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Lita::TemplateResolver do
  subject do
    described_class.new(template_root, template_name, adapter_name)
  end

  let(:adapter_name) { :shell }
  let(:generic_template) { File.join(template_root, "basic.erb") }
  let(:irc_template) { File.join(template_root, "basic.irc.erb") }
  let(:template_name) { "basic" }
  let(:template_root) { File.expand_path(File.join("..", "..", "templates"), __FILE__) }

  describe "#resolve" do
    context "when there is a template for the adapter" do
      let(:adapter_name) { :irc }

      it "returns the path to the adapter-specific template" do
        expect(subject.resolve).to eq(irc_template)
      end
    end

    context "when there is no template for the adapter" do
      it "returns the path for the generic template" do
        expect(subject.resolve).to eq(generic_template)
      end
    end

    context "when there is no template with the given name" do
      let(:template_name) { "nonexistent" }

      it "raises an exception" do
        expect { subject.resolve }.to raise_error(
          Lita::MissingTemplateError,
          %r{templates/nonexistent\.erb}
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rita-5.0.0.alpha.4 spec/lita/template_resolver_spec.rb
rita-5.0.0.alpha.3 spec/lita/template_resolver_spec.rb
rita-5.0.0.alpha.2 spec/lita/template_resolver_spec.rb
rita-5.0.0.alpha.1 spec/lita/template_resolver_spec.rb