rest-more 0.7.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 (81) hide show
  1. data/.gitignore +6 -0
  2. data/.gitmodules +3 -0
  3. data/.travis.yml +13 -0
  4. data/CHANGES.md +7 -0
  5. data/Gemfile +26 -0
  6. data/LICENSE +201 -0
  7. data/README.md +72 -0
  8. data/Rakefile +63 -0
  9. data/TODO.md +14 -0
  10. data/example/rails2/Gemfile +21 -0
  11. data/example/rails2/README +4 -0
  12. data/example/rails2/Rakefile +11 -0
  13. data/example/rails2/app/controllers/application_controller.rb +134 -0
  14. data/example/rails2/app/views/application/helper.html.erb +2 -0
  15. data/example/rails2/config/boot.rb +130 -0
  16. data/example/rails2/config/environment.rb +15 -0
  17. data/example/rails2/config/environments/development.rb +17 -0
  18. data/example/rails2/config/environments/production.rb +28 -0
  19. data/example/rails2/config/environments/test.rb +30 -0
  20. data/example/rails2/config/initializers/cookie_verification_secret.rb +7 -0
  21. data/example/rails2/config/initializers/new_rails_defaults.rb +21 -0
  22. data/example/rails2/config/initializers/session_store.rb +15 -0
  23. data/example/rails2/config/preinitializer.rb +23 -0
  24. data/example/rails2/config/rest-core.yaml +16 -0
  25. data/example/rails2/config/routes.rb +43 -0
  26. data/example/rails2/log +0 -0
  27. data/example/rails2/test/functional/application_controller_test.rb +219 -0
  28. data/example/rails2/test/test_helper.rb +18 -0
  29. data/example/rails2/test/unit/rails_util_test.rb +44 -0
  30. data/example/rails3/Gemfile +20 -0
  31. data/example/rails3/README +4 -0
  32. data/example/rails3/Rakefile +7 -0
  33. data/example/rails3/app/controllers/application_controller.rb +134 -0
  34. data/example/rails3/app/views/application/helper.html.erb +2 -0
  35. data/example/rails3/config.ru +4 -0
  36. data/example/rails3/config/application.rb +23 -0
  37. data/example/rails3/config/boot.rb +6 -0
  38. data/example/rails3/config/environment.rb +5 -0
  39. data/example/rails3/config/environments/development.rb +23 -0
  40. data/example/rails3/config/environments/production.rb +49 -0
  41. data/example/rails3/config/environments/test.rb +30 -0
  42. data/example/rails3/config/initializers/secret_token.rb +7 -0
  43. data/example/rails3/config/initializers/session_store.rb +8 -0
  44. data/example/rails3/config/rest-core.yaml +16 -0
  45. data/example/rails3/config/routes.rb +5 -0
  46. data/example/rails3/test/functional/application_controller_test.rb +219 -0
  47. data/example/rails3/test/test_helper.rb +18 -0
  48. data/example/rails3/test/unit/rails_util_test.rb +44 -0
  49. data/example/sinatra/config.ru +16 -0
  50. data/lib/rest-core/client/facebook.rb +265 -0
  51. data/lib/rest-core/client/facebook/rails_util.rb +334 -0
  52. data/lib/rest-core/client/flurry.rb +107 -0
  53. data/lib/rest-core/client/flurry/rails_util.rb +74 -0
  54. data/lib/rest-core/client/github.rb +18 -0
  55. data/lib/rest-core/client/linkedin.rb +59 -0
  56. data/lib/rest-core/client/mixi.rb +47 -0
  57. data/lib/rest-core/client/simple.rb +2 -0
  58. data/lib/rest-core/client/twitter.rb +101 -0
  59. data/lib/rest-core/client/universal.rb +18 -0
  60. data/lib/rest-more.rb +11 -0
  61. data/lib/rest-more/version.rb +4 -0
  62. data/rest-more.gemspec +127 -0
  63. data/task/.gitignore +1 -0
  64. data/task/gemgem.rb +265 -0
  65. data/test/client/facebook/config/rest-core.yaml +8 -0
  66. data/test/client/facebook/test_api.rb +97 -0
  67. data/test/client/facebook/test_cache.rb +58 -0
  68. data/test/client/facebook/test_default.rb +23 -0
  69. data/test/client/facebook/test_error.rb +65 -0
  70. data/test/client/facebook/test_handler.rb +84 -0
  71. data/test/client/facebook/test_load_config.rb +39 -0
  72. data/test/client/facebook/test_misc.rb +72 -0
  73. data/test/client/facebook/test_oauth.rb +38 -0
  74. data/test/client/facebook/test_old.rb +114 -0
  75. data/test/client/facebook/test_page.rb +106 -0
  76. data/test/client/facebook/test_parse.rb +166 -0
  77. data/test/client/facebook/test_serialize.rb +43 -0
  78. data/test/client/facebook/test_timeout.rb +22 -0
  79. data/test/client/flurry/test_metrics.rb +83 -0
  80. data/test/client/twitter/test_api.rb +37 -0
  81. metadata +155 -0
