From 84c4cacca0a5b527e89245b0ec9d5bb9e514a377 Mon Sep 17 00:00:00 2001 From: Kartik Luke Singh Date: Tue, 10 May 2016 13:43:39 +0530 Subject: [PATCH] Use `match: :first` after changing first to find In #37 we changed the `first()` to `find()` but this leads to #41. This is a fix for the same. --- gem/lib/capybara-select2.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gem/lib/capybara-select2.rb b/gem/lib/capybara-select2.rb index cb6d1d2..d9cf8d1 100644 --- a/gem/lib/capybara-select2.rb +++ b/gem/lib/capybara-select2.rb @@ -8,12 +8,12 @@ def select2(value, options = {}) raise "Must pass a hash containing 'from' or 'xpath' or 'css'" unless options.is_a?(Hash) and [:from, :xpath, :css].any? { |k| options.has_key? k } if options.has_key? :xpath - select2_container = find(:xpath, options[:xpath]) + select2_container = find(:xpath, options[:xpath], match: :first) elsif options.has_key? :css - select2_container = find(:css, options[:css]) + select2_container = find(:css, options[:css], match: :first) else select_name = options[:from] - select2_container = find("label", text: select_name).find(:xpath, '..').find(".select2-container") + select2_container = find("label", text: select_name, match: :first).find(:xpath, '..').find(".select2-container") end # Open select2 field