require "helper" require "minitest/autorun" class TestVoyagerConnection < MiniTest::Unit::TestCase def test_creates_cookies cookie_dir = File.join(File.dirname(__FILE__), "tmp", "cookies") cookie_file = File.join(cookie_dir, "cookies.dat") FileUtils.rm_rf(File.dirname(cookie_dir)) cookie_manager = mock cookie_manager.expects(:save_all_cookies).with(true) hc = HTTPClient.new hc.expects(:set_cookie_store).with(cookie_file) hc.expects(:get_content).with("http://www.google.com",{}) hc.expects(:cookie_manager).returns(cookie_manager) vc = Voyager::Connection.new(:http_client => hc, :cookie_path => cookie_file) vc.request("http://www.google.com") assert File.exists?(cookie_dir) FileUtils.rm_rf(File.dirname(cookie_dir)) end end