Sha256: bb4e02b2f7edf14f1fa7a1a0064c5ef325e306183e5b04b468ef5db4fda10d60

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"

describe Lita::Handlers::Down, lita_handler: true do
  it { is_expected.to route_command("Is example.com down?").to(:down) }
  it { is_expected.to route_command("is example.com down?").to(:down) }

  describe "Checking availability of a site" do
    context "when Faraday returns any object" do
      before do
        faraday_double = double("faraday")
        expect(Faraday::Connection).to receive(:new).and_return(faraday_double)
        expect(faraday_double).to receive(:head).and_return(Object.new)
      end

      it "responds that the site is up" do
        send_message("Is example.com down?")
        expect(replies.last).to eq("It's just you. example.com is up.")
      end
    end

    context "when Faraday raises" do
      before do
        faraday_double = double("faraday")
        expect(Faraday::Connection).to receive(:new).and_return(faraday_double)
        expect(faraday_double).to receive(:head).and_raise
      end

      it "responds that the site is down" do
        send_message("Is example.com down?")
        expect(replies.last).to eq("It's not just you! example.com looks down from here.")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-down-1.0.0 spec/lita/handlers/down_spec.rb