test/test_yahoo.rb in yahoo-1.0.0 vs test/test_yahoo.rb in yahoo-1.1.0

- old
+ new

@@ -1,7 +1,7 @@ require 'test/unit' -require 'test/uri_stub' +require 'rc_rest/uri_stub' require 'yahoo' class Yahoo::Test < Yahoo def initialize(*args) @@ -29,63 +29,24 @@ URI::HTTP.uris = [] @t = Yahoo::Test.new 'APP_ID' end - def test_check_error_IO - io = StringIO.new '<Error><Message>you broked it</Message></Error>' - @t.check_error io - - rescue Yahoo::Error => e - assert_equal 'you broked it', e.message - - else - flunk 'expected an error' - end - - def test_check_error_REXML__Document + def test_check_error xml = REXML::Document.new '<Error><Message>you broked it</Message></Error>' @t.check_error xml rescue Yahoo::Error => e assert_equal 'you broked it', e.message else flunk 'expected an error' end - def test_get - xml = '<Result>stuff</Result>' - URI::HTTP.responses << xml - - result = @t.test - - assert_equal xml, result.to_s - end - - def test_get_error - def @t.make_url(*args) # HACK extend uri_stub with error raising ability - u = Object.new - def u.open - xml = '<Error><Message>you did the bad thing</Message></Error>' - raise OpenURI::HTTPError.new('400 Bad Request', StringIO.new(xml)) - end - return u - end - - assert_raise Yahoo::Error do @t.test end - end - - def test_initialize - assert_equal 'http://api.test.yahoo.com/TestService/Vtest/test', - @t.instance_variable_get(:@url).to_s - end - def test_make_url - url = @t.make_url :test_param_1 => 'test test', - :test_param_2 => 'tset tset' + url = @t.make_url :param => 'value' - expected = 'http://api.test.yahoo.com/TestService/Vtest/test?appid=APP_ID&output=xml&test_param_1=test%20test&test_param_2=tset%20tset' + expected = 'http://api.test.yahoo.com/TestService/Vtest/test?appid=APP_ID&output=xml&param=value' assert_equal expected, url.to_s end end