forked from adzap/validates_timeliness
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
111d9b1
commit 890381b
Showing
14 changed files
with
212 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--format nested | ||
--format documentation | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'nokogiri' | ||
|
||
module TagMatcher | ||
extend RSpec::Matchers::DSL | ||
|
||
matcher :have_tag do |selector| | ||
match do |subject| | ||
matches = doc(subject).search(selector) | ||
|
||
if @inner_text | ||
matches = matches.select { |element| element.inner_text == @inner_text } | ||
end | ||
|
||
matches.any? | ||
end | ||
|
||
chain :with_inner_text do |inner_text| | ||
@inner_text = inner_text | ||
end | ||
|
||
private | ||
|
||
def body(subject) | ||
if subject.respond_to?(:body) | ||
subject.body | ||
else | ||
subject.to_s | ||
end | ||
end | ||
|
||
def doc(subject) | ||
@doc ||= Nokogiri::HTML(body(subject)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.