atig 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +3 -0
  3. data/README.mkdn +52 -0
  4. data/Rakefile +15 -0
  5. data/atig.gemspec +25 -0
  6. data/bin/atig +74 -0
  7. data/docs/OMakefile +32 -0
  8. data/docs/OMakeroot +45 -0
  9. data/docs/_static/allow.png +0 -0
  10. data/docs/_static/emacs.png +0 -0
  11. data/docs/_static/irc_setting.png +0 -0
  12. data/docs/_static/irssi.png +0 -0
  13. data/docs/_static/limechat.png +0 -0
  14. data/docs/_static/limechat_s.png +0 -0
  15. data/docs/_static/oauth_channel.png +0 -0
  16. data/docs/_static/screenshot.png +0 -0
  17. data/docs/_static/structure.png +0 -0
  18. data/docs/_static/verify.png +0 -0
  19. data/docs/changelog.rst +96 -0
  20. data/docs/commandline_options.rst +21 -0
  21. data/docs/commands.rst +84 -0
  22. data/docs/conf.py +194 -0
  23. data/docs/config.rst +159 -0
  24. data/docs/feature.rst +41 -0
  25. data/docs/graphics.graffle +1995 -0
  26. data/docs/hacking_guide.rst +43 -0
  27. data/docs/index.rst +109 -0
  28. data/docs/irc.rst +31 -0
  29. data/docs/options.rst +75 -0
  30. data/docs/quickstart.rst +89 -0
  31. data/docs/resize.sh +7 -0
  32. data/docs/tiarra.rst +2 -0
  33. data/docs/tig.rst +21 -0
  34. data/lib/atig.rb +19 -0
  35. data/lib/atig/agent.rb +8 -0
  36. data/lib/atig/agent/agent.rb +38 -0
  37. data/lib/atig/agent/clenup.rb +23 -0
  38. data/lib/atig/agent/dm.rb +35 -0
  39. data/lib/atig/agent/following.rb +45 -0
  40. data/lib/atig/agent/full_list.rb +20 -0
  41. data/lib/atig/agent/list.rb +55 -0
  42. data/lib/atig/agent/list_status.rb +46 -0
  43. data/lib/atig/agent/mention.rb +13 -0
  44. data/lib/atig/agent/other_list.rb +18 -0
  45. data/lib/atig/agent/own_list.rb +18 -0
  46. data/lib/atig/agent/stream_follow.rb +38 -0
  47. data/lib/atig/agent/timeline.rb +13 -0
  48. data/lib/atig/agent/user_stream.rb +31 -0
  49. data/lib/atig/basic_twitter.rb +116 -0
  50. data/lib/atig/bitly.rb +52 -0
  51. data/lib/atig/channel.rb +5 -0
  52. data/lib/atig/channel/channel.rb +17 -0
  53. data/lib/atig/channel/dm.rb +14 -0
  54. data/lib/atig/channel/list.rb +76 -0
  55. data/lib/atig/channel/mention.rb +20 -0
  56. data/lib/atig/channel/retweet.rb +28 -0
  57. data/lib/atig/channel/timeline.rb +74 -0
  58. data/lib/atig/command.rb +21 -0
  59. data/lib/atig/command/autofix.rb +58 -0
  60. data/lib/atig/command/command.rb +24 -0
  61. data/lib/atig/command/command_helper.rb +95 -0
  62. data/lib/atig/command/destroy.rb +44 -0
  63. data/lib/atig/command/dm.rb +31 -0
  64. data/lib/atig/command/favorite.rb +27 -0
  65. data/lib/atig/command/info.rb +50 -0
  66. data/lib/atig/command/limit.rb +15 -0
  67. data/lib/atig/command/location.rb +23 -0
  68. data/lib/atig/command/name.rb +18 -0
  69. data/lib/atig/command/option.rb +37 -0
  70. data/lib/atig/command/refresh.rb +18 -0
  71. data/lib/atig/command/reply.rb +37 -0
  72. data/lib/atig/command/retweet.rb +63 -0
  73. data/lib/atig/command/search.rb +51 -0
  74. data/lib/atig/command/spam.rb +26 -0
  75. data/lib/atig/command/status.rb +41 -0
  76. data/lib/atig/command/thread.rb +44 -0
  77. data/lib/atig/command/time.rb +32 -0
  78. data/lib/atig/command/uptime.rb +32 -0
  79. data/lib/atig/command/user.rb +42 -0
  80. data/lib/atig/command/user_info.rb +27 -0
  81. data/lib/atig/command/version.rb +49 -0
  82. data/lib/atig/command/whois.rb +39 -0
  83. data/lib/atig/db/db.rb +60 -0
  84. data/lib/atig/db/followings.rb +131 -0
  85. data/lib/atig/db/listenable.rb +22 -0
  86. data/lib/atig/db/lists.rb +76 -0
  87. data/lib/atig/db/roman.rb +30 -0
  88. data/lib/atig/db/sized_uniq_array.rb +62 -0
  89. data/lib/atig/db/sql.rb +35 -0
  90. data/lib/atig/db/statuses.rb +147 -0
  91. data/lib/atig/db/transaction.rb +47 -0
  92. data/lib/atig/exception_util.rb +26 -0
  93. data/lib/atig/gateway.rb +62 -0
  94. data/lib/atig/gateway/channel.rb +99 -0
  95. data/lib/atig/gateway/session.rb +326 -0
  96. data/lib/atig/http.rb +95 -0
  97. data/lib/atig/ifilter.rb +7 -0
  98. data/lib/atig/ifilter/expand_url.rb +74 -0
  99. data/lib/atig/ifilter/retweet.rb +14 -0
  100. data/lib/atig/ifilter/retweet_time.rb +16 -0
  101. data/lib/atig/ifilter/sanitize.rb +18 -0
  102. data/lib/atig/ifilter/strip.rb +15 -0
  103. data/lib/atig/ifilter/utf7.rb +26 -0
  104. data/lib/atig/ifilter/xid.rb +36 -0
  105. data/lib/atig/levenshtein.rb +49 -0
  106. data/lib/atig/monkey.rb +4 -0
  107. data/lib/atig/oauth-patch.rb +40 -0
  108. data/lib/atig/oauth.rb +55 -0
  109. data/lib/atig/ofilter.rb +4 -0
  110. data/lib/atig/ofilter/escape_url.rb +102 -0
  111. data/lib/atig/ofilter/footer.rb +20 -0
  112. data/lib/atig/ofilter/geo.rb +17 -0
  113. data/lib/atig/ofilter/short_url.rb +47 -0
  114. data/lib/atig/option.rb +90 -0
  115. data/lib/atig/scheduler.rb +79 -0
  116. data/lib/atig/search.rb +22 -0
  117. data/lib/atig/search_twitter.rb +21 -0
  118. data/lib/atig/sized_hash.rb +33 -0
  119. data/lib/atig/stream.rb +66 -0
  120. data/lib/atig/twitter.rb +79 -0
  121. data/lib/atig/twitter_struct.rb +63 -0
  122. data/lib/atig/unu.rb +27 -0
  123. data/lib/atig/update_checker.rb +53 -0
  124. data/lib/atig/url_escape.rb +62 -0
  125. data/lib/atig/util.rb +16 -0
  126. data/lib/atig/version.rb +3 -0
  127. data/lib/memory_profiler.rb +77 -0
  128. data/spec/command/autofix_spec.rb +35 -0
  129. data/spec/command/destroy_spec.rb +98 -0
  130. data/spec/command/dm_spec.rb +28 -0
  131. data/spec/command/favorite_spec.rb +55 -0
  132. data/spec/command/limit_spec.rb +27 -0
  133. data/spec/command/location_spec.rb +25 -0
  134. data/spec/command/name_spec.rb +19 -0
  135. data/spec/command/option_spec.rb +133 -0
  136. data/spec/command/refresh_spec.rb +22 -0
  137. data/spec/command/reply_spec.rb +79 -0
  138. data/spec/command/retweet_spec.rb +66 -0
  139. data/spec/command/spam_spec.rb +27 -0
  140. data/spec/command/status_spec.rb +44 -0
  141. data/spec/command/thread_spec.rb +91 -0
  142. data/spec/command/time_spec.rb +52 -0
  143. data/spec/command/uptime_spec.rb +55 -0
  144. data/spec/command/user_info_spec.rb +42 -0
  145. data/spec/command/user_spec.rb +50 -0
  146. data/spec/command/version_spec.rb +67 -0
  147. data/spec/command/whois_spec.rb +78 -0
  148. data/spec/db/followings_spec.rb +100 -0
  149. data/spec/db/listenable_spec.rb +32 -0
  150. data/spec/db/lists_spec.rb +104 -0
  151. data/spec/db/roman_spec.rb +17 -0
  152. data/spec/db/sized_uniq_array_spec.rb +63 -0
  153. data/spec/db/statuses_spec.rb +180 -0
  154. data/spec/ifilter/expand_url_spec.rb +44 -0
  155. data/spec/ifilter/retweet_spec.rb +28 -0
  156. data/spec/ifilter/retweet_time_spec.rb +25 -0
  157. data/spec/ifilter/sanitize_spec.rb +25 -0
  158. data/spec/ifilter/sid_spec.rb +29 -0
  159. data/spec/ifilter/strip_spec.rb +23 -0
  160. data/spec/ifilter/tid_spec.rb +29 -0
  161. data/spec/ifilter/utf7_spec.rb +30 -0
  162. data/spec/levenshtein_spec.rb +24 -0
  163. data/spec/ofilter/escape_url_spec.rb +50 -0
  164. data/spec/ofilter/footer_spec.rb +32 -0
  165. data/spec/ofilter/geo_spec.rb +33 -0
  166. data/spec/ofilter/short_url_spec.rb +127 -0
  167. data/spec/option_spec.rb +91 -0
  168. data/spec/sized_hash_spec.rb +45 -0
  169. data/spec/spec_helper.rb +35 -0
  170. data/spec/update_checker_spec.rb +55 -0
  171. metadata +326 -0
