Sha256: 6839b0997ec64831fb3c70e7d629bdc3ac469ce741452b5a4e9c17193805d892

Contents?: true

Size: 951 Bytes

Versions: 24

Compression:

Stored size: 951 Bytes

Contents

require "spec_helper"

describe Lita::Handler, lita_handler: true do
  before { registry.handlers.delete(described_class) }

  it "includes chat routes" do
    registry.register_handler(:foo) do
      route(/foo/) do |response|
        response.reply("bar")
      end
    end

    send_message("foo")

    expect(replies.last).to include("bar")
  end

  it "includes HTTP routes" do
    registry.register_handler(:foo) do
      http.get "foo" do |_request, response|
        response.write("bar")
      end
    end

    http_client = Faraday::Connection.new { |c| c.adapter(:rack, Lita::RackApp.new(robot)) }
    response = http_client.get("/foo")

    expect(response.body).to eq("bar")
  end

  it "includes event routes" do
    registry.register_handler(:foo) do
      on(:some_event) { robot.send_message("payload received") }
    end

    expect(robot).to receive(:send_message).with("payload received")

    robot.trigger(:some_event)
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lita-4.8.0 spec/lita/handler_spec.rb
lita-4.8.0.beta1 spec/lita/handler_spec.rb
lita-4.7.1 spec/lita/handler_spec.rb
lita-4.7.0 spec/lita/handler_spec.rb
lita-4.6.1 spec/lita/handler_spec.rb
lita-4.6.0 spec/lita/handler_spec.rb
lita-4.5.0 spec/lita/handler_spec.rb
lita-4.4.3 spec/lita/handler_spec.rb
lita-4.4.2 spec/lita/handler_spec.rb
lita-4.4.1 spec/lita/handler_spec.rb
lita-4.4.0 spec/lita/handler_spec.rb
lita-4.3.2 spec/lita/handler_spec.rb
lita-4.3.1 spec/lita/handler_spec.rb
lita-4.3.0 spec/lita/handler_spec.rb
lita-4.2.1 spec/lita/handler_spec.rb
lita-4.2.0 spec/lita/handler_spec.rb
lita-4.1.0 spec/lita/handler_spec.rb
lita-4.0.4 spec/lita/handler_spec.rb
lita-4.0.3 spec/lita/handler_spec.rb
lita-4.0.2 spec/lita/handler_spec.rb