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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -2
  4. data/Gemfile +2 -0
  5. data/README.mkdn +2 -0
  6. data/Rakefile +0 -6
  7. data/atig.gemspec +21 -20
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/{bin → exe}/atig +0 -0
  11. data/lib/atig/agent/agent.rb +4 -4
  12. data/lib/atig/agent/dm.rb +4 -4
  13. data/lib/atig/agent/following.rb +3 -3
  14. data/lib/atig/agent/list.rb +2 -2
  15. data/lib/atig/agent/list_status.rb +6 -6
  16. data/lib/atig/agent/stream_follow.rb +2 -2
  17. data/lib/atig/agent/user_stream.rb +3 -3
  18. data/lib/atig/basic_twitter.rb +1 -3
  19. data/lib/atig/bitly.rb +1 -1
  20. data/lib/atig/channel/channel.rb +1 -1
  21. data/lib/atig/channel/list.rb +3 -3
  22. data/lib/atig/channel/retweet.rb +1 -1
  23. data/lib/atig/channel/timeline.rb +1 -1
  24. data/lib/atig/command/autofix.rb +4 -4
  25. data/lib/atig/command/destroy.rb +1 -1
  26. data/lib/atig/command/dm.rb +2 -2
  27. data/lib/atig/command/favorite.rb +1 -1
  28. data/lib/atig/command/info.rb +2 -2
  29. data/lib/atig/command/reply.rb +2 -2
  30. data/lib/atig/command/retweet.rb +2 -2
  31. data/lib/atig/command/search.rb +2 -2
  32. data/lib/atig/command/status.rb +3 -3
  33. data/lib/atig/command/user.rb +3 -3
  34. data/lib/atig/command/version.rb +3 -3
  35. data/lib/atig/db/followings.rb +5 -6
  36. data/lib/atig/db/statuses.rb +12 -10
  37. data/lib/atig/db/transaction.rb +1 -1
  38. data/lib/atig/gateway/channel.rb +1 -2
  39. data/lib/atig/gateway/session.rb +13 -13
  40. data/lib/atig/http.rb +4 -4
  41. data/lib/atig/ifilter/expand_url.rb +1 -1
  42. data/lib/atig/ifilter/retweet.rb +1 -1
  43. data/lib/atig/ifilter/retweet_time.rb +1 -1
  44. data/lib/atig/ifilter/sanitize.rb +1 -1
  45. data/lib/atig/ifilter/strip.rb +1 -1
  46. data/lib/atig/ifilter/xid.rb +1 -1
  47. data/lib/atig/oauth.rb +3 -3
  48. data/lib/atig/ofilter/escape_url.rb +1 -1
  49. data/lib/atig/ofilter/footer.rb +1 -1
  50. data/lib/atig/ofilter/geo.rb +1 -1
  51. data/lib/atig/ofilter/short_url.rb +1 -1
  52. data/lib/atig/option.rb +1 -1
  53. data/lib/atig/optparse.rb +22 -11
  54. data/lib/atig/search.rb +4 -2
  55. data/lib/atig/stream.rb +1 -1
  56. data/lib/atig/twitter.rb +5 -4
  57. data/lib/atig/update_checker.rb +2 -2
  58. data/lib/atig/url_escape.rb +1 -1
  59. data/lib/atig/version.rb +1 -1
  60. data/lib/memory_profiler.rb +1 -1
  61. data/spec/command/autofix_spec.rb +7 -8
  62. data/spec/command/destroy_spec.rb +12 -13
  63. data/spec/command/dm_spec.rb +5 -6
  64. data/spec/command/favorite_spec.rb +11 -12
  65. data/spec/command/limit_spec.rb +6 -7
  66. data/spec/command/location_spec.rb +4 -5
  67. data/spec/command/name_spec.rb +2 -3
  68. data/spec/command/option_spec.rb +28 -29
  69. data/spec/command/refresh_spec.rb +3 -4
  70. data/spec/command/reply_spec.rb +22 -23
  71. data/spec/command/retweet_spec.rb +17 -18
  72. data/spec/command/spam_spec.rb +4 -5
  73. data/spec/command/status_spec.rb +19 -20
  74. data/spec/command/thread_spec.rb +20 -21
  75. data/spec/command/time_spec.rb +18 -21
  76. data/spec/command/uptime_spec.rb +17 -18
  77. data/spec/command/user_info_spec.rb +13 -16
  78. data/spec/command/user_spec.rb +13 -14
  79. data/spec/command/version_spec.rb +25 -29
  80. data/spec/command/whois_spec.rb +25 -26
  81. data/spec/command_helper.rb +2 -2
  82. data/spec/db/followings_spec.rb +22 -23
  83. data/spec/db/listenable_spec.rb +2 -3
  84. data/spec/db/lists_spec.rb +16 -17
  85. data/spec/db/roman_spec.rb +3 -5
  86. data/spec/db/sized_uniq_array_spec.rb +13 -14
  87. data/spec/db/statuses_spec.rb +69 -70
  88. data/spec/ifilter/expand_url_spec.rb +18 -20
  89. data/spec/ifilter/retweet_spec.rb +4 -5
  90. data/spec/ifilter/retweet_time_spec.rb +4 -5
  91. data/spec/ifilter/sanitize_spec.rb +5 -6
  92. data/spec/ifilter/sid_spec.rb +6 -7
  93. data/spec/ifilter/strip_spec.rb +3 -4
  94. data/spec/ifilter/tid_spec.rb +6 -7
  95. data/spec/levenshtein_spec.rb +2 -3
  96. data/spec/ofilter/escape_url_spec.rb +13 -14
  97. data/spec/ofilter/footer_spec.rb +10 -11
  98. data/spec/ofilter/geo_spec.rb +12 -13
  99. data/spec/ofilter/short_url_spec.rb +28 -29
  100. data/spec/option_spec.rb +23 -24
  101. data/spec/sized_hash_spec.rb +5 -6
  102. data/spec/spec_helper.rb +8 -6
  103. data/spec/update_checker_spec.rb +14 -15
  104. metadata +9 -32
  105. data/docs/_static/allow.png +0 -0
  106. data/docs/_static/emacs.png +0 -0
  107. data/docs/_static/irc_setting.png +0 -0
  108. data/docs/_static/irssi.png +0 -0
  109. data/docs/_static/limechat.png +0 -0
  110. data/docs/_static/limechat_s.png +0 -0
  111. data/docs/_static/oauth_channel.png +0 -0
  112. data/docs/_static/screenshot.png +0 -0
  113. data/docs/_static/structure.png +0 -0
  114. data/docs/_static/verify.png +0 -0
  115. data/docs/changelog.rst +0 -233
  116. data/docs/commandline_options.rst +0 -21
  117. data/docs/commands.rst +0 -84
  118. data/docs/conf.py +0 -194
  119. data/docs/config.rst +0 -159
  120. data/docs/feature.rst +0 -41
  121. data/docs/hacking_guide.rst +0 -43
  122. data/docs/index.rst +0 -102
  123. data/docs/irc.rst +0 -31
  124. data/docs/options.rst +0 -76
  125. data/docs/quickstart.rst +0 -96
  126. data/docs/resize.sh +0 -7
  127. data/docs/tiarra.rst +0 -2
  128. data/docs/tig.rst +0 -21
  129. data/requirements.txt +0 -5
