test/facebook/test_handler.rb in rest-more-1.0.2 vs test/facebook/test_handler.rb in rest-more-2.0.0
- old
+ new
@@ -12,21 +12,21 @@
stub_request(:get, 'https://graph.facebook.com/me').
to_return(:body => '{}')
logger = []
rg = RC::Facebook.new(:log_method => lambda{ |s| logger << [s] })
- rg.get('me')
+ rg.get('me').tap{}
- logger.size.should.eq 2
+ logger.size.should.eq 3 # Auto + Future + Requested
end
end
describe 'with Graph API' do
before do
@id = lambda{ |env| env }
@error = '{"error":{"type":"Exception","message":"(#2500)"}}'
- @error_hash = RC::JsonDecode.json_decode(@error)
+ @error_hash = RC::Json.decode(@error)
stub_request(:get, 'https://graph.facebook.com/me').
to_return(:body => @error)
end
@@ -35,11 +35,11 @@
should.eq @error_hash
end
should 'raise ::RC::Facebook::Error in default error_handler' do
begin
- RC::Facebook.new.get('me')
+ RC::Facebook.new.get('me').tap{}
rescue ::RC::Facebook::Error => e
e.error .should.eq @error_hash
e.message.should.eq \
"#{@error_hash.inspect} from https://graph.facebook.com/me"
end
@@ -54,11 +54,11 @@
# {"key":"query","value":
# "SELECT name FROM bad_table WHERE uid=12345"}]}
before do
@id = lambda{ |env| env }
@fql_error = '{"error_code":603,"error_msg":"Unknown table: bad"}'
- @fql_error_hash = RC::JsonDecode.json_decode(@fql_error)
+ @fql_error_hash = RC::Json.decode(@fql_error)
@bad_fql_query = 'SELECT name FROM bad_table WHERE uid="12345"'
bad_fql_request = "https://api.facebook.com/method/fql.query?" \
"format=json&query=#{CGI.escape(@bad_fql_query)}"
@@ -70,10 +70,10 @@
should.eq @fql_error_hash
end
should 'raise ::RC::Facebook::Error in default error_handler' do
begin
- RC::Facebook.new.fql(@bad_fql_query)
+ RC::Facebook.new.fql(@bad_fql_query).tap{}
rescue ::RC::Facebook::Error => e
e.error .should.eq @fql_error_hash
e.message.should.start_with?(
"#{@fql_error_hash.inspect} from " \
"https://api.facebook.com/method/fql.query?")