diff --git a/lib/rspec-html-matchers/have_tag.rb b/lib/rspec-html-matchers/have_tag.rb index 1eb0d58..476cfb4 100644 --- a/lib/rspec-html-matchers/have_tag.rb +++ b/lib/rspec-html-matchers/have_tag.rb @@ -79,7 +79,7 @@ def matches? src, &block case src when String - parent_scope = Nokogiri::HTML::DocumentFragment.parse(src) + parent_scope = Nokogiri::HTML(src) @document = src else parent_scope = src.current_scope diff --git a/spec/fixtures/document.html b/spec/fixtures/document.html new file mode 100644 index 0000000..d1759c4 --- /dev/null +++ b/spec/fixtures/document.html @@ -0,0 +1,5 @@ + + + test + + diff --git a/spec/have_tag_spec.rb b/spec/have_tag_spec.rb index a87517c..2f4eac9 100644 --- a/spec/have_tag_spec.rb +++ b/spec/have_tag_spec.rb @@ -669,4 +669,16 @@ end end end + + context 'html and body elements' do + asset 'document' + + it 'should find the html element' do + expect(rendered).to have_tag('html') + end + + it 'should find the body element' do + expect(rendered).to have_tag('body') + end + end end diff --git a/spec/issues_spec.rb b/spec/issues_spec.rb index f55a7c9..90cc3b5 100644 --- a/spec/issues_spec.rb +++ b/spec/issues_spec.rb @@ -4,16 +4,6 @@ require 'spec_helper' describe 'working on github issues' do - describe '#62' do # https://github.com/kucaahbe/rspec-html-matchers/issues/62 - it 'should not have html tag' do - expect('

My paragraph.

').not_to have_tag('html') - end - - it 'should not have body tag' do - expect('

My paragraph.

').not_to have_tag('body') - end - end - it '#73' do # https://github.com/kucaahbe/rspec-html-matchers/issues/73 rendered = <