@@ -5,14 +5,16 @@ require 'atig/url_escape'
5
5
  module Atig
6
6
  class Search
7
7
  def search(query, options = {})
8
+ options[:q] = query
9
+
8
10
  search = URI("https://search.twitter.com")
9
11
  search.path = "/search.json"
10
- params = options; options[:q] = query
11
12
  search.query = options.to_query_str
13
+
12
14
  http = Http.new nil
13
15
  req = http.req(:get, search)
14
16
  res = http.http(search, 5, 10).request(req)
15
- res = JSON.parse(res.body)
17
+ JSON.parse(res.body)
16
18
  rescue Errno::ETIMEDOUT, JSON::ParserError, IOError, Timeout::Error, Errno::ECONNRESET => e
17
19
  @log.error e
18
20
  text
@@ -33,7 +33,7 @@ module Atig
33
33
 
34
34
  http = Net::HTTP.new(uri.host, uri.port)
35
35
  http.use_ssl = true
36
- request = Net::HTTP::Get.new(uri.request_uri)
36
+ request = Net::HTTP::Get.new(uri.request_uri, {"Accept-Encoding" => "identity"})
37
37
  request.oauth!(http, @access.consumer, @access)
38
38
  http.request(request) do |response|
39
39
  unless response.code == '200' then
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ require 'timeout'
3
4
  require 'atig/basic_twitter'
