diff --git a/gem/capybara-select2.gemspec b/gem/capybara-select2.gemspec index 3ab717d..f2efda0 100644 --- a/gem/capybara-select2.gemspec +++ b/gem/capybara-select2.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - - gem.add_dependency 'rspec' + + gem.add_development_dependency 'rspec' gem.add_dependency 'capybara' end diff --git a/gem/lib/capybara-select2.rb b/gem/lib/capybara-select2.rb index 64f025d..30b7dec 100644 --- a/gem/lib/capybara-select2.rb +++ b/gem/lib/capybara-select2.rb @@ -15,7 +15,7 @@ def select2(value, options = {}) select2_container = first("label", text: select_name).find(:xpath, '..').find(".select2-container") end - select2_container.find(".select2-choice").click + select2_container.find(".select2-choice").trigger('click') if options.has_key? :search find(:xpath, "//body").find("input.select2-input").set(value) @@ -27,7 +27,7 @@ def select2(value, options = {}) [value].flatten.each do |value| select2_container.find(:xpath, "a[contains(concat(' ',normalize-space(@class),' '),' select2-choice ')] | ul[contains(concat(' ',normalize-space(@class),' '),' select2-choices ')]").click - find(:xpath, "//body").find("#{drop_container} li", text: value).click + find(:xpath, "//body").find("#{drop_container} li.select2-result-selectable", text: value).click end end end