Sha256: 3bbaa03f47651a5b7ca9b686f0487a3046ac38f88a2d191f28384d68836a4f58

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe Lita::PluginBuilder, lita: true do
  let(:robot) { instance_double("Lita::Robot") }
  subject { plugin.new(robot) }

  describe "#build_adapter" do
    let(:builder) do
      described_class.new(:test_adapter) do
        def run
          self.class.namespace
        end
      end
    end

    let(:plugin) { builder.build_adapter }

    it "builds an adapter" do
      expect(subject.run).to eq("test_adapter")
    end
  end

  describe "#build_handler" do
    builder = described_class.new(:test_handler) do
      route(/namespace/) { |response| response.reply(self.class.namespace) }
    end

    plugin = builder.build_handler

    describe plugin, lita_handler: true do
      before { registry.register_handler(plugin) }

      it "builds a handler from a block" do
        send_message("namespace")
        expect(replies.last).to eq("test_handler")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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