Sha256: 09318e7823b041798cd0d6fb125dd4019091f28dd2407fd1986a90baa5aa4a55

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

require 'helper'

class TestHarvestman < Test::Unit::TestCase
	def test_namespace
		assert Harvestman.is_a?(Module)
	end

	def test_scraping
		results = []

		Harvestman.crawl "test/example*.html", (1..3), :plain do
			r = {
				:title => css("head title"),
				:header => css("header div.title h1"),
				:footer => css("footer span a"),
				:list => []
			}

			css "div.main ul" do
				r[:list] << css("li")
			end

			results << r
		end

		results.each_with_index do |r, i|
			assert_equal(r[:title], "ex#{i+1}")
			assert_equal(r[:header], "#{r[:title]}_header_h1")			
			assert_equal(r[:footer], "#{r[:title]}_footer_span_a")
			assert_equal(r[:list].count, 3)
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harvestman-0.1.1 test/test_harvestman.rb