Skip to content

Instantly share code, notes, and snippets.

@gongo
Created April 30, 2013 09:00
Show Gist options
  • Save gongo/5487518 to your computer and use it in GitHub Desktop.
Save gongo/5487518 to your computer and use it in GitHub Desktop.
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