Sha256: c8cbebd172af0ee40b19f927164feb4b890457b5fbd7f6ad1b256088a4dd97c8

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'test/unit'
require 'rubygems'
require 'rc_rest/uri_stub'
require 'yahoo'

class Yahoo::Test < Yahoo

  def initialize(*args)
    @host = 'api.test.yahoo.com'
    @service_name = 'TestService'
    @version = 'Vtest'
    super
  end

  def test
    get :test, :test_param => 5
  end

  def parse_response(xml)
    return xml
  end

end

class TestYahoo < Test::Unit::TestCase

  def setup
    URI::HTTP.responses = []
    URI::HTTP.uris = []

    @t = Yahoo::Test.new 'APP_ID'
  end

  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_make_url
    url = @t.make_url :test, :param => 'value'

    expected = 'http://api.test.yahoo.com/TestService/Vtest/test?appid=APP_ID&output=xml&param=value'

    assert_equal expected, url.to_s
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yahoo-1.1.1 test/test_yahoo.rb