@@ -0,0 +1,106 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RestCore::Facebook do
5
+ after do
6
+ WebMock.reset!
7
+ RR.verify
8
+ end
9
+
10
+ should 'get the next/prev page' do
11
+ rg = RestCore::Facebook.new(:site => '', :cache => false)
12
+ %w[next previous].each{ |type|
13
+ kind = "#{type}_page"
14
+ rg.send(kind, {}) .should.eq nil
15
+ rg.send(kind, {'paging' => []}).should.eq nil
16
+ rg.send(kind, {'paging' => {}}).should.eq nil
17
+
18
+ stub_request(:get, 'zzz').to_return(:body => '["ok"]')
19
+ rg.send(kind, {'paging' => {type => 'zzz'}}).should.eq ['ok']
20
+ }
21
+ end
22
+
23
+ should 'merge all pages into one' do
24
+ rg = RestCore::Facebook.new(:site => '', :cache => false)
25
+ %w[next previous].each{ |type|
26
+ kind = "#{type}_page"
27
+ data = {'paging' => {type => 'zzz'}, 'data' => ['z']}
28
+
29
+ # invalid pages or just the page itself
30
+ (-1..1).each{ |page|
31
+ rg.for_pages(data, page, {}, kind).should == data
32
+ }
33
+
34
+ (2..4).each{ |pages|
35
+ # merge data
36
+ stub_request(:get, 'zzz').to_return(:body => '{"data":["y"]}')
37
+ rg.for_pages(data, pages, {}, kind).should.eq({'data' => %w[z y]})
38
+
39
+ # this data cannot be merged
40
+ stub_request(:get, 'zzz').to_return(:body => '{"data":"y"}')
41
+ rg.for_pages(data, pages, {}, kind).should.eq({'data' => %w[z]})
42
+ }
43
+
44
+ stub_request(:get, 'zzz').to_return(:body =>
45
+ '{"paging":{"'+type+'":"yyy"},"data":["y"]}')
46
+ stub_request(:get, 'yyy').to_return(:body => '{"data":["x"]}')
47
+
48
+ rg.for_pages(data, 3, {}, kind).should.eq({'data' => %w[z y x]})
49
+ }
50
+ end
51
+
52
+ should 'for_pages with callback' do
53
+ rg = RestCore::Facebook.new(:site => '', :cache => false)
54
+ %w[next previous].each{ |type|
55
+ kind = "#{type}_page"
56
+ data = {'paging' => {type => 'zzz'}, 'data' => ['z']}
57
+
58
+ # invalid pages or just the page itself
59
+ nils = 0
60
+ ranges = -1..1
61
+ ranges.each{ |page|
62
+ rg.for_pages(data, page, {}, kind){ |r|
63
+ if r
64
+ r.should.eq data
65
+ else
66
+ nils += 1
67
+ end
68
+ }.should.eq data
69
+ }
70
+ nils.should.eq ranges.to_a.size
71
+
72
+ (2..4).each{ |pages|
73
+ # merge data
74
+ stub_request(:get, 'zzz').to_return(:body => '{"data":["y"]}')
75
+ expects = [{'data' => %w[y]}, nil]
76
+ rg.for_pages(data, pages, {}, kind){ |r|
77
+ r.should.eq expects.shift
78
+ }.should.eq({'data' => %w[z y]})
79
+ expects.empty?.should.eq true
80
+
81
+ # this data cannot be merged
82
+ stub_request(:get, 'zzz').to_return(:body => '{"data":"y"}')
83
+ expects = [{'data' => 'y'}, nil]
84
+ rg.for_pages(data, pages, {}, kind){ |r|
85
+ r.should.eq expects.shift
86
+ }.should.eq({'data' => %w[z]})
87
+ expects.empty?.should.eq true
88
+ }
89
+
90
+ stub_request(:get, 'zzz').to_return(:body =>
91
+ '{"paging":{"'+type+'":"yyy"},"data":["y"]}')
92
+ stub_request(:get, 'yyy').to_return(:body => '{"data":["x"]}')
93
+
94
+ expects = [{'data' => %w[y]}, {'data' => %w[x]}, nil]
95
+ rg.for_pages(data, 3, {}, kind){ |rr|
96
+ if rr
97
+ r = rr.dup
98
+ r.delete('paging')
99
+ else
100
+ r = rr
101
+ end
102
+ r.should.eq expects.shift
103
+ }.should.eq({'data' => %w[z y x]})
104
+ }
105
+ end
106
+ end
@@ -0,0 +1,166 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RestCore::Facebook do
5
+
6
+ should 'return nil if parse error, but not when call data directly' do
7
+ rg = RestCore::Facebook.new
8
+ rg.parse_cookies!({}).should.eq nil
9
+ rg.data .should.eq({})
10
+ end
11
+
12
+ should 'parse if fbs contains json as well' do
13
+ algorithm = 'HMAC-SHA256'
14
+ user = '{"country"=>"us", "age"=>{"min"=>21}}'
15
+ data = {'algorithm' => algorithm, 'user' => user}
16
+ rg = RestCore::Facebook.new(:data => data, :secret => 'secret')
17
+ sig = rg.send(:calculate_sig, data)
18
+ rg.parse_fbs!("\"#{rg.fbs}\"").should.eq data.merge('sig' => sig)
19
+ end
20
+
21
+ should 'extract correct access_token or fail checking sig' do
22
+ access_token = '1|2-5|f.'
23
+ app_id = '1829'
24
+ secret = app_id.reverse
25
+ sig = '398262caea8442bd8801e8fba7c55c8a'
26
+ fbs = "access_token=#{CGI.escape(access_token)}&expires=0&" \
27
+ "secret=abc&session_key=def-456&sig=#{sig}&uid=3"
28
+
29
+ check = lambda{ |token, fbs1|
30
+ http_cookie =
31
+ "__utma=123; __utmz=456.utmcsr=(d)|utmccn=(d)|utmcmd=(n); " \
32
+ "fbs_#{app_id}=#{fbs1}"
33
+
34
+ rg = RestCore::Facebook.new(:app_id => app_id, :secret => secret)
35
+ rg.parse_rack_env!('HTTP_COOKIE' => http_cookie).
36
+ should.kind_of?(token ? Hash : NilClass)
37
+ rg.access_token.should.eq token
38
+
39
+ rg.parse_rack_env!('HTTP_COOKIE' => nil).should.eq nil
40
+ rg.data.should.eq({})
41
+
42
+ rg.parse_cookies!({"fbs_#{app_id}" => fbs1}).
43
+ should.kind_of?(token ? Hash : NilClass)
44
+ rg.access_token.should.eq token
45
+
46
+ rg.parse_fbs!(fbs1).
47
+ should.kind_of?(token ? Hash : NilClass)
48
+ rg.access_token.should.eq token
49
+ }
50
+ check.call(access_token, fbs)
51
+ check.call(access_token, "\"#{fbs}\"")
52
+ fbs << '&inject=evil"'
53
+ check.call(nil, fbs)
54
+ check.call(nil, "\"#{fbs}\"")
55
+ end
56
+
57
+ should 'not pass if there is no secret, prevent from forgery' do
58
+ rg = RestCore::Facebook.new
59
+ rg.parse_fbs!('"feed=me&sig=bddd192cf27f22c05f61c8bea24fa4b7"').
60
+ should.eq nil
61
+ end
62
+
63
+ should 'parse json correctly' do
64
+ rg = RestCore::Facebook.new
65
+
66
+ rg.parse_json!('bad json') .should.eq nil
67
+ rg.parse_json!('{"no":"sig"}').should.eq nil
68
+ rg.parse_json!('{"feed":"me","sig":"bddd192cf27f22c05f61c8bea24fa4b7"}').
69
+ should.eq nil
70
+
71
+ rg = RestCore::Facebook.new(:secret => 'bread')
72
+ rg.parse_json!('{"feed":"me","sig":"20393e7823730308938a86ecf1c88b14"}').
73
+ should.eq({'feed' => 'me', 'sig' => "20393e7823730308938a86ecf1c88b14"})
74
+ rg.data.empty?.should.eq false
75
+ rg.parse_json!('bad json')
76
+ rg.data.empty?.should.eq true
77
+ end
78
+
79
+ describe 'signed_request' do
80
+ def encode str
81
+ [str].pack('m').tr("\n=", '').tr('+/', '-_')
82
+ end
83
+
84
+ def setup_sr secret, data, sig=nil
85
+ json_encoded = encode(RestCore::JsonDecode.json_encode(data))
86
+ sig ||= OpenSSL::HMAC.digest('sha256', secret, json_encoded)
87
+ "#{encode(sig)}.#{json_encoded}"
88
+ end
89
+
90
+ should 'parse invalid' do
91
+ RC::Facebook.new.parse_signed_request!('bad').should.eq nil
92
+ end
93
+
94
+ should 'parse' do
95
+ secret = 'aloha'
96
+ rg = RestCore::Facebook.new(:secret => secret)
97
+ rg.parse_signed_request!(setup_sr(secret, {'ooh' => 'dir',
98
+ 'moo' => 'bar'}))
99
+ rg.data['ooh'].should.eq 'dir'
100
+ rg.data['moo'].should.eq 'bar'
101
+
102
+ rg.parse_signed_request!(setup_sr(secret, {'ooh' => 'dir',
103
+ 'moo' => 'bar'}, 'wrong')).
104
+ should.eq nil
105
+ rg.data .should.eq({})
106
+ end
107
+
108
+ should 'fbsr and cookies with fbsr' do
109
+ secret = 'lulala'
110
+ code = 'lalalu'
111
+ access_token = 'lololo'
112
+ user_id = 123
113
+ app_id = 456
114
+ rg = RestCore::Facebook.new(:secret => secret,
115
+ :app_id => app_id)
116
+ mock(rg).authorize!(hash_including(:code => code)){
117
+ rg.data = {'access_token' => access_token}
118
+ }.times(2)
119
+
120
+ check = lambda{
121
+ rg.data['code'] .should.eq code
122
+ rg.data['access_token'].should.eq access_token
123
+ rg.data['user_id'] .should.eq user_id
124
+ }
125
+
126
+ rg.parse_fbsr!(setup_sr(secret, 'code' => code, 'user_id' => user_id))
127
+ check.call
128
+ rg.data = nil
129
+ rg.data.should.eq({})
130
+
131
+ rg.parse_cookies!("fbsr_#{app_id}" =>
132
+ setup_sr(secret, 'code' => code, 'user_id' => user_id))
133
+ check.call
134
+ end
135
+ end
136
+
137
+ should 'fallback to ruby-hmac if Digest.new raise an runtime error' do
138
+ key, data = 'top', 'secret'
139
+ digest = OpenSSL::HMAC.digest('sha256', key, data)
140
+ mock(OpenSSL::HMAC).digest('sha256', key, data){ raise 'boom' }
141
+ RestCore::Hmac.sha256(key, data).should.eq digest
142
+ end
143
+
144
+ should 'generate correct fbs with correct sig' do
145
+ RestCore::Facebook.new(:access_token => 'fake', :secret => 's').fbs.
146
+ should.eq \
147
+ "access_token=fake&sig=#{Digest::MD5.hexdigest('access_token=fakes')}"
148
+ end
149
+
150
+ should 'parse fbs from facebook response which lacks sig...' do
151
+ rg = RestCore::Facebook.new(:access_token => 'a', :secret => 'z')
152
+ rg.parse_fbs!(rg.fbs) .should.kind_of?(Hash)
153
+ rg.data.empty?.should.eq false
154
+ rg.parse_fbs!(rg.fbs.sub(/sig\=\w+/, 'sig=abc')).should.eq nil
155
+ rg.data.empty?.should.eq true
156
+ end
157
+
158
+ should 'generate correct fbs with additional parameters' do
159
+ rg = RestCore::Facebook.new(:access_token => 'a', :secret => 'z')
160
+ rg.data['expires'] = '1234'
161
+ rg.parse_fbs!(rg.fbs).should.kind_of?(Hash)
162
+ rg.access_token .should.eq 'a'
163
+ rg.data['expires'] .should.eq '1234'
164
+ end
165
+
166
+ end
@@ -0,0 +1,43 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RestCore::Facebook do
5
+ after do
6
+ WebMock.reset!
7
+ RR.verify
8
+ end
9
+
10
+ should 'be serialized with lighten' do
11
+ engines = begin
12
+ require 'psych'
13
+ YAML::ENGINE.yamler = 'psych' # TODO: probably a bug?
14
+ [Psych, YAML, Marshal]
15
+ rescue LoadError
16
+ [YAML, Marshal]
17
+ end
18
+
19
+ # sorry, it is marshal in 1.8 is broken
20
+ if defined?(RUBY_ENGINE)
21
+ if RUBY_ENGINE == 'ruby' && RUBY_VERSION == '1.8.7'
22
+ engines.pop # REE 1.8.7
23
+ end
24
+ else
25
+ engines.pop # MRI 1.8.7
26
+ end
27
+
28
+ engines.each{ |engine|
29
+ test = lambda{ |obj| engine.load(engine.dump(obj)) }
30
+ rg = RestCore::Facebook.new(:log_handler => lambda{})
31
+ lambda{ test[rg] }.should.raise(TypeError)
32
+ test[rg.lighten].should.eq rg.lighten
33
+ lambda{ test[rg] }.should.raise(TypeError)
34
+ rg.lighten!
35
+ test[rg.lighten].should.eq rg
36
+ }
37
+ end
38
+
39
+ should 'lighten takes options to change attributes' do
40
+ RestCore::Facebook.new.lighten(:timeout => 100 ).timeout.should.eq 100
41
+ RestCore::Facebook.new.lighten(:lang => 'zh-TW').lang.should.eq 'zh-TW'
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RestCore::Facebook do
5
+ after do
6
+ WebMock.reset!
7
+ RR.verify
8
+ end
9
+
10
+ should 'respect timeout' do
11
+ stub_request(:get, 'https://graph.facebook.com/me').
12
+ to_return(:body => '{}')
13
+ mock.proxy(Timeout).timeout(numeric)
14
+ RestCore::Facebook.new.get('me').should.eq({})
15
+ end
16
+
17
+ should 'override timeout' do
18
+ mock(Timeout).timeout(99){ {RestCore::Facebook::RESPONSE_BODY => true} }
19
+ RestCore::Facebook.new(:timeout => 1).get('me', {}, :timeout => 99).
20
+ should.eq true
21
+ end
22
+ end
@@ -0,0 +1,83 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ require 'time'
5
+
6
+ describe RestCore::Flurry do
7
+ after do
8
+ WebMock.reset!
9
+ RR.verify
10
+ end
11
+
12
+ before do
13
+ startDate = '2011-08-23'
14
+ endDate = '2011-09-19'
15
+ @flurry = RestCore::Flurry.new
16
+ stub(Time).now{ Time.parse(endDate, nil) }
17
+ stub_request(:get,
18
+ "http://api.flurry.com/appMetrics/ActiveUsers?" \
19
+ "startDate=#{startDate}&endDate=#{endDate}").
20
+ to_return(:body =>
21
+ '{"@startDate":"2011-08-23",
22
+ "@metric":"ActiveUsersByDay",
23
+ "@endDate":"2011-09-19",
24
+ "@version":"1.0",
25
+ "@generatedDate":"9/19/11 5:54 AM",
26
+ "day":
27
+ [{"@value":"34722","@date":"2011-08-23"},
28
+ {"@value":"33560","@date":"2011-08-24"},
29
+ {"@value":"34392","@date":"2011-08-25"},
30
+ {"@value":"37737","@date":"2011-08-26"},
31
+ {"@value":"41332","@date":"2011-08-27"},
32
+ {"@value":"40456","@date":"2011-08-28"},
33
+ {"@value":"34950","@date":"2011-08-29"},
34
+ {"@value":"34076","@date":"2011-08-30"},
35
+ {"@value":"32096","@date":"2011-08-31"},
36
+ {"@value":"31558","@date":"2011-09-01"},
37
+ {"@value":"33467","@date":"2011-09-02"},
38
+ {"@value":"39306","@date":"2011-09-03"},
39
+ {"@value":"40233","@date":"2011-09-04"},
40
+ {"@value":"37777","@date":"2011-09-05"},
41
+ {"@value":"35829","@date":"2011-09-06"},
42
+ {"@value":"35960","@date":"2011-09-07"},
43
+ {"@value":"34871","@date":"2011-09-08"},
44
+ {"@value":"36683","@date":"2011-09-09"},
45
+ {"@value":"44077","@date":"2011-09-10"},
46
+ {"@value":"45057","@date":"2011-09-11"},
47
+ {"@value":"37750","@date":"2011-09-12"},
48
+ {"@value":"35223","@date":"2011-09-13"},
49
+ {"@value":"34918","@date":"2011-09-14"},
50
+ {"@value":"37587","@date":"2011-09-15"},
51
+ {"@value":"40972","@date":"2011-09-16"},
52
+ {"@value":"45412","@date":"2011-09-17"},
53
+ {"@value":"43920","@date":"2011-09-18"},
54
+ {"@value":"6516","@date":"2011-09-19"}]}')
55
+
56
+ @active_users =
57
+ [["2011-09-19", 6516], ["2011-09-18", 43920], ["2011-09-17", 45412],
58
+ ["2011-09-16", 40972], ["2011-09-15", 37587], ["2011-09-14", 34918],
59
+ ["2011-09-13", 35223], ["2011-09-12", 37750], ["2011-09-11", 45057],
60
+ ["2011-09-10", 44077], ["2011-09-09", 36683], ["2011-09-08", 34871],
61
+ ["2011-09-07", 35960], ["2011-09-06", 35829], ["2011-09-05", 37777],
62
+ ["2011-09-04", 40233], ["2011-09-03", 39306], ["2011-09-02", 33467],
63
+ ["2011-09-01", 31558], ["2011-08-31", 32096], ["2011-08-30", 34076],
64
+ ["2011-08-29", 34950], ["2011-08-28", 40456], ["2011-08-27", 41332],
65
+ ["2011-08-26", 37737], ["2011-08-25", 34392], ["2011-08-24", 33560],
66
+ ["2011-08-23", 34722]]
67
+
68
+ @weekly = [244548, 270227, 248513, 257149]
69
+ end
70
+
71
+ should 'metrics("ActiveUsers")' do
72
+ @flurry.metrics('ActiveUsers', {}, :weeks => 4).should.eq @active_users
73
+
74
+ end
75
+
76
+ should 'weekly(metrics("ActiveUsers"))' do
77
+ @flurry.weekly(@active_users).should.eq @weekly
78
+ end
79
+
80
+ should 'sum(weekly(metrics("ActiveUsers")))' do
81
+ @flurry.sum(@weekly).should.eq [1020437, 775889, 505662, 257149]
82
+ end
83
+ end
@@ -0,0 +1,37 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RestCore::Twitter do
5
+ after do
6
+ WebMock.reset!
7
+ RR.verify
8
+ end
9
+
10
+ should 'get right' do
11
+ stub_request(:get, 'https://api.twitter.com/me').
12
+ to_return(:body => '{"status": "OK"}')
13
+
14
+ RestCore::Twitter.new.get('me').should.eq({'status' => 'OK'})
15
+ end
16
+
17
+ def check status, klass
18
+ stub_request(:delete, 'https://api.twitter.com/123').to_return(
19
+ :body => '{}', :status => status)
20
+
21
+ lambda{
22
+ RestCore::Twitter.new.delete('123')
23
+ }.should.raise(klass)
24
+
25
+ WebMock.reset!
26
+ end
27
+
28
+ should 'raise exception when encountering error' do
29
+ [401, 402, 403].each{ |status|
30
+ check(status, RestCore::Twitter::Error)
31
+ }
32
+
33
+ [500, 502, 503].each{ |status|
34
+ check(status, RestCore::Twitter::Error::ServerError)
35
+ }
36
+ end
37
+ end