Sha256: cdca36da467f1d72cee96df4d3863028eb59cf54f34c0366a294b76c90e248c7

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

require "spec_helper"

describe Lita::Handlers::Cron, lita_handler: true do
  it { routes_command("cron list").to(:list) }
  it { routes_command("cron new 15 15 * * * rspec_test_job").to(:new) }
  it { routes_command("cron delete rspec_test_job").to(:delete) }

  describe "#cron list" do
    it "replies to the 'cron list' command" do
      send_command("cron list")
      expect(replies.last).to eq("No cron jobs currently running.")
    end

    it "replies to the 'cron list' command with results" do
      send_command("cron new 15 15 * * * rspec_test_job")

      send_command("cron list")
      expect(replies.last).to eq("rspec_test_job=>[\"15 15 * * *\"]")
    end

  end

  describe "#cron delete doesnotexist" do
    it "handles non-existant cron job, replying with status" do
      send_command("cron delete doesnotexist")
      expect(replies.last).to eq ("doesnotexist isn't an existing cron job.")
    end
  end

  describe "#cron new 15 15 * * * rspec_test_job" do
    before { subject.redis.flushdb }
    it "creates a new cron job, replying with status" do
      send_command("cron new 15 15 * * * rspec_test_job")
      expect(replies.first).to eq("New cron job: 15 15 * * * rspec_test_job")
    end
  end

  describe "#cron delete rspec_test_job" do
   it "deletes a cron job, replying with status" do
     send_command("cron new 15 15 * * * rspec_test_job")
     send_command("cron delete rspec_test_job")
     expect(replies).to include("Deleted rspec_test_job.")
   end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lita-cron-0.0.3 spec/lita/handlers/cron_spec.rb
lita-cron-0.0.2 spec/lita/handlers/cron_spec.rb
lita-cron-0.0.1 spec/lita/handlers/cron_spec.rb