atig 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +3 -2
- data/Gemfile +2 -0
- data/README.mkdn +2 -0
- data/Rakefile +0 -6
- data/atig.gemspec +21 -20
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/{bin → exe}/atig +0 -0
- data/lib/atig/agent/agent.rb +4 -4
- data/lib/atig/agent/dm.rb +4 -4
- data/lib/atig/agent/following.rb +3 -3
- data/lib/atig/agent/list.rb +2 -2
- data/lib/atig/agent/list_status.rb +6 -6
- data/lib/atig/agent/stream_follow.rb +2 -2
- data/lib/atig/agent/user_stream.rb +3 -3
- data/lib/atig/basic_twitter.rb +1 -3
- data/lib/atig/bitly.rb +1 -1
- data/lib/atig/channel/channel.rb +1 -1
- data/lib/atig/channel/list.rb +3 -3
- data/lib/atig/channel/retweet.rb +1 -1
- data/lib/atig/channel/timeline.rb +1 -1
- data/lib/atig/command/autofix.rb +4 -4
- data/lib/atig/command/destroy.rb +1 -1
- data/lib/atig/command/dm.rb +2 -2
- data/lib/atig/command/favorite.rb +1 -1
- data/lib/atig/command/info.rb +2 -2
- data/lib/atig/command/reply.rb +2 -2
- data/lib/atig/command/retweet.rb +2 -2
- data/lib/atig/command/search.rb +2 -2
- data/lib/atig/command/status.rb +3 -3
- data/lib/atig/command/user.rb +3 -3
- data/lib/atig/command/version.rb +3 -3
- data/lib/atig/db/followings.rb +5 -6
- data/lib/atig/db/statuses.rb +12 -10
- data/lib/atig/db/transaction.rb +1 -1
- data/lib/atig/gateway/channel.rb +1 -2
- data/lib/atig/gateway/session.rb +13 -13
- data/lib/atig/http.rb +4 -4
- data/lib/atig/ifilter/expand_url.rb +1 -1
- data/lib/atig/ifilter/retweet.rb +1 -1
- data/lib/atig/ifilter/retweet_time.rb +1 -1
- data/lib/atig/ifilter/sanitize.rb +1 -1
- data/lib/atig/ifilter/strip.rb +1 -1
- data/lib/atig/ifilter/xid.rb +1 -1
- data/lib/atig/oauth.rb +3 -3
- data/lib/atig/ofilter/escape_url.rb +1 -1
- data/lib/atig/ofilter/footer.rb +1 -1
- data/lib/atig/ofilter/geo.rb +1 -1
- data/lib/atig/ofilter/short_url.rb +1 -1
- data/lib/atig/option.rb +1 -1
- data/lib/atig/optparse.rb +22 -11
- data/lib/atig/search.rb +4 -2
- data/lib/atig/stream.rb +1 -1
- data/lib/atig/twitter.rb +5 -4
- data/lib/atig/update_checker.rb +2 -2
- data/lib/atig/url_escape.rb +1 -1
- data/lib/atig/version.rb +1 -1
- data/lib/memory_profiler.rb +1 -1
- data/spec/command/autofix_spec.rb +7 -8
- data/spec/command/destroy_spec.rb +12 -13
- data/spec/command/dm_spec.rb +5 -6
- data/spec/command/favorite_spec.rb +11 -12
- data/spec/command/limit_spec.rb +6 -7
- data/spec/command/location_spec.rb +4 -5
- data/spec/command/name_spec.rb +2 -3
- data/spec/command/option_spec.rb +28 -29
- data/spec/command/refresh_spec.rb +3 -4
- data/spec/command/reply_spec.rb +22 -23
- data/spec/command/retweet_spec.rb +17 -18
- data/spec/command/spam_spec.rb +4 -5
- data/spec/command/status_spec.rb +19 -20
- data/spec/command/thread_spec.rb +20 -21
- data/spec/command/time_spec.rb +18 -21
- data/spec/command/uptime_spec.rb +17 -18
- data/spec/command/user_info_spec.rb +13 -16
- data/spec/command/user_spec.rb +13 -14
- data/spec/command/version_spec.rb +25 -29
- data/spec/command/whois_spec.rb +25 -26
- data/spec/command_helper.rb +2 -2
- data/spec/db/followings_spec.rb +22 -23
- data/spec/db/listenable_spec.rb +2 -3
- data/spec/db/lists_spec.rb +16 -17
- data/spec/db/roman_spec.rb +3 -5
- data/spec/db/sized_uniq_array_spec.rb +13 -14
- data/spec/db/statuses_spec.rb +69 -70
- data/spec/ifilter/expand_url_spec.rb +18 -20
- data/spec/ifilter/retweet_spec.rb +4 -5
- data/spec/ifilter/retweet_time_spec.rb +4 -5
- data/spec/ifilter/sanitize_spec.rb +5 -6
- data/spec/ifilter/sid_spec.rb +6 -7
- data/spec/ifilter/strip_spec.rb +3 -4
- data/spec/ifilter/tid_spec.rb +6 -7
- data/spec/levenshtein_spec.rb +2 -3
- data/spec/ofilter/escape_url_spec.rb +13 -14
- data/spec/ofilter/footer_spec.rb +10 -11
- data/spec/ofilter/geo_spec.rb +12 -13
- data/spec/ofilter/short_url_spec.rb +28 -29
- data/spec/option_spec.rb +23 -24
- data/spec/sized_hash_spec.rb +5 -6
- data/spec/spec_helper.rb +8 -6
- data/spec/update_checker_spec.rb +14 -15
- metadata +9 -32
- data/docs/_static/allow.png +0 -0
- data/docs/_static/emacs.png +0 -0
- data/docs/_static/irc_setting.png +0 -0
- data/docs/_static/irssi.png +0 -0
- data/docs/_static/limechat.png +0 -0
- data/docs/_static/limechat_s.png +0 -0
- data/docs/_static/oauth_channel.png +0 -0
- data/docs/_static/screenshot.png +0 -0
- data/docs/_static/structure.png +0 -0
- data/docs/_static/verify.png +0 -0
- data/docs/changelog.rst +0 -233
- data/docs/commandline_options.rst +0 -21
- data/docs/commands.rst +0 -84
- data/docs/conf.py +0 -194
- data/docs/config.rst +0 -159
- data/docs/feature.rst +0 -41
- data/docs/hacking_guide.rst +0 -43
- data/docs/index.rst +0 -102
- data/docs/irc.rst +0 -31
- data/docs/options.rst +0 -76
- data/docs/quickstart.rst +0 -96
- data/docs/resize.sh +0 -7
- data/docs/tiarra.rst +0 -2
- data/docs/tig.rst +0 -21
- data/requirements.txt +0 -5
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/refresh'
|
|
5
4
|
require 'atig/command/info'
|
|
6
5
|
|
|
@@ -12,9 +11,9 @@ describe Atig::Command::Refresh do
|
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
it "should refresh all" do
|
|
15
|
-
@followings.
|
|
16
|
-
@lists.
|
|
17
|
-
@channel.
|
|
14
|
+
expect(@followings).to receive(:invalidate)
|
|
15
|
+
expect(@lists).to receive(:invalidate).with(:all)
|
|
16
|
+
expect(@channel).to receive(:notify).with("refresh followings/lists...")
|
|
18
17
|
|
|
19
18
|
call '#twitter','refresh', []
|
|
20
19
|
end
|
data/spec/command/reply_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/reply'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Reply do
|
|
@@ -14,65 +13,65 @@ describe Atig::Command::Reply do
|
|
|
14
13
|
|
|
15
14
|
stub_status(:find_by_tid,'a' => entry)
|
|
16
15
|
stub_status(:find_by_sid,'mzp:a' => entry)
|
|
17
|
-
stub_status(:find_by_screen_name,'mzp' => [ entry ], :
|
|
16
|
+
stub_status(:find_by_screen_name,'mzp' => [ entry ], default: [])
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it "should have '/me status' name" do
|
|
21
|
-
@gateway.names.
|
|
20
|
+
expect(@gateway.names).to eq(%w(mention re reply rp))
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
it "should post the status" do
|
|
25
|
-
@api.
|
|
26
|
-
with('statuses/update', {:
|
|
24
|
+
expect(@api).to receive(:post).
|
|
25
|
+
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
|
|
27
26
|
and_return(@res)
|
|
28
27
|
|
|
29
28
|
call '#twitter', "reply", %w(a abc @mzp)
|
|
30
29
|
|
|
31
|
-
@gateway.updated.
|
|
32
|
-
@gateway.filtered.
|
|
30
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
|
|
31
|
+
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
it "should post the status by sid" do
|
|
36
|
-
@api.
|
|
37
|
-
with('statuses/update', {:
|
|
35
|
+
expect(@api).to receive(:post).
|
|
36
|
+
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
|
|
38
37
|
and_return(@res)
|
|
39
38
|
|
|
40
39
|
call '#twitter', "reply", %w(mzp:a abc @mzp)
|
|
41
40
|
|
|
42
|
-
@gateway.updated.
|
|
43
|
-
@gateway.filtered.
|
|
41
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
|
|
42
|
+
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
it "should post the status by API" do
|
|
47
|
-
@api.
|
|
48
|
-
with('statuses/update', {:
|
|
46
|
+
expect(@api).to receive(:post).
|
|
47
|
+
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
|
|
49
48
|
and_return(@res)
|
|
50
49
|
|
|
51
50
|
call '#twitter', "reply", %w(a abc @mzp)
|
|
52
51
|
|
|
53
|
-
@gateway.updated.
|
|
54
|
-
@gateway.filtered.
|
|
52
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
|
|
53
|
+
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it "should post the status with screen_name" do
|
|
58
|
-
@api.
|
|
59
|
-
with('statuses/update', {:
|
|
57
|
+
expect(@api).to receive(:post).
|
|
58
|
+
with('statuses/update', {status:'abc @mzp', in_reply_to_status_id:'1'}).
|
|
60
59
|
and_return(@res)
|
|
61
60
|
|
|
62
61
|
call '#twitter', "reply", %w(mzp abc @mzp)
|
|
63
62
|
|
|
64
|
-
@gateway.updated.
|
|
65
|
-
@gateway.filtered.
|
|
63
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
|
|
64
|
+
expect(@gateway.filtered).to eq({ status: 'abc @mzp', in_reply_to_status_id:'1'})
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
it "should add screen name as prefix" do
|
|
69
|
-
@api.
|
|
70
|
-
with('statuses/update', {:
|
|
68
|
+
expect(@api).to receive(:post).
|
|
69
|
+
with('statuses/update', {status:'@mzp mzp', in_reply_to_status_id:'1'}).
|
|
71
70
|
and_return(@res)
|
|
72
71
|
|
|
73
72
|
call '#twitter', "reply", %w(a mzp)
|
|
74
73
|
|
|
75
|
-
@gateway.updated.
|
|
76
|
-
@gateway.filtered.
|
|
74
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'In reply to mzp: blah blah' ])
|
|
75
|
+
expect(@gateway.filtered).to eq({ status: '@mzp mzp', in_reply_to_status_id:'1'})
|
|
77
76
|
end
|
|
78
77
|
end
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/retweet'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Retweet do
|
|
7
6
|
include CommandHelper
|
|
8
7
|
before do
|
|
9
8
|
bitly = double("Bitly")
|
|
10
|
-
bitly.
|
|
9
|
+
allow(bitly).to receive(:shorten){|s|
|
|
11
10
|
"[#{s}]"
|
|
12
11
|
}
|
|
13
|
-
Atig::Bitly.
|
|
12
|
+
allow(Atig::Bitly).to receive(:no_login).and_return(bitly)
|
|
14
13
|
|
|
15
14
|
@command = init Atig::Command::Retweet
|
|
16
15
|
|
|
@@ -20,46 +19,46 @@ describe Atig::Command::Retweet do
|
|
|
20
19
|
|
|
21
20
|
stub_status(:find_by_tid,'a' => entry)
|
|
22
21
|
stub_status(:find_by_sid,'mzp:a' => entry)
|
|
23
|
-
stub_status(:find_by_screen_name,'mzp' => [ entry ], :
|
|
22
|
+
stub_status(:find_by_screen_name,'mzp' => [ entry ], default:[])
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
it "should have command name" do
|
|
27
|
-
@gateway.names.
|
|
26
|
+
expect(@gateway.names).to eq(%w(ort rt retweet qt))
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
it "should post official retweet without comment" do
|
|
31
|
-
@api.
|
|
30
|
+
expect(@api).to receive(:post).with('statuses/retweet/1').and_return(@res)
|
|
32
31
|
call "#twitter", 'rt', %w(a)
|
|
33
|
-
@gateway.updated.
|
|
32
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
it "should post official retweet without comment by screen name" do
|
|
37
|
-
@api.
|
|
36
|
+
expect(@api).to receive(:post).with('statuses/retweet/1').and_return(@res)
|
|
38
37
|
call "#twitter", 'rt', %w(mzp)
|
|
39
|
-
@gateway.updated.
|
|
38
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
it "should post official retweet without comment by sid" do
|
|
43
|
-
@api.
|
|
42
|
+
expect(@api).to receive(:post).with('statuses/retweet/1').and_return(@res)
|
|
44
43
|
call "#twitter", 'rt', %w(mzp:a)
|
|
45
|
-
@gateway.updated.
|
|
44
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
it "should post un-official retweet with comment" do
|
|
49
|
-
@api.
|
|
48
|
+
expect(@api).to receive(:post).with('statuses/update',:status=> "aaa RT @mzp: blah blah blah blah blah blah blah blah").and_return(@res)
|
|
50
49
|
call "#twitter", 'rt', %w(a aaa)
|
|
51
|
-
@gateway.updated.
|
|
50
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
it "should post un-official retweet with comment by screen name" do
|
|
55
|
-
@api.
|
|
54
|
+
expect(@api).to receive(:post).with('statuses/update',:status=> "aaa RT @mzp: blah blah blah blah blah blah blah blah").and_return(@res)
|
|
56
55
|
call "#twitter", 'rt', %w(mzp aaa)
|
|
57
|
-
@gateway.updated.
|
|
56
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
it "should post un-official retweet with long comment" do
|
|
61
|
-
@api.
|
|
62
|
-
call "#twitter", 'rt', ['a', 'a' *
|
|
63
|
-
@gateway.updated.
|
|
60
|
+
expect(@api).to receive(:post).with('statuses/update',:status=> "#{'a' * 94} RT @mzp: b [https://twitter.com/mzp/status/1]").and_return(@res)
|
|
61
|
+
call "#twitter", 'rt', ['a', 'a' * 94 ]
|
|
62
|
+
expect(@gateway.updated).to eq([ @res, '#twitter', 'RT to mzp: blah blah blah blah blah blah blah blah' ])
|
|
64
63
|
end
|
|
65
64
|
end
|
data/spec/command/spam_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/spam'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Spam do
|
|
@@ -10,17 +9,17 @@ describe Atig::Command::Spam do
|
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
it "はspamコマンドを提供する" do
|
|
13
|
-
@gateway.names.
|
|
12
|
+
expect(@gateway.names).to eq(%w(spam SPAM))
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
it "は指定されたscreen_nameを通報する" do
|
|
17
16
|
user = user(1,'examplespammer')
|
|
18
|
-
@api.
|
|
19
|
-
|
|
17
|
+
expect(@api).
|
|
18
|
+
to receive(:post).
|
|
20
19
|
with('report_spam',:screen_name=> 'examplespammer').
|
|
21
20
|
and_return(user)
|
|
22
21
|
|
|
23
|
-
@channel.
|
|
22
|
+
expect(@channel).to receive(:notify).with("Report examplespammer as SPAMMER")
|
|
24
23
|
call "#twitter", 'spam', %w(examplespammer)
|
|
25
24
|
end
|
|
26
25
|
end
|
data/spec/command/status_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/status'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Status do
|
|
@@ -10,56 +9,56 @@ describe Atig::Command::Status do
|
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
it "should have '/me status' name" do
|
|
13
|
-
@gateway.names.
|
|
12
|
+
expect(@gateway.names).to eq(['status'])
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
it "should post the status by API" do
|
|
17
16
|
res = status('blah blah')
|
|
18
|
-
@statuses.
|
|
19
|
-
@api.
|
|
17
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return(nil)
|
|
18
|
+
expect(@api).to receive(:post).with('statuses/update', {status:'blah blah'}).and_return(res)
|
|
20
19
|
|
|
21
20
|
call '#twitter', "status", %w(blah blah)
|
|
22
21
|
|
|
23
|
-
@gateway.updated.
|
|
24
|
-
@gateway.filtered.
|
|
22
|
+
expect(@gateway.updated).to eq([ res, '#twitter' ])
|
|
23
|
+
expect(@gateway.filtered).to eq({ status: 'blah blah' })
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should post with japanese language" do
|
|
28
27
|
res = status("あ"*140)
|
|
29
|
-
@statuses.
|
|
30
|
-
@api.
|
|
28
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return(nil)
|
|
29
|
+
expect(@api).to receive(:post).with('statuses/update', {status:"あ"*140}).and_return(res)
|
|
31
30
|
|
|
32
31
|
call '#twitter', "status", ["あ" * 140]
|
|
33
32
|
|
|
34
|
-
@gateway.updated.
|
|
35
|
-
@gateway.filtered.
|
|
33
|
+
expect(@gateway.updated).to eq([ res, '#twitter' ])
|
|
34
|
+
expect(@gateway.filtered).to eq({ status: "あ" * 140 })
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
it "should post the status even if has long URL" do
|
|
39
38
|
res = status("https://www.google.co.jp/search?q=%E3%83%AB%E3%83%93%E3%83%BC%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E9%96%8B%E7%99%BA&safe=off")
|
|
40
|
-
@statuses.
|
|
41
|
-
@api.
|
|
39
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return(nil)
|
|
40
|
+
expect(@api).to receive(:post).with('statuses/update', {status:'https://www.google.co.jp/search?q=%E3%83%AB%E3%83%93%E3%83%BC%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E9%96%8B%E7%99%BA&safe=off'}).and_return(res)
|
|
42
41
|
|
|
43
42
|
call '#twitter', "status", ['https://www.google.co.jp/search?q=%E3%83%AB%E3%83%93%E3%83%BC%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E9%96%8B%E7%99%BA&safe=off']
|
|
44
43
|
|
|
45
|
-
@gateway.updated.
|
|
46
|
-
@gateway.filtered.
|
|
44
|
+
expect(@gateway.updated).to eq([ res, '#twitter' ])
|
|
45
|
+
expect(@gateway.filtered).to eq({ status: 'https://www.google.co.jp/search?q=%E3%83%AB%E3%83%93%E3%83%BC%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E9%96%8B%E7%99%BA&safe=off'})
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
it "should not post same post" do
|
|
50
49
|
e = entry user(1,'mzp'), status('blah blah')
|
|
51
|
-
@statuses.
|
|
52
|
-
@channel.
|
|
50
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return([ e ] )
|
|
51
|
+
expect(@channel).to receive(:notify).with("You can't submit the same status twice in a row.")
|
|
53
52
|
|
|
54
53
|
call '#twitter', "status", %w(blah blah)
|
|
55
|
-
@gateway.notified.
|
|
54
|
+
expect(@gateway.notified).to eq('#twitter')
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
it "should not post over 140" do
|
|
59
|
-
@statuses.
|
|
60
|
-
@channel.
|
|
58
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return(nil)
|
|
59
|
+
expect(@channel).to receive(:notify).with("You can't submit the status over 140 chars")
|
|
61
60
|
|
|
62
61
|
call '#twitter', "status", [ 'a' * 141 ]
|
|
63
|
-
@gateway.notified.
|
|
62
|
+
expect(@gateway.notified).to eq('#twitter')
|
|
64
63
|
end
|
|
65
64
|
end
|
data/spec/command/thread_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/thread'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Thread do
|
|
@@ -16,75 +15,75 @@ describe Atig::Command::Thread do
|
|
|
16
15
|
]
|
|
17
16
|
@command = init Atig::Command::Thread
|
|
18
17
|
@messages = []
|
|
19
|
-
@channel.
|
|
18
|
+
allow(@channel).to receive(:message){|entry,_|
|
|
20
19
|
@messages.unshift entry
|
|
21
20
|
}
|
|
22
|
-
@statuses.
|
|
21
|
+
allow(@statuses).to receive(:find_by_status_id).with(anything){|id|
|
|
23
22
|
@entries[id.to_i]
|
|
24
23
|
}
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should provide thread command" do
|
|
28
|
-
@gateway.names.
|
|
27
|
+
expect(@gateway.names).to eq(%w( thread ))
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
it "should show the tweet" do
|
|
32
|
-
@statuses.
|
|
31
|
+
expect(@statuses).to receive(:find_by_tid).with('a').and_return(@entries[0])
|
|
33
32
|
|
|
34
33
|
call "#twitter","thread",%w(a)
|
|
35
34
|
|
|
36
|
-
@messages.
|
|
35
|
+
expect(@messages).to eq([ @entries[0] ])
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
it "should chain the tweets" do
|
|
40
|
-
@statuses.
|
|
39
|
+
expect(@statuses).to receive(:find_by_tid).with('a').and_return(@entries[1])
|
|
41
40
|
|
|
42
41
|
call "#twitter","thread",%w(a)
|
|
43
42
|
|
|
44
|
-
@messages.
|
|
43
|
+
expect(@messages).to eq(@entries[1..3])
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
it "should chain the tweets by screen name" do
|
|
48
|
-
@statuses.
|
|
49
|
-
@statuses.
|
|
50
|
-
@statuses.
|
|
47
|
+
expect(@statuses).to receive(:find_by_tid).with('mzp').and_return(nil)
|
|
48
|
+
expect(@statuses).to receive(:find_by_sid).with('mzp').and_return(nil)
|
|
49
|
+
expect(@statuses).to receive(:find_by_screen_name).with('mzp',:limit=>1).and_return([ @entries[1] ])
|
|
51
50
|
|
|
52
51
|
call "#twitter","thread",%w(mzp)
|
|
53
52
|
|
|
54
|
-
@messages.
|
|
53
|
+
expect(@messages).to eq(@entries[1..3])
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it "should chain the tweets by sid" do
|
|
58
|
-
@statuses.
|
|
59
|
-
@statuses.
|
|
57
|
+
expect(@statuses).to receive(:find_by_tid).with('mzp:a').and_return(nil)
|
|
58
|
+
expect(@statuses).to receive(:find_by_sid).with('mzp:a').and_return(@entries[1])
|
|
60
59
|
|
|
61
60
|
call "#twitter","thread",%w(mzp:a)
|
|
62
61
|
|
|
63
|
-
@messages.
|
|
62
|
+
expect(@messages).to eq(@entries[1..3])
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
|
|
67
66
|
|
|
68
67
|
it "should chain the tweets with limit" do
|
|
69
|
-
@statuses.
|
|
68
|
+
expect(@statuses).to receive(:find_by_tid).with('a').and_return(@entries[1])
|
|
70
69
|
|
|
71
70
|
call "#twitter","thread",%w(a 2)
|
|
72
71
|
|
|
73
|
-
@messages.
|
|
72
|
+
expect(@messages).to eq(@entries[1..2])
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
it "should get new tweets" do
|
|
77
|
-
@statuses.
|
|
76
|
+
expect(@statuses).to receive(:find_by_tid).with('a').and_return(@entries[4])
|
|
78
77
|
user = user 1, 'mzp'
|
|
79
78
|
status = status '','user'=>user
|
|
80
79
|
entry = entry user,status,'new-entry'
|
|
81
|
-
@statuses.
|
|
80
|
+
expect(@statuses).to receive(:add).with(status: status, user: user, source: :thread){
|
|
82
81
|
@entries << entry
|
|
83
82
|
}
|
|
84
|
-
@api.
|
|
83
|
+
expect(@api).to receive(:get).with('statuses/show/5').and_return(status)
|
|
85
84
|
|
|
86
85
|
call "#twitter","thread",%w(a)
|
|
87
86
|
|
|
88
|
-
@messages.
|
|
87
|
+
expect(@messages).to eq([@entries[4], entry])
|
|
89
88
|
end
|
|
90
89
|
end
|
data/spec/command/time_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/command/time'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Time do
|
|
@@ -8,8 +7,8 @@ describe Atig::Command::Time do
|
|
|
8
7
|
|
|
9
8
|
def user(offset, tz)
|
|
10
9
|
u = double "user-#{offset}"
|
|
11
|
-
u.
|
|
12
|
-
u.
|
|
10
|
+
allow(u).to receive(:utc_offset).and_return(offset)
|
|
11
|
+
allow(u).to receive(:time_zone).and_return(tz)
|
|
13
12
|
u
|
|
14
13
|
end
|
|
15
14
|
|
|
@@ -19,33 +18,31 @@ describe Atig::Command::Time do
|
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
it "should provide time command" do
|
|
22
|
-
@gateway.names.
|
|
21
|
+
expect(@gateway.names).to eq(['time'])
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
it "should show offset time on DB" do
|
|
26
|
-
::Time.
|
|
27
|
-
@followings.
|
|
28
|
-
@channel.
|
|
29
|
-
|
|
30
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
|
31
|
-
|
|
32
|
-
s.status.text.should == "\x01TIME :1970-01-01T01:01:01+01:01 (Tokyo)\x01"
|
|
25
|
+
expect(::Time).to receive(:now).and_return(Time.at(0))
|
|
26
|
+
expect(@followings).to receive(:find_by_screen_name).with('mzp').and_return(@user)
|
|
27
|
+
expect(@channel).
|
|
28
|
+
to receive(:message).
|
|
29
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
|
30
|
+
expect(s.status.text).to eq("\x01TIME :1970-01-01T01:01:01+01:01 (Tokyo)\x01")
|
|
33
31
|
}
|
|
34
32
|
call '#twitter', 'time', ['mzp']
|
|
35
|
-
@gateway.notified.
|
|
33
|
+
expect(@gateway.notified).to eq('#twitter')
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
it "should show offset time via API" do
|
|
39
|
-
::Time.
|
|
40
|
-
@followings.
|
|
41
|
-
@api.
|
|
42
|
-
@channel.
|
|
43
|
-
|
|
44
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
|
45
|
-
|
|
46
|
-
s.status.text.should == "\x01TIME :1970-01-01T01:01:01+01:01 (Tokyo)\x01"
|
|
37
|
+
expect(::Time).to receive(:now).and_return(Time.at(0))
|
|
38
|
+
expect(@followings).to receive(:find_by_screen_name).with('mzp').and_return(nil)
|
|
39
|
+
expect(@api).to receive(:get).with('users/show', screen_name:'mzp').and_return(@user)
|
|
40
|
+
expect(@channel).
|
|
41
|
+
to receive(:message).
|
|
42
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
|
43
|
+
expect(s.status.text).to eq("\x01TIME :1970-01-01T01:01:01+01:01 (Tokyo)\x01")
|
|
47
44
|
}
|
|
48
45
|
call '#twitter', 'time', ['mzp']
|
|
49
|
-
@gateway.notified.
|
|
46
|
+
expect(@gateway.notified).to eq('#twitter')
|
|
50
47
|
end
|
|
51
48
|
end
|