mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adding 'selected' option to have_select2 matcher
This commit is contained in:
@@ -14,6 +14,10 @@ RSpec::Matchers.define :have_select2 do |id, options={}|
|
||||
|
||||
results << node.has_selector?(from)
|
||||
|
||||
if results.all?
|
||||
results << selected_option_is(from, options[:selected]) if options.key? :selected
|
||||
end
|
||||
|
||||
if results.all?
|
||||
results << all_options_present(from, options[:with_options]) if options.key? :with_options
|
||||
results << exact_options_present(from, options[:options]) if options.key? :options
|
||||
@@ -47,6 +51,12 @@ RSpec::Matchers.define :have_select2 do |id, options={}|
|
||||
end
|
||||
end
|
||||
|
||||
def selected_option_is(from, text)
|
||||
within find(from) do
|
||||
find("a.select2-choice").text == text
|
||||
end
|
||||
end
|
||||
|
||||
def with_select2_open(from)
|
||||
find(from).click
|
||||
r = yield
|
||||
|
||||
Reference in New Issue
Block a user