Last active
September 4, 2018 15:25
-
-
Save robcolburn/e0a589cef44e6bcf7448663b2ff4531a to your computer and use it in GitHub Desktop.
Needed an "or" clause in cucumber to check either condition. Gripes: It's terse, but I don't love that it doesn't follow normal Matcher pattern, and that error string is built when we don't need it.
This file contains hidden or 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
Then the page should display either | |
| Cat | | |
| Dog | | |
| Mouse | |
This file contains hidden or 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
Then /^the page should display either$/ do |table| | |
expect_to_have_content_any_of page, table.raw.map {|row| row.first } | |
end | |
def expect_to_have_content_any_of(element, options) | |
fail ArgumentError, "expected to find any of (\"#{options * '" or "'}\") in \"#{element.text}\"" unless | |
options.any? { |option| element.has_content? option} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment