Sha256: b57ac694ae7ae3d1f3d1437db631c22e03f04e422bb34b9990bf6fa8bd29093c

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require "spec_helper"

describe Lita::Handlers::Cheapshark, lita_handler: true do
  it { is_expected.to route_command("cheapshark batman: arkham city").to(:cheapshark) }

  describe "#cheapshark" do
    context "with a term with results" do
      before :each do
        stub_request(:get, "#{described_class::CHEAPSHARK_URL}/games").with(query: {title: 'batman: arkham city'}).to_return(body: File.read('spec/fixtures/games_batman_arkham_city.json'))
      end

      it "returns the title of the game, the best deal as well as a url to the deal" do
        send_command "cheapshark batman: arkham city"
        expect(replies.count).to eq 2
        expect(replies[0]).to match "Cheapest deal for 'Batman: Arkham City': $19.99"
        expect(replies[1]).to match "http://www.cheapshark.com/redirect?dealID=se5gAdztkrc9svaLPhaVb1drhQP3tlcztIhqLh7cTA0%3D"
      end
    end

    context "with a term without results" do
      before :each do
        stub_request(:get, "#{described_class::CHEAPSHARK_URL}/games").with(query: {title: 'foobar'}).to_return(body: "[]")
      end

      it "returns a helpful message" do
        send_command "cheapshark foobar"
        expect(replies.count).to eq 1
        expect(replies[0]).to match "No deal found for 'foobar'"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-cheapshark-0.2.0 spec/lita/handlers/cheapshark_spec.rb