Sha256: 6379ed9110eff6d8192ff657e9991b98e9786f1f703d5a1cd6a8a74435f65ab4

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require "spec_helper"

describe Lita::Adapter do
  let(:robot) { instance_double("Lita::Robot") }

  let(:required_methods) { [:join, :part, :run, :send_messages, :set_topic, :shut_down] }

  subject { described_class.new(robot) }

  it "stores a Robot" do
    expect(subject.robot).to eql(robot)
  end

  it "logs a warning if a required method has not been implemented" do
    expect(Lita.logger).to receive(:warn).exactly(required_methods.size).times
    required_methods.each do |method|
      subject.public_send(method)
    end
  end

  describe ".require_config" do
    let(:adapter_class) do
      Class.new(described_class) do
        require_config :foo
        require_configs :bar, :baz
        require_configs ["blah", :bleh]
      end
    end

    subject { adapter_class.new(robot) }

    it "ensures that config keys are present on initialization" do
      expect(Lita.logger).to receive(:fatal).with(/foo, bar, baz, blah, bleh/)
      expect { subject }.to raise_error(SystemExit)
    end
  end

  describe ".namespace" do
    it "raises an exception if self.name is not implemented" do
      expect do
        Class.new(Lita::Adapter).namespace
      end.to raise_error(RuntimeError)
    end
  end

  describe "#mention_format" do
    it "formats the provided name for mentioning the user" do
      expect(subject.mention_format("carl")).to eq("carl:")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lita-3.3.1 spec/lita/adapter_spec.rb
lita-3.3.0 spec/lita/adapter_spec.rb
lita-3.2.0 spec/lita/adapter_spec.rb
lita-3.1.0 spec/lita/adapter_spec.rb