4
5
  require 'atig/http'
5
6
 
@@ -17,8 +18,8 @@ module Atig
17
18
  r = []
18
19
  cursor = -1
19
20
  1.upto(limit) do |num|
20
- options = {:cursor => cursor}.merge(opts)
21
- ret = api(path, options, { :authenticate => true })
21
+ options = {cursor: cursor}.merge(opts)
22
+ ret = api(path, options, { authenticate: true })
22
23
  r.concat ret[name]
23
24
  cursor = ret[:next_cursor]
24
25
  break if cursor.zero?
@@ -30,7 +31,7 @@ module Atig
30
31
  methods.each do |m|
31
32
  self.module_eval <<END
32
33
  def #{m}(path, query = {}, opts = {})
33
- opts.update( :method => :#{m})
34
+ opts.update( method: :#{m})
34
35
  api path, query, opts
35
36
  end
36
37
  END
@@ -56,7 +57,7 @@ END
56
57
  end
57
58
 
58
59
  def oauth(time, req)
59
- timeout(time) do
60
+ Timeout.timeout(time) do
60
61
  headers = {}
61
62
  req.each{|k,v| headers[k] = v }
62
63
 
@@ -3,7 +3,7 @@
3
3
  module Atig
4
4
  module UpdateChecker
5
5
  def commits
6
- uri = URI("https://api.github.com/repos/mzp/atig/commits")
6
+ uri = URI("https://api.github.com/repos/atig/atig/commits")
7
7
  http = Atig::Http.new
8
8
  res = http.http(uri).request http.req(:get, uri)
9
9
  JSON.parse(res.body)
@@ -47,7 +47,7 @@ module Atig
47
47
  end.map {|i| i['commit']['message'] }
48
48
  end
49
49
  end
50
- rescue Errno::ECONNREFUSED, Timeout::Error => e
50
+ rescue TypeError, Errno::ECONNREFUSED, Timeout::Error
51
51
  []
52
52
  end
53
53
 
@@ -1,7 +1,7 @@
1
1
  # -*- mode:ruby; coding:utf-8 -*-
2
2
 
3
3
  class Hash
4
- # { :f => "v" } #=> "f=v"
4
+ # { f: "v" } #=> "f=v"
5
5
  # { "f" => [1, 2] } #=> "f=1&f=2"
6
6
  # { "f" => "" } #=> "f="
7
7
  # { "f" => nil } #=> "f"
@@ -1,3 +1,3 @@
1
1
  module Atig
2
- VERSION = "0.4.5"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -16,7 +16,7 @@
16
16
  # each cycle. You can then use 'diff' to spot which strings were added
17
17
  # between runs.
18
18
  class MemoryProfiler
19
- DEFAULTS = {:delay => 10, :string_debug => false}
19
+ DEFAULTS = {delay: 10, string_debug: false}
20
20
 
21
21
  def self.start(opt={})
22
22
  opt = DEFAULTS.dup.merge(opt)
@@ -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/autofix'
5
4
 
6
5
  describe Atig::Command::Autofix do
@@ -10,24 +9,24 @@ describe Atig::Command::Autofix do
10
9
  @opts.autofix = true
11
10
  target = status 'hello', 'id'=>'42'
12
11
  entry = entry user(1,'mzp'), target, "entry", 1
13
- @statuses.should_receive(:find_by_user).with(@me,:limit=>1).and_return([ entry ])
12
+ expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return([ entry ])
14
13
  end
15
14
 
16
15
  it "should post normal tweet" do
17
16
  res = status('blah blah')
18
- @api.should_receive(:post).with('statuses/update', {:status=>'blah blah'}).and_return(res)
17
+ expect(@api).to receive(:post).with('statuses/update', {status:'blah blah'}).and_return(res)
19
18
 
20
19
  call '#twitter', "autofix", %w(blah blah)
21
20
  end
22
21
 
23
22
  it "should delete old similar tweet" do
24
23
  res = status('hillo')
25
- @api.should_receive(:post).with('statuses/update', {:status=>'hillo'}).and_return(res)
26
- @api.should_receive(:post).with("statuses/destroy/42")
27
- @statuses.should_receive(:remove_by_id).with(1)
24
+ expect(@api).to receive(:post).with('statuses/update', {status:'hillo'}).and_return(res)
25
+ expect(@api).to receive(:post).with("statuses/destroy/42")
26
+ expect(@statuses).to receive(:remove_by_id).with(1)
28
27
 
29
- @channel.should_receive(:notify).with("Similar update in previous. Conclude that it has error.")
30
- @channel.should_receive(:notify).with("And overwrite previous as new status: hillo")
28
+ expect(@channel).to receive(:notify).with("Similar update in previous. Conclude that it has error.")
29
+ expect(@channel).to receive(:notify).with("And overwrite previous as new status: hillo")
31
30
 
32
31
  call '#twitter', "autofix", %w(hillo)
33
32
  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/destroy'
5
4
 
6
5
  describe Atig::Command::Destroy,"when status is not removed" do
@@ -12,9 +11,9 @@ describe Atig::Command::Destroy,"when status is not removed" do
12
11
 
13
12
  it "should specified other's status" do
14
13
  entry = entry user(2,'other'), status('blah blah', 'id'=>'1')
15
- @statuses.stub(:find_by_tid).with('b').and_return(entry)
14
+ allow(@statuses).to receive(:find_by_tid).with('b').and_return(entry)
16
15
 
17
- @channel.should_receive(:notify).with("The status you specified by the ID tid is not yours.")
16
+ expect(@channel).to receive(:notify).with("The status you specified by the ID tid is not yours.")
18
17
  call "#twitter","destory",%w(b)
19
18
  end
20
19
  end
@@ -31,20 +30,20 @@ describe Atig::Command::Destroy,"when remove recently tweet" do
31
30
 
32
31
  stub_status(:find_by_tid,'a' => entry)
33
32
  stub_status(:find_by_sid,'mzp:a' => entry)
34
- stub_status(:find_by_screen_name,'mzp' => [ entry ], :default=>[])
33
+ stub_status(:find_by_screen_name,'mzp' => [ entry ], default:[])
35
34
 
36
35
  # api
37
- @api.should_receive(:post).with("statuses/destroy/1")
36
+ expect(@api).to receive(:post).with("statuses/destroy/1")
38
37
 
39
38
  # notice
40
- @channel.should_receive(:notify).with("Destroyed: blah blah")
39
+ expect(@channel).to receive(:notify).with("Destroyed: blah blah")
41
40
 
42
41
  # update topics
43
42
  new_entry = entry @me, status('foo', 'id'=>'2')
44
- @gateway.should_receive(:topic).with(new_entry)
43
+ expect(@gateway).to receive(:topic).with(new_entry)
45
44
 
46
- @statuses.should_receive(:remove_by_id).with(1).and_return{
47
- @statuses.should_receive(:find_by_screen_name).with(@me.screen_name,:limit=>1).and_return{
45
+ expect(@statuses).to receive(:remove_by_id).with(1){
46
+ expect(@statuses).to receive(:find_by_screen_name).with(@me.screen_name,:limit=>1){
48
47
  [ new_entry ]
49
48
  }
50
49
  }
@@ -75,16 +74,16 @@ describe Atig::Command::Destroy,"when remove old tweet" do
75
74
 
76
75
  stub_status(:find_by_tid,'a' => entry)
77
76
  stub_status(:find_by_sid,'mzp:a' => entry)
78
- stub_status(:find_by_screen_name, @db.me.screen_name => [ entry ], :default=>[])
77
+ stub_status(:find_by_screen_name, @db.me.screen_name => [ entry ], default:[])
79
78
 
80
79
  # api
81
- @api.should_receive(:post).with("statuses/destroy/1")
80
+ expect(@api).to receive(:post).with("statuses/destroy/1")
82
81
 
83
82
  # notice
84
- @channel.should_receive(:notify).with("Destroyed: blah blah")
83
+ expect(@channel).to receive(:notify).with("Destroyed: blah blah")
85
84
 
86
85
  # update topics
87
- @statuses.should_receive(:remove_by_id).with(1)
86
+ expect(@statuses).to receive(:remove_by_id).with(1)
88
87
  end
89
88
 
90
89
  it "should specified by tid" do
@@ -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/dm'
5
4
 
6
5
  describe Atig::Command::Dm do
@@ -10,18 +9,18 @@ describe Atig::Command::Dm do
10
9
  end
11
10
 
12
11
  it "should have '/me dm' name" do
13
- @gateway.names.should == ['d', 'dm','dms']
12
+ expect(@gateway.names).to eq(['d', 'dm','dms'])
14
13
  end
15
14
 
16
15
  it "should post the status by API" do
17
- @api.should_receive(:post).with('direct_messages/new',
18
- {:screen_name => 'mzp', :text => 'blah blah'})
19
- @channel.should_receive(:notify).with("Sent message to mzp: blah blah")
16
+ expect(@api).to receive(:post).with('direct_messages/new',
17
+ {screen_name: 'mzp', text: 'blah blah'})
18
+ expect(@channel).to receive(:notify).with("Sent message to mzp: blah blah")
20
19
  call '#twitter', "dm", %w(mzp blah blah)
21
20
  end
22
21
 
23
22
  it "should post the status by API" do
24
- @channel.should_receive(:notify).with("/me dm <SCREEN_NAME> blah blah")
23
+ expect(@channel).to receive(:notify).with("/me dm <SCREEN_NAME> blah blah")
25
24
  call '#twitter', "dm", %w()
26
25
  end
27
26
  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/favorite'
5
4
 
6
5
  describe Atig::Command::Favorite do
@@ -14,40 +13,40 @@ describe Atig::Command::Favorite 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 ], :default=>[])
16
+ stub_status(:find_by_screen_name,'mzp' => [ entry ], default:[])
18
17
  end
19
18
 
20
19
  it "should post fav by tid" do
21
- @api.should_receive(:post).with("favorites/create", {:id => "1"})
22
- @channel.should_receive(:notify).with("FAV: mzp: blah blah")
20
+ expect(@api).to receive(:post).with("favorites/create", {id: "1"})
21
+ expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
23
22
 
24
23
  call "#twitter","fav",%w(a)
25
24
  end
26
25
 
27
26
  it "should post fav by sid" do
28
- @api.should_receive(:post).with("favorites/create", {:id => "1"})
29
- @channel.should_receive(:notify).with("FAV: mzp: blah blah")
27
+ expect(@api).to receive(:post).with("favorites/create", {id: "1"})
28
+ expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
30
29
 
31
30
  call "#twitter","fav",%w(mzp:a)
32
31
  end
33
32
 
34
33
  it "should post fav by screen name" do
35
- @api.should_receive(:post).with("favorites/create", {:id => "1"})
36
- @channel.should_receive(:notify).with("FAV: mzp: blah blah")
34
+ expect(@api).to receive(:post).with("favorites/create", {id: "1"})
35
+ expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
37
36
 
38
37
  call "#twitter","fav",%w(mzp)
39
38
  end
40
39
 
41
40
  it "should post fav by screen name with at" do
42
- @api.should_receive(:post).with("favorites/create", {:id => "1"})
43
- @channel.should_receive(:notify).with("FAV: mzp: blah blah")
41
+ expect(@api).to receive(:post).with("favorites/create", {id: "1"})
42
+ expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
44
43
 
45
44
  call "#twitter","fav",%w(@mzp)
46
45
  end
47
46
 
48
47
  it "should post unfav" do
49
- @api.should_receive(:post).with("favorites/destroy", {:id => "1"})
50
- @channel.should_receive(:notify).with("UNFAV: mzp: blah blah")
48
+ expect(@api).to receive(:post).with("favorites/destroy", {id: "1"})
49
+ expect(@channel).to receive(:notify).with("UNFAV: mzp: blah blah")
51
50
 
52
51
  call "#twitter","unfav",%w(a)
53
52
  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/limit'
5
4
 
6
5
  describe Atig::Command::Limit do
@@ -9,18 +8,18 @@ describe Atig::Command::Limit do
9
8
  before do
10
9
  @reset = ::Time.utc(2010,9,25,8,24,12)
11
10
  @command = init Atig::Command::Limit
12
- @api.stub(:limit).and_return(150)
13
- @api.stub(:remain).and_return(148)
14
- @api.stub(:reset).and_return(@reset)
11
+ allow(@api).to receive(:limit).and_return(150)
12
+ allow(@api).to receive(:remain).and_return(148)
13
+ allow(@api).to receive(:reset).and_return(@reset)
15
14
  end
16
15
 
17
16
  it "should provide limit command" do
18
- @gateway.names.should == ['rls','limit','limits']
17
+ expect(@gateway.names).to eq(['rls','limit','limits'])
19
18
  end
20
19
 
21
20
  it "should show limit" do
22
- @channel.should_receive(:notify).with("148 / 150 (reset at 2010-09-25 08:24:12)")
21
+ expect(@channel).to receive(:notify).with("148 / 150 (reset at 2010-09-25 08:24:12)")
23
22
  call '#twitter', 'limit', []
24
- @gateway.notified.should == '#twitter'
23
+ expect(@gateway.notified).to eq('#twitter')
25
24
  end
26
25
  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/location'
5
4
 
6
5
  describe Atig::Command::Location do
@@ -11,14 +10,14 @@ describe Atig::Command::Location do
11
10
  end
12
11
 
13
12
  it "should update location" do
14
- @api.should_receive(:post).with('account/update_profile',:location=>'some place')
15
- @channel.should_receive(:notify).with("You are in some place now.")
13
+ expect(@api).to receive(:post).with('account/update_profile',:location=>'some place')
14
+ expect(@channel).to receive(:notify).with("You are in some place now.")
16
15
  call '#twitter','location',%w(some place)
17
16
  end
18
17
 
19
18
  it "should reset location" do
20
- @api.should_receive(:post).with('account/update_profile',:location=>'')
21
- @channel.should_receive(:notify).with("You are nowhere now.")
19
+ expect(@api).to receive(:post).with('account/update_profile',:location=>'')
20
+ expect(@channel).to receive(:notify).with("You are nowhere now.")
22
21
  call '#twitter','location',%w()
23
22
  end
24
23
  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/name'
5
4
 
6
5
  describe Atig::Command::Name do
@@ -11,8 +10,8 @@ describe Atig::Command::Name do
11
10
  end
12
11
 
13
12
  it "should update name" do
14
- @api.should_receive(:post).with('account/update_profile',:name=>'mzp')
15
- @channel.should_receive(:notify).with("You are named mzp.")
13
+ expect(@api).to receive(:post).with('account/update_profile',:name=>'mzp')
14
+ expect(@channel).to receive(:notify).with("You are named mzp.")
16
15
  call '#twitter', 'name', %w(mzp)
17
16
  end
18
17
  end
@@ -1,6 +1,5 @@
1
1
  # -*- mode:ruby; coding:utf-8 -*-
2
2
 
3
- require File.expand_path( '../spec_helper', File.dirname(__FILE__))
4
3
  require 'atig/command/option'
5
4
 
6
5
  describe Atig::Command::Option do
@@ -11,7 +10,7 @@ describe Atig::Command::Option do
11
10
  end
12
11
 
13
12
  it "should provide option command" do
14
- @command.command_name.should == %w(opt opts option options)
13
+ expect(@command.command_name).to eq(%w(opt opts option options))
15
14
  end
16
15
  end
17
16
 
@@ -24,20 +23,20 @@ describe Atig::Command::Option, 'when have many property' do
24
23
  @opts.foo2 = 42
25
24
  @opts.foo3 = 42.1
26
25
 
27
- @opts.stub(:foo1=)
28
- @opts.stub(:foo2=)
29
- @opts.stub(:foo3=)
26
+ allow(@opts).to receive(:foo1=)
27
+ allow(@opts).to receive(:foo2=)
28
+ allow(@opts).to receive(:foo3=)
30
29
  end
31
30
 
32
31
  it "should list up values" do
33
32
  xs = []
34
- @channel.stub(:notify){|x| xs << x}
33
+ allow(@channel).to receive(:notify){|x| xs << x}
35
34
  call '#twitter', 'opt', %w()
36
- xs.should == [
35
+ expect(xs).to eq([
37
36
  "foo1 => true",
38
37
  "foo2 => 42",
39
38
  "foo3 => 42.1",
40
- ]
39
+ ])
41
40
  end
42
41
  end
43
42
 
@@ -47,19 +46,19 @@ describe Atig::Command::Option, 'when have bool property' do
47
46
 
48
47
  before do
49
48
  @command = init Atig::Command::Option
50
- @opts.stub(:foo).and_return true
51
- @opts.stub(:foo=){|v| @value = v }
52
- @channel.stub(:notify)
49
+ allow(@opts).to receive(:foo).and_return true
50
+ allow(@opts).to receive(:foo=){|v| @value = v }
51
+ allow(@channel).to receive(:notify)
53
52
  end
54
53
 
55
54
  it "should show the value" do
56
- @channel.should_receive(:notify).with("foo => true")
55
+ expect(@channel).to receive(:notify).with("foo => true")
57
56
  call '#twitter', 'opt', %w(foo)
58
57
  end
59
58
 
60
59
  it "should update the value" do
61
60
  call '#twitter', 'opt', %w(foo false)
62
- @value.should be_false
61
+ expect(@value).to be_falsey
63
62
  end
64
63
  end
65
64
 
@@ -68,19 +67,19 @@ describe Atig::Command::Option, 'when have int property' do
68
67
 
69
68
  before do
70
69
  @command = init Atig::Command::Option
71
- @opts.stub(:foo).and_return 42
72
- @opts.stub(:foo=){|v| @value = v }
73
- @channel.stub(:notify)
70
+ allow(@opts).to receive(:foo).and_return 42
71
+ allow(@opts).to receive(:foo=){|v| @value = v }
72
+ allow(@channel).to receive(:notify)
74
73
  end
75
74
 
76
75
  it "should show the value" do
77
- @channel.should_receive(:notify).with("foo => 42")
76
+ expect(@channel).to receive(:notify).with("foo => 42")
78
77
  call '#twitter', 'opt', %w(foo)
79
78
  end
80
79
 
81
80
  it "should update the value" do
82
81
  call '#twitter', 'opt', %w(foo 42)
83
- @value.should == 42
82
+ expect(@value).to eq(42)
84
83
  end
85
84
  end
86
85
 
@@ -89,19 +88,19 @@ describe Atig::Command::Option, 'when have float property' do
89
88
 
90
89
  before do
91
90
  @command = init Atig::Command::Option
92
- @opts.stub(:foo).and_return 1.23
93
- @opts.stub(:foo=){|v| @value = v }
94
- @channel.stub(:notify)
91
+ allow(@opts).to receive(:foo).and_return 1.23
92
+ allow(@opts).to receive(:foo=){|v| @value = v }
93
+ allow(@channel).to receive(:notify)
95
94
  end
96
95
 
97
96
  it "should show the value" do
98
- @channel.should_receive(:notify).with("foo => 1.23")
97
+ expect(@channel).to receive(:notify).with("foo => 1.23")
99
98
  call '#twitter', 'opt', %w(foo)
100
99
  end
101
100
 
102
101
  it "should update the value" do
103
102
  call '#twitter', 'opt', %w(foo 1.24)
104
- @value.should == 1.24
103
+ expect(@value).to eq(1.24)
105
104
  end
106
105
  end
107
106
 
@@ -110,23 +109,23 @@ describe Atig::Command::Option, 'when have string property' do
110
109
 
111
110
  before do
112
111
  @command = init Atig::Command::Option
113
- @opts.stub(:foo).and_return "bar"
114
- @opts.stub(:foo=){|v| @value = v }
115
- @channel.stub(:notify)
112
+ allow(@opts).to receive(:foo).and_return "bar"
113
+ allow(@opts).to receive(:foo=){|v| @value = v }
114
+ allow(@channel).to receive(:notify)
116
115
  end
117
116
 
118
117
  it "should show the value" do
119
- @channel.should_receive(:notify).with("foo => bar")
118
+ expect(@channel).to receive(:notify).with("foo => bar")
120
119
  call '#twitter', 'opt', %w(foo)
121
120
  end
122
121
 
123
122
  it "should update the value" do
124
123
  call '#twitter', 'opt', %w(foo baz)
125
- @value.should == 'baz'
124
+ expect(@value).to eq('baz')
126
125
  end
127
126
 
128
127
  it "should update the value" do
129
128
  call '#twitter', 'opt', %w(foo blah Blah)
130
- @value.should == 'blah Blah'
129
+ expect(@value).to eq('blah Blah')
131
130
  end
132
131
  end