File: uptime_spec.rb

package info (click to toggle)
atig 0.6.1-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 868 kB
  • sloc: ruby: 5,315; makefile: 11; sh: 3
file content (53 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- mode:ruby; coding:utf-8 -*-

require 'atig/command/uptime'

describe Atig::Command::Uptime do
  include CommandHelper

  before do
    expect(::Time).to receive(:now).and_return(::Time.at(0))
    @command = init Atig::Command::Uptime
  end

  it "should register uptime command" do
    expect(@gateway.names).to eq(['uptime'])
  end

  it "should return mm:ss(min)" do
    expect(::Time).to receive(:now).and_return(::Time.at(0))
    expect(@channel).to receive(:notify).with("00:00")
    call '#twitter', 'uptime', []

    expect(@gateway.notified).to eq('#twitter')
  end

  it "should return mm:ss(max)" do
    expect(::Time).to receive(:now).and_return(::Time.at(60*60-1))
    expect(@channel).to receive(:notify).with("59:59")
    call '#twitter', 'uptime', []

    expect(@gateway.notified).to eq('#twitter')
  end

  it "should return hh:mm:ss(min)" do
    expect(::Time).to receive(:now).and_return(::Time.at(60*60))
    expect(@channel).to receive(:notify).with("01:00:00")
    call '#twitter', 'uptime', []
    expect(@gateway.notified).to eq('#twitter')
  end

  it "should return hh:mm:ss(max)" do
    expect(::Time).to receive(:now).and_return(::Time.at(24*60*60-1))
    expect(@channel).to receive(:notify).with("23:59:59")
    call '#twitter', 'uptime', []
    expect(@gateway.notified).to eq('#twitter')
  end

  it "should return dd days hh:mm:ss" do
    expect(::Time).to receive(:now).and_return(::Time.at(24*60*60))
    expect(@channel).to receive(:notify).with("1 days 00:00")
    call '#twitter', 'uptime', []
    expect(@gateway.notified).to eq('#twitter')
  end
end