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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
# -*- mode:ruby; coding:utf-8 -*-
require 'atig/command/reply'
describe Atig::Command::Reply do
include CommandHelper
before do
@command = init Atig::Command::Reply
target = status 'blah blah', 'id'=>'1'
entry = entry user(1,'mzp'), target
@res = double 'res'
stub_status(:find_by_tid,'a' => entry)
stub_status(:find_by_sid,'mzp:a' => entry)
stub_status(:find_by_screen_name,'mzp' => [ entry ], default: [])
end
it "should have '/me status' name" do
expect(@gateway.names).to eq(%w(mention re reply rp))
end
it "should post the status" do
expect(@api).to receive(:post).
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
and_return(@res)
call '#twitter', "reply", %w(a abc @mzp)
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
end
it "should post the status by sid" do
expect(@api).to receive(:post).
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
and_return(@res)
call '#twitter', "reply", %w(mzp:a abc @mzp)
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
end
it "should post the status by API" do
expect(@api).to receive(:post).
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
and_return(@res)
call '#twitter', "reply", %w(a abc @mzp)
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
end
it "should post the status with screen_name" do
expect(@api).to receive(:post).
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
and_return(@res)
call '#twitter', "reply", %w(mzp abc @mzp)
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
end
it "should add screen name as prefix" do
expect(@api).to receive(:post).
with('statuses/update', {status:'@mzp mzp', in_reply_to_status_id:'1'}).
and_return(@res)
call '#twitter', "reply", %w(a mzp)
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
expect(@gateway.filtered).to eq({ status: '@mzp mzp', in_reply_to_status_id:'1'})
end
end
|