@@ -0,0 +1,50 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/command/user'
5
+ require 'atig/command/command_helper'
6
+
7
+ describe Atig::Command::User do
8
+ include CommandHelper
9
+ before do
10
+ @command = init Atig::Command::User
11
+ end
12
+
13
+ it "should have '/me status' name" do
14
+ @gateway.names.should == ['user', 'u']
15
+ end
16
+
17
+ it "should" do
18
+ foo = entry user(1,'mzp'),status('foo')
19
+ bar = entry user(1,'mzp'),status('bar')
20
+ baz = entry user(1,'mzp'),status('baz')
21
+ @api.
22
+ should_receive(:get).
23
+ with('statuses/user_timeline',:count=>20,:screen_name=>'mzp').
24
+ and_return([foo, bar, baz])
25
+ @statuses.should_receive(:add).with(any_args).at_least(3)
26
+ @statuses.
27
+ should_receive(:find_by_screen_name).
28
+ with('mzp',:limit=>20).
29
+ and_return([foo, bar, baz])
30
+ @channel.should_receive(:message).with(anything, Net::IRC::Constants::NOTICE).at_least(3)
31
+ call "#twitter","user",%w(mzp)
32
+ end
33
+
34
+ it "should get specified statuses" do
35
+ foo = entry user(1,'mzp'),status('foo')
36
+ bar = entry user(1,'mzp'),status('bar')
37
+ baz = entry user(1,'mzp'),status('baz')
38
+ @api.
39
+ should_receive(:get).
40
+ with('statuses/user_timeline',:count=>200,:screen_name=>'mzp').
41
+ and_return([foo, bar, baz])
42
+ @statuses.should_receive(:add).with(any_args).at_least(3)
43
+ @statuses.
44
+ should_receive(:find_by_screen_name).
45
+ with('mzp',:limit=>200).
46
+ and_return([foo, bar, baz])
47
+ @channel.should_receive(:message).with(anything, Net::IRC::Constants::NOTICE).at_least(3)
48
+ call "#twitter","user",%w(mzp 200)
49
+ end
50
+ end
@@ -0,0 +1,67 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/command/version'
5
+ require 'atig/command/command_helper'
6
+
7
+ describe Atig::Command::Version do
8
+ include CommandHelper
9
+
10
+ before do
11
+ @command = init Atig::Command::Version
12
+ @status = stub "status"
13
+ @status.stub!(:source).and_return('<a href="http://echofon.com/" rel="nofollow">Echofon</a>')
14
+ @user = stub "user"
15
+ @user.stub!(:status).and_return(@status)
16
+ end
17
+
18
+ it "should provide version command" do
19
+ @gateway.names.should == ['version']
20
+ end
21
+
22
+ it "should show the source via DB" do
23
+ @statuses.
24
+ should_receive(:find_by_screen_name).
25
+ with('mzp',:limit => 1).
26
+ and_return([ entry(@user,@status) ])
27
+ @channel.
28
+ should_receive(:message).
29
+ with(anything, Net::IRC::Constants::NOTICE).
30
+ and_return{|s,_|
31
+ s.status.text.should == "\x01Echofon <http://echofon.com/>\x01"
32
+ }
33
+ call '#twitter','version',%w(mzp)
34
+ end
35
+
36
+ it "should show the source of web" do
37
+ status = stub "status"
38
+ status.stub!(:source).and_return('web')
39
+ @statuses.
40
+ should_receive(:find_by_screen_name).
41
+ with('mzp',:limit => 1).
42
+ and_return([ entry(@user,status) ])
43
+ @channel.
44
+ should_receive(:message).
45
+ with(anything, Net::IRC::Constants::NOTICE).
46
+ and_return{|s,_|
47
+ s.status.text.should == "\x01web\x01"
48
+ }
49
+ call '#twitter','version',%w(mzp)
50
+ end
51
+
52
+ it "should show the source via API" do
53
+ @statuses.stub!(:find_by_screen_name).and_return(@status)
54
+ @statuses.should_receive(:find_by_screen_name).with('mzp',:limit => 1).and_return(nil)
55
+ @statuses.should_receive(:add).with(:status => @status, :user => @user, :source=>:version)
56
+ @api.should_receive(:get).with('users/show',:screen_name=>'mzp').and_return(@user)
57
+
58
+ @channel.
59
+ should_receive(:message).
60
+ with(anything, Net::IRC::Constants::NOTICE).
61
+ and_return{|s,_|
62
+ s.status.text.should == "\x01Echofon <http://echofon.com/>\x01"
63
+ }
64
+
65
+ call '#twitter','version',%w(mzp)
66
+ end
67
+ end
@@ -0,0 +1,78 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/command/whois'
5
+ require 'atig/command/command_helper'
6
+ require 'atig/command/info'
7
+
8
+ include Net::IRC::Constants
9
+
10
+ describe Atig::Command::Whois do
11
+ include CommandHelper
12
+
13
+
14
+ def time(t)
15
+ t.utc.strftime("%a %b %d %H:%M:%S +0000 %Y")
16
+ end
17
+
18
+ before do
19
+ @command = init Atig::Command::Whois
20
+ @status = stub 'status'
21
+ @status.stub!(:created_at).and_return(time(::Time.at(42)))
22
+ @user = stub "user"
23
+ @user.stub!(:name) .and_return('name')
24
+ @user.stub!(:id) .and_return('10')
25
+ @user.stub!(:screen_name).and_return('screen_name')
26
+ @user.stub!(:description).and_return('blah blah')
27
+ @user.stub!(:protected) .and_return(false)
28
+ @user.stub!(:location) .and_return('Tokyo, Japan')
29
+ @user.stub!(:created_at) .and_return(time(::Time.at(0)))
30
+ @user.stub!(:status) .and_return(@status)
31
+
32
+ ::Time.stub!(:now).and_return(::Time.at(50))
33
+ @followings.stub!(:find_by_screen_name).with('mzp').and_return(@user)
34
+ end
35
+
36
+ it "should proide whois command" do
37
+ @command.command_name.should == %w(whois)
38
+ end
39
+
40
+ it "should show profile" do
41
+ commands = []
42
+ @gateway.should_receive(:post){|_,command,_,_,*params|
43
+ commands << command
44
+ case command
45
+ when RPL_WHOISUSER
46
+ params.should == ['id=10', 'twitter.com', "*", 'name / blah blah']
47
+ when RPL_WHOISSERVER
48
+ params.should == ['twitter.com', 'Tokyo, Japan']
49
+ when RPL_WHOISIDLE
50
+ params.should == ["8", "0", "seconds idle, signon time"]
51
+ when RPL_ENDOFWHOIS
52
+ params.should == ["End of WHOIS list"]
53
+ end
54
+ }.at_least(4)
55
+ call '#twitter','whois',%w(mzp)
56
+ commands.should == [ RPL_WHOISUSER, RPL_WHOISSERVER, RPL_WHOISIDLE, RPL_ENDOFWHOIS]
57
+ end
58
+
59
+ it "should append /protect if the user is protected" do
60
+ @user.stub!(:protected).and_return(true)
61
+ commands = []
62
+ @gateway.should_receive(:post){|_,command,_,_,*params|
63
+ commands << command
64
+ case command
65
+ when RPL_WHOISUSER
66
+ params.should == ['id=10', 'twitter.com/protected', "*", 'name / blah blah']
67
+ when RPL_WHOISSERVER
68
+ params.should == ['twitter.com/protected', 'Tokyo, Japan']
69
+ when RPL_WHOISIDLE
70
+ params.should == ["8", "0", "seconds idle, signon time"]
71
+ when RPL_ENDOFWHOIS
72
+ params.should == ["End of WHOIS list"]
73
+ end
74
+ }.at_least(4)
75
+ call '#twitter','whois',%w(mzp)
76
+ commands.should == [ RPL_WHOISUSER, RPL_WHOISSERVER, RPL_WHOISIDLE, RPL_ENDOFWHOIS]
77
+ end
78
+ end
@@ -0,0 +1,100 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/db/followings'
5
+
6
+ describe Atig::Db::Followings,"when it is empty" do
7
+ before do
8
+ FileUtils.rm_f 'following.test.db'
9
+ @db = Atig::Db::Followings.new('following.test.db')
10
+ end
11
+
12
+ it "should be emtpy" do
13
+ @db.empty?.should be_true
14
+ end
15
+ end
16
+
17
+ describe Atig::Db::Followings,"when updated users" do
18
+ def user(id, name, protect, only)
19
+ OpenStruct.new(:id => id, :screen_name=>name, :protected=>protect, :only=>only)
20
+ end
21
+
22
+ before do
23
+ @alice = user 1,'alice' , false, false
24
+ @bob = user 2,'bob' , true , false
25
+ @charriey = user 3,'charriey', false, true
26
+
27
+ FileUtils.rm_f 'following.test.db'
28
+ @db = Atig::Db::Followings.new('following.test.db')
29
+ @db.update [ @alice, @bob ]
30
+
31
+ @listen = {}
32
+ @db.listen do|kind, users|
33
+ @listen[kind] = users
34
+ end
35
+ end
36
+
37
+ it "should return size" do
38
+ @db.size.should == 2
39
+ end
40
+
41
+ it "should be invalidated" do
42
+ called = false
43
+ @db.on_invalidated do
44
+ called = true
45
+ end
46
+ @db.invalidate
47
+
48
+ called.should be_true
49
+ end
50
+
51
+ it "should not empty" do
52
+ @db.empty?.should be_false
53
+ end
54
+
55
+ it "should call listener with :join" do
56
+ @db.update [ @alice, @bob, @charriey ]
57
+ @listen[:join].should == [ @charriey ]
58
+ @listen[:part].should == nil
59
+ @listen[:mode].should == nil
60
+ end
61
+
62
+ it "should call listener with :part" do
63
+ @db.update [ @alice ]
64
+ @listen[:join].should == nil
65
+ @listen[:part].should == [ @bob ]
66
+ @listen[:mode].should == nil
67
+ end
68
+
69
+ it "should not found removed user[BUG]" do
70
+ @db.include?(@bob).should == true
71
+ @db.update [ @alice ]
72
+ # now, @bob is not member
73
+ @db.include?(@bob).should == false
74
+ end
75
+
76
+ it "should call listener with :mode" do
77
+ bob = user 5,'bob', false, false
78
+
79
+ @db.update [ @alice, bob ]
80
+ @listen[:join].should == nil
81
+ @listen[:part].should == nil
82
+ @listen[:mode].should == [ bob ]
83
+ end
84
+
85
+ it "should have users" do
86
+ @db.users.should == [ @alice, @bob ]
87
+ end
88
+
89
+ it "should be found by screen_name" do
90
+ @db.find_by_screen_name('alice').should == @alice
91
+ @db.find_by_screen_name('???').should == nil
92
+ end
93
+
94
+ it "should check include" do
95
+ alice = user @alice.id,'alice', true, true
96
+ @db.include?(@charriey).should be_false
97
+ @db.include?(@alice).should be_true
98
+ @db.include?(alice).should be_true
99
+ end
100
+ end
@@ -0,0 +1,32 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/db/listenable'
5
+
6
+ class SampleListener
7
+ include Atig::Db::Listenable
8
+
9
+ def hi(*args)
10
+ notify(*args)
11
+ end
12
+ end
13
+
14
+ describe Atig::Db::Listenable, "when it is called" do
15
+ before do
16
+ @listeners = SampleListener.new
17
+
18
+ @args = []
19
+ @listeners.listen {|*args| @args << args }
20
+ @listeners.listen {|*args| @args << args }
21
+ @listeners.listen {|*args| @args << args }
22
+ end
23
+
24
+ it "should call all listener" do
25
+ @listeners.hi 1,2,3
26
+
27
+ @args.length.should == 3
28
+ 1.upto(2) {|i|
29
+ @args[i].should == [1,2,3]
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,104 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/db/lists'
5
+
6
+ describe Atig::Db::Lists do
7
+ def user(id, name, protect, only)
8
+ OpenStruct.new(:id => id, :screen_name=>name, :protected=>protect, :only=>only)
9
+ end
10
+
11
+ before do
12
+ FileUtils.rm_rf "test-a.db"
13
+ @lists = Atig::Db::Lists.new "test-%s.db"
14
+ @alice = user 1,'alice' , false, false
15
+ @bob = user 2,'bob' , true , false
16
+ @charriey = user 3,'charriey', false, true
17
+
18
+ @args = {}
19
+ @lists.listen{|kind,*args| @args[kind] = args }
20
+ end
21
+
22
+ it "should have list" do
23
+ @lists.update("a" => [ @alice, @bob ],
24
+ "b" => [ @alice, @bob , @charriey ])
25
+
26
+ @lists.find_by_screen_name('alice').sort.should == ["a", "b"]
27
+ @lists.find_by_screen_name('charriey').should == ["b"]
28
+ end
29
+
30
+ it "should have lists" do
31
+ @lists.update("a" => [ @alice, @bob ],
32
+ "b" => [ @alice, @bob , @charriey ])
33
+
34
+ @lists.find_by_list_name('a').should == [ @alice, @bob ]
35
+ end
36
+
37
+ it "should have each" do
38
+ data = {
39
+ "a" => [ @alice, @bob ],
40
+ "b" => [ @alice, @bob , @charriey ]
41
+ }
42
+ @lists.update(data)
43
+
44
+ hash = {}
45
+ @lists.each do|name,users|
46
+ hash[name] = users
47
+ end
48
+ hash.should == data
49
+ end
50
+
51
+ it "should call listener when new list" do
52
+ @lists.update("a" => [ @alice, @bob ])
53
+
54
+ @args.keys.should include(:new, :join)
55
+ @args[:new].should == [ "a" ]
56
+ @args[:join].should == [ "a", [ @alice, @bob ] ]
57
+ end
58
+
59
+ it "should call listener when partcial update" do
60
+ @lists.update("a" => [ @alice ])
61
+ @lists["a"].update([ @alice, @bob, @charriey ])
62
+ @args[:join].should == ["a", [ @bob, @charriey ]]
63
+ end
64
+
65
+ it "should call on_invalidated" do
66
+ called = false
67
+ @lists.on_invalidated do|name|
68
+ name.should == "a"
69
+ called = true
70
+ end
71
+ @lists.invalidate("a")
72
+
73
+ called.should be_true
74
+ end
75
+
76
+ it "should call listener when delete list" do
77
+ @lists.update("a" => [ @alice, @bob ])
78
+ @lists.update({})
79
+ @args.keys.should include(:new, :join, :del)
80
+ @args[:del].should == ["a"]
81
+ end
82
+
83
+ it "should call listener when join user" do
84
+ @lists.update("a" => [ @alice ])
85
+ @lists.update("a" => [ @alice, @bob, @charriey ])
86
+
87
+ @args[:join].should == ["a", [ @bob, @charriey ]]
88
+ end
89
+
90
+ it "should call listener when exit user" do
91
+ @lists.update("a" => [ @alice, @bob, @charriey ])
92
+ @lists.update("a" => [ @alice ])
93
+ @args[:part].should == ["a", [ @bob, @charriey ]]
94
+ end
95
+
96
+ it "should call listener when change user mode" do
97
+ @lists.update("a" => [ @alice, @bob ])
98
+ bob = user @bob.id, 'bob', false, false
99
+ @lists.update("a" => [ @alice, bob ])
100
+
101
+ @args[:mode].should == [ "a", [ bob ]]
102
+ end
103
+ end
104
+
@@ -0,0 +1,17 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/db/roman'
5
+
6
+ describe Atig::Db::Roman do
7
+ before do
8
+ @roman = Atig::Db::Roman.new
9
+ end
10
+
11
+ it "should make readble tid" do
12
+ @roman.make(0).should == 'a'
13
+ @roman.make(1).should == 'i'
14
+ @roman.make(2).should == 'u'
15
+ end
16
+ end
17
+