Skip to content

Instantly share code, notes, and snippets.

@robcolburn
Last active September 4, 2018 15:25
Show Gist options
  • Save robcolburn/e0a589cef44e6bcf7448663b2ff4531a to your computer and use it in GitHub Desktop.
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.
Then the page should display either
| Cat |
| Dog |
| Mouse |
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