Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the support for matching html and body #75

Merged
merged 1 commit into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rspec-html-matchers/have_tag.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/document.html
@@ -0,0 +1,5 @@
<html>
<body>
test
</body>
</html>
12 changes: 12 additions & 0 deletions spec/have_tag_spec.rb
Expand Up @@ -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')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand, the ArgumentError is telling me to add additional options. and it works, I have added with: {...}
but your spec don't have any ?!?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good point, that's because this code is not fully relevant (as original author was proposing restoring functionality), it was consumed and changed, recent version contains this part changed a bit

end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest adding examples for .to_not have_tag(...), without them it may be easy to introduce same bug in future again.

end
end
10 changes: 0 additions & 10 deletions spec/issues_spec.rb
Expand Up @@ -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('<p>My paragraph.</p>').not_to have_tag('html')
end

it 'should not have body tag' do
expect('<p>My paragraph.</p>').not_to have_tag('body')
end
end

it '#73' do # https://github.com/kucaahbe/rspec-html-matchers/issues/73
rendered = <<HTML
<p>
Expand Down