Use select2 for order cycle selection

This commit is contained in:
Rohan Mitchell
2015-12-11 07:38:53 +11:00
parent 60e971ad63
commit 76d4fbccf9
5 changed files with 55 additions and 13 deletions

View File

@@ -28,15 +28,43 @@ RSpec::Matchers.define :have_select2 do |id, options={}|
end
failure_message_for_should do |actual|
message = "expected to find select2 ##{@id}"
message = "expected to find select2 ##{@id}"
message += " with #{@options.inspect}" if @options.any?
message
end
match_for_should_not do |node|
raise "Not yet implemented"
@id, @options, @node = id, options, node
#id = find_label_by_text(locator)
from = "#s2id_#{id}"
results = []
results << node.has_no_selector?(from, wait: 1)
# if results.all?
# results << selected_option_is(from, options[:selected]) if options.key? :selected
# end
if results.none?
results << all_options_absent(from, options[:with_options]) if options.key? :with_options
#results << exact_options_present(from, options[:options]) if options.key? :options
#results << no_options_present(from, options[:without_options]) if options.key? :without_options
end
if (options.keys & %i(selected options without_options)).any?
raise "Not yet implemented"
end
results.any?
end
failure_message_for_should_not do |actual|
message = "expected not to find select2 ##{@id}"
message += " with #{@options.inspect}" if @options.any?
message
end
def all_options_present(from, options)
with_select2_open(from) do
@@ -46,6 +74,14 @@ RSpec::Matchers.define :have_select2 do |id, options={}|
end
end
def all_options_absent(from, options)
with_select2_open(from) do
options.all? do |option|
@node.has_no_selector? "div.select2-drop-active ul.select2-results li", text: option
end
end
end
def exact_options_present(from, options)
with_select2_open(from) do
@node.all("div.select2-drop-active ul.select2-results li").map(&:text) == options