Sha256: 7928a2ee86f7ea8ad161d4f7e3a8505a7a4cf09cecf1b4df9724b0f136be417c
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
require 'test_helper' require 'webmock/minitest' module Wovnrb class ReplacerBaseTest < WovnMiniTest def test_replace replacer = LinkReplacer.new('query', get_header) dom = Wovnrb.get_dom('<a href="/index.html">link text</a>') replacer.replace(dom, Lang.new('en')) link = dom.xpath('//a')[0].get_attribute('href') assert_equal('/index.html?wovn=en', link) end def test_replace_multiple replacer = LinkReplacer.new('query', get_header) dom = Wovnrb.get_dom('<a href="/index.html">link text</a><div>aaa</div><a href="/index2.html">link text</a>') replacer.replace(dom, Lang.new('en')) link = dom.xpath('//a')[0].get_attribute('href') link2 = dom.xpath('//a')[1].get_attribute('href') assert_equal('/index.html?wovn=en', link) assert_equal('/index2.html?wovn=en', link2) end def test_replace_ignore replacer = LinkReplacer.new('query', get_header) dom = Wovnrb.get_dom('<a wovn-ignore href="/index.html">link text</a>') replacer.replace(dom, Lang.new('en')) link = dom.xpath('//a')[0].get_attribute('href') assert_equal('/index.html', link) end def test_replace_mustache replacer = LinkReplacer.new('query', get_header) dom = Wovnrb.get_dom('<a href="{{hello}}">link text</a>') replacer.replace(dom, Lang.new('en')) link = dom.xpath('//a')[0].get_attribute('href') assert_equal('{{hello}}', link) dom = Wovnrb.get_dom('<a href=" {{hello}} ">link text</a>') replacer.replace(dom, Lang.new('en')) link = dom.xpath('//a')[0].get_attribute('href') assert_equal(' {{hello}} ', link) end def get_header h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://favy.tips'), Wovnrb.get_settings('url_pattern' => 'query', 'url_pattern_reg' => '^(?<lang>[^.]+).')) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wovnrb-0.2.13 | test/lib/html_replacers/link_replacer_test.rb |
wovnrb-0.2.12 | test/lib/html_replacers/link_replacer_test.rb |
wovnrb-0.2.11 | test/lib/html_replacers/link_replacer_test.rb |