Sha256: 1340492a1a7483b95e56450907b89d61f7b911060039bd39b5b2fcd1737cf281

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'
require 'rest-client'
require 'timecop'

describe Lita::Handlers::OnewheelHalfstaff, lita_handler: true do
  before do
    mock = File.open('spec/fixtures/halfstaff.html').read
    allow(RestClient).to receive(:get) { mock }
  end

  it { is_expected.to route_command('halfstaff') }
  it { is_expected.to route_command('halfstaff history') }
  it { is_expected.to route_command('halfmast') }
  it { is_expected.to route_command('halfmast history') }

  it 'gives half-staff status' do
    Timecop.freeze(Time.local(2016, 2, 2, 10, 5, 0)) do
      send_command 'halfstaff'
      expect(["Everything's cool, yo.", "No half staff known."].include? replies.last).to be true
    end
  end

  it 'gives half-staff affirmative' do
    Timecop.freeze(Time.local(2016, 2, 26, 10, 5, 0)) do
      send_command 'halfstaff'
      expect(replies.count).to eq(2)
      expect(replies[0]).to eq('KANSAS ONLY - Honoring  the victims of the Hesston shootings - http://www.flagsexpress.com/Articles.asp?ID=546')
      expect(replies[1]).to eq('MINNESOTA ONLY - Honoring Marine Corps Sergeant and Delano, Minnesota resident Dillion J. Semolina - http://www.flagsexpress.com/Articles.asp?ID=545')
    end
  end

  it 'checks some edge cases for multi-day half staffs.' do
    Timecop.freeze(Time.local(2016, 3, 9, 10, 5, 0)) do
      send_command 'halfstaff'
      expect(replies.count).to eq(2)
      expect(replies[0]).to eq('COLORADO ONLY - Honoring Las Animas County Deputy Sheriff Travis Russell  - http://www.flagsexpress.com/Articles.asp?ID=552')
      expect(replies[1]).to eq('ENTIRE UNITED STATES - Honoring Nancy Reagan  - http://www.flagsexpress.com/Articles.asp?ID=550')
    end
  end

  it 'will return history link' do
    send_command 'halfstaff history'
    expect(replies.last).to eq('https://en.wikipedia.org/wiki/Half-mast')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-onewheel-halfstaff-0.2.0 spec/lita/handlers/onewheel_halfstaff_spec.rb