require "test/unit" require File.dirname(__FILE__) + "/../lib/parsley" class TestParsley < Test::Unit::TestCase def setup @page = File.expand_path(File.dirname(__FILE__) + "/yelp.html") @home = File.expand_path(File.dirname(__FILE__) + "/yelp-home.html") @let = File.expand_path(File.dirname(__FILE__) + "/yelp-home.let") end def test_yelp @parsley = Parsley.new(File.read(@let)) out = @parsley.parse(:file => @home) assert_equal "/c/sf/shopping", out["categories"][0]["href"] end def test_yelp_xml @parsley = Parsley.new(File.read(@let)) out = @parsley.parse(:file => @home, :output => :xml) end def test_broken @parsley = Parsley.new("hi" => "no-ns:match(h1)") assert_raises(ParsleyError) { @parsley.parse(:file => @page) } end def test_simple @parsley = Parsley.new("hi" => "h1") assert_equal({"hi" => "Nick's Crispy Tacos"}, @parsley.parse(:file => @page)) end def test_simple_string @parsley = Parsley.new("hi" => "h1") assert_equal({"hi" => "Nick's Crispy Tacos"}, @parsley.parse(:string => "