atig 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/command/uptime_spec.rb
CHANGED
@@ -1,54 +1,53 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
4
3
|
require 'atig/command/uptime'
|
5
4
|
|
6
5
|
describe Atig::Command::Uptime do
|
7
6
|
include CommandHelper
|
8
7
|
|
9
8
|
before do
|
10
|
-
::Time.
|
9
|
+
expect(::Time).to receive(:now).and_return(::Time.at(0))
|
11
10
|
@command = init Atig::Command::Uptime
|
12
11
|
end
|
13
12
|
|
14
13
|
it "should register uptime command" do
|
15
|
-
@gateway.names.
|
14
|
+
expect(@gateway.names).to eq(['uptime'])
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should return mm:ss(min)" do
|
19
|
-
::Time.
|
20
|
-
@channel.
|
18
|
+
expect(::Time).to receive(:now).and_return(::Time.at(0))
|
19
|
+
expect(@channel).to receive(:notify).with("00:00")
|
21
20
|
call '#twitter', 'uptime', []
|
22
21
|
|
23
|
-
@gateway.notified.
|
22
|
+
expect(@gateway.notified).to eq('#twitter')
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should return mm:ss(max)" do
|
27
|
-
::Time.
|
28
|
-
@channel.
|
26
|
+
expect(::Time).to receive(:now).and_return(::Time.at(60*60-1))
|
27
|
+
expect(@channel).to receive(:notify).with("59:59")
|
29
28
|
call '#twitter', 'uptime', []
|
30
29
|
|
31
|
-
@gateway.notified.
|
30
|
+
expect(@gateway.notified).to eq('#twitter')
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should return hh:mm:ss(min)" do
|
35
|
-
::Time.
|
36
|
-
@channel.
|
34
|
+
expect(::Time).to receive(:now).and_return(::Time.at(60*60))
|
35
|
+
expect(@channel).to receive(:notify).with("01:00:00")
|
37
36
|
call '#twitter', 'uptime', []
|
38
|
-
@gateway.notified.
|
37
|
+
expect(@gateway.notified).to eq('#twitter')
|
39
38
|
end
|
40
39
|
|
41
40
|
it "should return hh:mm:ss(max)" do
|
42
|
-
::Time.
|
43
|
-
@channel.
|
41
|
+
expect(::Time).to receive(:now).and_return(::Time.at(24*60*60-1))
|
42
|
+
expect(@channel).to receive(:notify).with("23:59:59")
|
44
43
|
call '#twitter', 'uptime', []
|
45
|
-
@gateway.notified.
|
44
|
+
expect(@gateway.notified).to eq('#twitter')
|
46
45
|
end
|
47
46
|
|
48
47
|
it "should return dd days hh:mm:ss" do
|
49
|
-
::Time.
|
50
|
-
@channel.
|
48
|
+
expect(::Time).to receive(:now).and_return(::Time.at(24*60*60))
|
49
|
+
expect(@channel).to receive(:notify).with("1 days 00:00")
|
51
50
|
call '#twitter', 'uptime', []
|
52
|
-
@gateway.notified.
|
51
|
+
expect(@gateway.notified).to eq('#twitter')
|
53
52
|
end
|
54
53
|
end
|
@@ -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/user_info'
|
5
4
|
|
6
5
|
describe Atig::Command::UserInfo do
|
@@ -10,30 +9,28 @@ describe Atig::Command::UserInfo do
|
|
10
9
|
@command = init Atig::Command::UserInfo
|
11
10
|
@status = double "status"
|
12
11
|
@user = double "user"
|
13
|
-
@user.
|
14
|
-
@user.
|
12
|
+
allow(@user).to receive(:description).and_return('hogehoge')
|
13
|
+
allow(@user).to receive(:status).and_return(@status)
|
15
14
|
end
|
16
15
|
|
17
16
|
it "should show the source via DB" do
|
18
|
-
@followings.
|
19
|
-
@channel.
|
20
|
-
|
21
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
22
|
-
|
23
|
-
s.status.text.should == "\x01hogehoge\x01"
|
17
|
+
expect(@followings).to receive(:find_by_screen_name).with('mzp').and_return(@user)
|
18
|
+
expect(@channel).
|
19
|
+
to receive(:message).
|
20
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
21
|
+
expect(s.status.text).to eq("\x01hogehoge\x01")
|
24
22
|
}
|
25
23
|
call '#twitter','userinfo',%w(mzp)
|
26
24
|
end
|
27
25
|
|
28
26
|
it "should show the source via API" do
|
29
|
-
@followings.
|
30
|
-
@api.
|
27
|
+
expect(@followings).to receive(:find_by_screen_name).with('mzp').and_return(nil)
|
28
|
+
expect(@api).to receive(:get).with('users/show',:screen_name=>'mzp').and_return(@user)
|
31
29
|
|
32
|
-
@channel.
|
33
|
-
|
34
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
35
|
-
|
36
|
-
s.status.text.should == "\x01hogehoge\x01"
|
30
|
+
expect(@channel).
|
31
|
+
to receive(:message).
|
32
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
33
|
+
expect(s.status.text).to eq("\x01hogehoge\x01")
|
37
34
|
}
|
38
35
|
|
39
36
|
call '#twitter','userinfo',%w(mzp)
|
data/spec/command/user_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/user'
|
5
4
|
|
6
5
|
describe Atig::Command::User do
|
@@ -10,23 +9,23 @@ describe Atig::Command::User do
|
|
10
9
|
end
|
11
10
|
|
12
11
|
it "should have '/me status' name" do
|
13
|
-
@gateway.names.
|
12
|
+
expect(@gateway.names).to eq(['user', 'u'])
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should" do
|
17
16
|
foo = entry user(1,'mzp'),status('foo')
|
18
17
|
bar = entry user(1,'mzp'),status('bar')
|
19
18
|
baz = entry user(1,'mzp'),status('baz')
|
20
|
-
@api.
|
21
|
-
|
19
|
+
expect(@api).
|
20
|
+
to receive(:get).
|
22
21
|
with('statuses/user_timeline',:count=>20,:screen_name=>'mzp').
|
23
22
|
and_return([foo, bar, baz])
|
24
|
-
@statuses.
|
25
|
-
@statuses.
|
26
|
-
|
23
|
+
expect(@statuses).to receive(:add).with(any_args).at_least(3)
|
24
|
+
expect(@statuses).
|
25
|
+
to receive(:find_by_screen_name).
|
27
26
|
with('mzp',:limit=>20).
|
28
27
|
and_return([foo, bar, baz])
|
29
|
-
@channel.
|
28
|
+
expect(@channel).to receive(:message).with(anything, Net::IRC::Constants::NOTICE).at_least(3)
|
30
29
|
call "#twitter","user",%w(mzp)
|
31
30
|
end
|
32
31
|
|
@@ -34,16 +33,16 @@ describe Atig::Command::User do
|
|
34
33
|
foo = entry user(1,'mzp'),status('foo')
|
35
34
|
bar = entry user(1,'mzp'),status('bar')
|
36
35
|
baz = entry user(1,'mzp'),status('baz')
|
37
|
-
@api.
|
38
|
-
|
36
|
+
expect(@api).
|
37
|
+
to receive(:get).
|
39
38
|
with('statuses/user_timeline',:count=>200,:screen_name=>'mzp').
|
40
39
|
and_return([foo, bar, baz])
|
41
|
-
@statuses.
|
42
|
-
@statuses.
|
43
|
-
|
40
|
+
expect(@statuses).to receive(:add).with(any_args).at_least(3)
|
41
|
+
expect(@statuses).
|
42
|
+
to receive(:find_by_screen_name).
|
44
43
|
with('mzp',:limit=>200).
|
45
44
|
and_return([foo, bar, baz])
|
46
|
-
@channel.
|
45
|
+
expect(@channel).to receive(:message).with(anything, Net::IRC::Constants::NOTICE).at_least(3)
|
47
46
|
call "#twitter","user",%w(mzp 200)
|
48
47
|
end
|
49
48
|
end
|
@@ -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/version'
|
5
4
|
|
6
5
|
describe Atig::Command::Version do
|
@@ -9,56 +8,53 @@ describe Atig::Command::Version do
|
|
9
8
|
before do
|
10
9
|
@command = init Atig::Command::Version
|
11
10
|
@status = double "status"
|
12
|
-
@status.
|
11
|
+
allow(@status).to receive(:source).and_return('<a href="http://echofon.com/" rel="nofollow">Echofon</a>')
|
13
12
|
@user = double "user"
|
14
|
-
@user.
|
13
|
+
allow(@user).to receive(:status).and_return(@status)
|
15
14
|
end
|
16
15
|
|
17
16
|
it "should provide version command" do
|
18
|
-
@gateway.names.
|
17
|
+
expect(@gateway.names).to eq(['version'])
|
19
18
|
end
|
20
19
|
|
21
20
|
it "should show the source via DB" do
|
22
|
-
@statuses.
|
23
|
-
|
21
|
+
expect(@statuses).
|
22
|
+
to receive(:find_by_screen_name).
|
24
23
|
with('mzp',:limit => 1).
|
25
24
|
and_return([ entry(@user,@status) ])
|
26
|
-
@channel.
|
27
|
-
|
28
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
29
|
-
|
30
|
-
s.status.text.should == "\x01Echofon <http://echofon.com/>\x01"
|
25
|
+
expect(@channel).
|
26
|
+
to receive(:message).
|
27
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
28
|
+
expect(s.status.text).to eq("\x01Echofon <http://echofon.com/>\x01")
|
31
29
|
}
|
32
30
|
call '#twitter','version',%w(mzp)
|
33
31
|
end
|
34
32
|
|
35
33
|
it "should show the source of web" do
|
36
34
|
status = double "status"
|
37
|
-
status.
|
38
|
-
@statuses.
|
39
|
-
|
35
|
+
allow(status).to receive(:source).and_return('web')
|
36
|
+
expect(@statuses).
|
37
|
+
to receive(:find_by_screen_name).
|
40
38
|
with('mzp',:limit => 1).
|
41
39
|
and_return([ entry(@user,status) ])
|
42
|
-
@channel.
|
43
|
-
|
44
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
45
|
-
|
46
|
-
s.status.text.should == "\x01web\x01"
|
40
|
+
expect(@channel).
|
41
|
+
to receive(:message).
|
42
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
43
|
+
expect(s.status.text).to eq("\x01web\x01")
|
47
44
|
}
|
48
45
|
call '#twitter','version',%w(mzp)
|
49
46
|
end
|
50
47
|
|
51
48
|
it "should show the source via API" do
|
52
|
-
@statuses.
|
53
|
-
@statuses.
|
54
|
-
@statuses.
|
55
|
-
@api.
|
56
|
-
|
57
|
-
@channel.
|
58
|
-
|
59
|
-
with(anything, Net::IRC::Constants::NOTICE)
|
60
|
-
|
61
|
-
s.status.text.should == "\x01Echofon <http://echofon.com/>\x01"
|
49
|
+
allow(@statuses).to receive(:find_by_screen_name).and_return(@status)
|
50
|
+
expect(@statuses).to receive(:find_by_screen_name).with('mzp',:limit => 1).and_return(nil)
|
51
|
+
expect(@statuses).to receive(:add).with(status: @status, user: @user, source: :version)
|
52
|
+
expect(@api).to receive(:get).with('users/show',:screen_name=>'mzp').and_return(@user)
|
53
|
+
|
54
|
+
expect(@channel).
|
55
|
+
to receive(:message).
|
56
|
+
with(anything, Net::IRC::Constants::NOTICE){|s,_|
|
57
|
+
expect(s.status.text).to eq("\x01Echofon <http://echofon.com/>\x01")
|
62
58
|
}
|
63
59
|
|
64
60
|
call '#twitter','version',%w(mzp)
|
data/spec/command/whois_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/whois'
|
5
4
|
require 'atig/command/info'
|
6
5
|
|
@@ -17,61 +16,61 @@ describe Atig::Command::Whois do
|
|
17
16
|
before do
|
18
17
|
@command = init Atig::Command::Whois
|
19
18
|
@status = double 'status'
|
20
|
-
@status.
|
19
|
+
allow(@status).to receive(:created_at).and_return(time(::Time.at(42)))
|
21
20
|
@user = double "user"
|
22
|
-
@user.
|
23
|
-
@user.
|
24
|
-
@user.
|
25
|
-
@user.
|
26
|
-
@user.
|
27
|
-
@user.
|
28
|
-
@user.
|
29
|
-
@user.
|
21
|
+
allow(@user).to receive(:name) .and_return('name')
|
22
|
+
allow(@user).to receive(:id) .and_return('10')
|
23
|
+
allow(@user).to receive(:screen_name).and_return('screen_name')
|
24
|
+
allow(@user).to receive(:description).and_return('blah blah')
|
25
|
+
allow(@user).to receive(:protected) .and_return(false)
|
26
|
+
allow(@user).to receive(:location) .and_return('Tokyo, Japan')
|
27
|
+
allow(@user).to receive(:created_at) .and_return(time(::Time.at(0)))
|
28
|
+
allow(@user).to receive(:status) .and_return(@status)
|
30
29
|
|
31
|
-
::Time.
|
32
|
-
@followings.
|
30
|
+
allow(::Time).to receive(:now).and_return(::Time.at(50))
|
31
|
+
allow(@followings).to receive(:find_by_screen_name).with('mzp').and_return(@user)
|
33
32
|
end
|
34
33
|
|
35
34
|
it "should proide whois command" do
|
36
|
-
@command.command_name.
|
35
|
+
expect(@command.command_name).to eq(%w(whois))
|
37
36
|
end
|
38
37
|
|
39
38
|
it "should show profile" do
|
40
39
|
commands = []
|
41
|
-
@gateway.
|
40
|
+
expect(@gateway).to receive(:post){|_,command,_,_,*params|
|
42
41
|
commands << command
|
43
42
|
case command
|
44
43
|
when RPL_WHOISUSER
|
45
|
-
params.
|
44
|
+
expect(params).to eq(['id=10', 'twitter.com', "*", 'name / blah blah'])
|
46
45
|
when RPL_WHOISSERVER
|
47
|
-
params.
|
46
|
+
expect(params).to eq(['twitter.com', 'Tokyo, Japan'])
|
48
47
|
when RPL_WHOISIDLE
|
49
|
-
params.
|
48
|
+
expect(params).to eq(["8", "0", "seconds idle, signon time"])
|
50
49
|
when RPL_ENDOFWHOIS
|
51
|
-
params.
|
50
|
+
expect(params).to eq(["End of WHOIS list"])
|
52
51
|
end
|
53
52
|
}.at_least(4)
|
54
53
|
call '#twitter','whois',%w(mzp)
|
55
|
-
commands.
|
54
|
+
expect(commands).to eq([ RPL_WHOISUSER, RPL_WHOISSERVER, RPL_WHOISIDLE, RPL_ENDOFWHOIS])
|
56
55
|
end
|
57
56
|
|
58
57
|
it "should append /protect if the user is protected" do
|
59
|
-
@user.
|
58
|
+
allow(@user).to receive(:protected).and_return(true)
|
60
59
|
commands = []
|
61
|
-
@gateway.
|
60
|
+
expect(@gateway).to receive(:post){|_,command,_,_,*params|
|
62
61
|
commands << command
|
63
62
|
case command
|
64
63
|
when RPL_WHOISUSER
|
65
|
-
params.
|
64
|
+
expect(params).to eq(['id=10', 'twitter.com/protected', "*", 'name / blah blah'])
|
66
65
|
when RPL_WHOISSERVER
|
67
|
-
params.
|
66
|
+
expect(params).to eq(['twitter.com/protected', 'Tokyo, Japan'])
|
68
67
|
when RPL_WHOISIDLE
|
69
|
-
params.
|
68
|
+
expect(params).to eq(["8", "0", "seconds idle, signon time"])
|
70
69
|
when RPL_ENDOFWHOIS
|
71
|
-
params.
|
70
|
+
expect(params).to eq(["End of WHOIS list"])
|
72
71
|
end
|
73
72
|
}.at_least(4)
|
74
73
|
call '#twitter','whois',%w(mzp)
|
75
|
-
commands.
|
74
|
+
expect(commands).to eq([ RPL_WHOISUSER, RPL_WHOISSERVER, RPL_WHOISIDLE, RPL_ENDOFWHOIS])
|
76
75
|
end
|
77
76
|
end
|
data/spec/command_helper.rb
CHANGED
@@ -66,7 +66,7 @@ module CommandHelper
|
|
66
66
|
def init(klass)
|
67
67
|
@log = double 'log'
|
68
68
|
@opts = Atig::Option.new({})
|
69
|
-
context = OpenStruct.new
|
69
|
+
context = OpenStruct.new log:@log, opts:@opts
|
70
70
|
|
71
71
|
@channel = double 'channel'
|
72
72
|
@gateway = FakeGateway.new @channel
|
@@ -88,7 +88,7 @@ module CommandHelper
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def stub_status(key, hash)
|
91
|
-
@statuses.
|
91
|
+
allow(@statuses).to receive(key){|arg,*_|
|
92
92
|
hash.fetch(arg, hash[:default])
|
93
93
|
}
|
94
94
|
end
|
data/spec/db/followings_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/db/followings'
|
5
4
|
|
6
5
|
describe Atig::Db::Followings,"when it is empty" do
|
@@ -14,13 +13,13 @@ describe Atig::Db::Followings,"when it is empty" do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should be emtpy" do
|
17
|
-
@db.empty
|
16
|
+
expect(@db.empty?).to be_truthy
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
describe Atig::Db::Followings,"when updated users" do
|
22
21
|
def user(id, name, protect, only)
|
23
|
-
OpenStruct.new(:
|
22
|
+
OpenStruct.new(id: id, screen_name:name, protected:protect, only:only)
|
24
23
|
end
|
25
24
|
|
26
25
|
before do
|
@@ -43,7 +42,7 @@ describe Atig::Db::Followings,"when updated users" do
|
|
43
42
|
end
|
44
43
|
|
45
44
|
it "should return size" do
|
46
|
-
@db.size.
|
45
|
+
expect(@db.size).to eq(2)
|
47
46
|
end
|
48
47
|
|
49
48
|
it "should be invalidated" do
|
@@ -53,56 +52,56 @@ describe Atig::Db::Followings,"when updated users" do
|
|
53
52
|
end
|
54
53
|
@db.invalidate
|
55
54
|
|
56
|
-
called.
|
55
|
+
expect(called).to be_truthy
|
57
56
|
end
|
58
57
|
|
59
58
|
it "should not empty" do
|
60
|
-
@db.empty
|
59
|
+
expect(@db.empty?).to be_falsey
|
61
60
|
end
|
62
61
|
|
63
62
|
it "should call listener with :join" do
|
64
63
|
@db.update [ @alice, @bob, @charriey ]
|
65
|
-
@listen[:join].
|
66
|
-
@listen[:part].
|
67
|
-
@listen[:mode].
|
64
|
+
expect(@listen[:join]).to eq([ @charriey ])
|
65
|
+
expect(@listen[:part]).to eq(nil)
|
66
|
+
expect(@listen[:mode]).to eq(nil)
|
68
67
|
end
|
69
68
|
|
70
69
|
it "should call listener with :part" do
|
71
70
|
@db.update [ @alice ]
|
72
|
-
@listen[:join].
|
73
|
-
@listen[:part].
|
74
|
-
@listen[:mode].
|
71
|
+
expect(@listen[:join]).to eq(nil)
|
72
|
+
expect(@listen[:part]).to eq([ @bob ])
|
73
|
+
expect(@listen[:mode]).to eq(nil)
|
75
74
|
end
|
76
75
|
|
77
76
|
it "should not found removed user[BUG]" do
|
78
|
-
@db.include?(@bob).
|
77
|
+
expect(@db.include?(@bob)).to eq(true)
|
79
78
|
@db.update [ @alice ]
|
80
79
|
# now, @bob is not member
|
81
|
-
@db.include?(@bob).
|
80
|
+
expect(@db.include?(@bob)).to eq(false)
|
82
81
|
end
|
83
82
|
|
84
83
|
it "should call listener with :mode" do
|
85
84
|
bob = user 5,'bob', false, false
|
86
85
|
|
87
86
|
@db.update [ @alice, bob ]
|
88
|
-
@listen[:join].
|
89
|
-
@listen[:part].
|
90
|
-
@listen[:mode].
|
87
|
+
expect(@listen[:join]).to eq(nil)
|
88
|
+
expect(@listen[:part]).to eq(nil)
|
89
|
+
expect(@listen[:mode]).to eq([ bob ])
|
91
90
|
end
|
92
91
|
|
93
92
|
it "should have users" do
|
94
|
-
@db.users.
|
93
|
+
expect(@db.users).to eq([ @alice, @bob ])
|
95
94
|
end
|
96
95
|
|
97
96
|
it "should be found by screen_name" do
|
98
|
-
@db.find_by_screen_name('alice').
|
99
|
-
@db.find_by_screen_name('???').
|
97
|
+
expect(@db.find_by_screen_name('alice')).to eq(@alice)
|
98
|
+
expect(@db.find_by_screen_name('???')).to eq(nil)
|
100
99
|
end
|
101
100
|
|
102
101
|
it "should check include" do
|
103
102
|
alice = user @alice.id,'alice', true, true
|
104
|
-
@db.include?(@charriey).
|
105
|
-
@db.include?(@alice).
|
106
|
-
@db.include?(alice).
|
103
|
+
expect(@db.include?(@charriey)).to be_falsey
|
104
|
+
expect(@db.include?(@alice)).to be_truthy
|
105
|
+
expect(@db.include?(alice)).to be_truthy
|
107
106
|
end
|
108
107
|
end
|