Sha256: e94f9ce316fc3910fcf14449aa310cba85d414327a9e6624009b6c0babd9e0c4
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
require_relative 'spec_helper' describe 'Yasuri' do include_context 'httpserver' before do @agent = Mechanize.new @index_page = @agent.get(uri) end describe '::MapNode' do it "multi scrape in singe page" do map = Yasuri.map_sample do text_title '/html/head/title' text_body_p '/html/body/p[1]' end actual = map.inject(@agent, @index_page) expected = { "title" => "Yasuri Test", "body_p" => "Hello,Yasuri" } expect(actual).to include expected end it "nested multi scrape in singe page" do map = Yasuri.map_sample do map_group1 { text_child01 '/html/body/a[1]' } map_group2 do text_child01 '/html/body/a[1]' text_child03 '/html/body/a[3]' end end actual = map.inject(@agent, @index_page) expected = { "group1" => { "child01" => "child01" }, "group2" => { "child01" => "child01", "child03" => "child03" } } expect(actual).to include expected end it "scrape with links node" do map = Yasuri.map_sample do map_group1 do links_a '/html/body/a' do text_content '/html/body/p' end text_child01 '/html/body/a[1]' end map_group2 do text_child03 '/html/body/a[3]' end end actual = map.inject(@agent, @index_page) expected = { "group1" => { "a" => [ {"content" => "Child 01 page."}, {"content" => "Child 02 page."}, {"content" => "Child 03 page."}, ], "child01" => "child01" }, "group2" => { "child03" => "child03" } } expect(actual).to include expected end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yasuri-3.2.0 | spec/yasuri_map_spec.rb |
yasuri-3.1.0 | spec/yasuri_map_spec.rb |