File: version_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 (62 lines) | stat: -rw-r--r-- 2,031 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
# -*- mode:ruby; coding:utf-8 -*-

require 'atig/command/version'

describe Atig::Command::Version do
  include CommandHelper

  before do
    @command = init Atig::Command::Version
    @status  = double "status"
    allow(@status).to receive(:source).and_return('<a href="http://echofon.com/" rel="nofollow">Echofon</a>')
    @user    = double "user"
    allow(@user).to receive(:status).and_return(@status)
  end

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

  it "should show the source via DB" do
    expect(@statuses).
      to receive(:find_by_screen_name).
      with('mzp',:limit => 1).
      and_return([ entry(@user,@status) ])
    expect(@channel).
      to receive(:message).
      with(anything, Net::IRC::Constants::NOTICE){|s,_|
        expect(s.status.text).to eq("\x01Echofon <http://echofon.com/>\x01")
      }
    call '#twitter','version',%w(mzp)
  end

  it "should show the source of web" do
    status  = double "status"
    allow(status).to receive(:source).and_return('web')
    expect(@statuses).
      to receive(:find_by_screen_name).
      with('mzp',:limit => 1).
      and_return([ entry(@user,status) ])
    expect(@channel).
      to receive(:message).
      with(anything, Net::IRC::Constants::NOTICE){|s,_|
        expect(s.status.text).to eq("\x01web\x01")
      }
    call '#twitter','version',%w(mzp)
  end

  it "should show the source via API" do
    allow(@statuses).to receive(:find_by_screen_name).and_return(@status)
    expect(@statuses).to receive(:find_by_screen_name).with('mzp',:limit => 1).and_return(nil)
    expect(@statuses).to receive(:add).with(status: @status, user: @user, source: :version)
    expect(@api).to receive(:get).with('users/show',{:screen_name=>'mzp'}).and_return(@user)

    expect(@channel).
      to receive(:message).
      with(anything, Net::IRC::Constants::NOTICE){|s,_|
        expect(s.status.text).to eq("\x01Echofon <http://echofon.com/>\x01")
      }

    call '#twitter','version',%w(mzp)
  end
end