test/term_extraction_test.rb in term-extraction-0.1.4 vs test/term_extraction_test.rb in term-extraction-1.0.0

- old
+ new

@@ -1,32 +1,42 @@ require File.dirname(__FILE__) + '/test_helper' +require 'addressable/uri' class TermExtractionTest < Test::Unit::TestCase should 'return correct terms from Yahoo!' do yahoo = TermExtraction::Yahoo.new fake_uri(:get, yahoo.uri, 'yahoo.xml') - assert_equal yahoo.terms, correct_yahoo_terms + assert_equal correct_yahoo_terms, yahoo.terms end should 'return correct terms from Zemanta' do zemanta = TermExtraction::Zemanta.new fake_uri(:post, zemanta.uri, 'zemanta.xml') - assert_equal zemanta.terms, correct_zemanta_terms + assert_equal correct_zemanta_terms, zemanta.terms end + should 'set the correct API uri for Yahoo!' do + yahoo = TermExtraction::Yahoo.new(:context => 'the context') + uri = Addressable::URI.parse('http://query.yahooapis.com/v1/public/yql') + uri.query_values = { + 'q' => "select * from search.termextract where context=\"the context\"" + } + assert_equal uri.to_s, yahoo.uri.to_s + end + should 'be able to set the context after initialization' do yahoo = TermExtraction::Yahoo.new context = 'foo' yahoo.context = context - assert_equal yahoo.context, context + assert_equal context, yahoo.context end should 'be able to set the api key after initialization' do zemanta = TermExtraction::Zemanta.new context = 'bar' zemanta.context = context - assert_equal zemanta.context, context + assert_equal context, zemanta.context end should 'return different response on subsequent calls when different data is returned from Yahoo!' do yahoo = TermExtraction::Yahoo.new fake_uri(:get, yahoo.uri, 'yahoo.xml') @@ -57,6 +67,6 @@ end def correct_zemanta_terms ['Apple', 'IMac', 'Rumor', 'Hardware', 'Nvidia', 'Macintosh', 'Desktops', 'AllInOne'] end -end \ No newline at end of file +end