Created
April 30, 2013 09:00
-
-
Save gongo/5487518 to your computer and use it in GitHub Desktop.
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
Capybara.add_selector(:select_inexact) do | |
label "select box (inexact finder)" | |
xpath { |locator| XPath::HTML.select(locator) } | |
filter(:options) do |node, options| | |
actual = node.all(:xpath, './/option').map { |option| option.text } | |
actual.zip(options).all? { |act, opt| Regexp.new(opt).match(act) } | |
end | |
end | |
module Capybara | |
module RSpecMatchers | |
def have_select_inexact(locator, options={}) | |
HaveSelector.new(:select_inexact, locator, options) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment