Skip to content

Helper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)

License

Notifications You must be signed in to change notification settings

cultureamp/capybara-select2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Capybara::Select2

Culture Amp fork maintained by @sentience. We’d prefer to contribute our changes back into the original source, but it seems unmaintained as of November 24, 2016.

Code Climate

All this gem does is something very simple- allow you to trigger select2 dropdown to select the value you want. The original select doesn't with the javascript overrides, so this new helper method does only this thing.

Installation

Add this line to your application's Gemfile:

gem 'capybara-select2', group: :test

Or, add it into your test group

group :test do
  gem 'capybara-select2'
  ...
end

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara-select2

The gem automatically hook itself into rspec helper using Rspec.configure.

If you're using capybara outside of Rspec, you may have to include the following (eg: in features/support/env.rb for Cucumber users):

include Capybara::Select2

Usage

Just use this method inside your capybara test:

select2("Dropdown Text", from: "Label of the dropdown")

or

select2("Dropdown Text", xpath: "<xpath of the dropdown>")

If the select2 field has a min_length option (acts as a search field) specify it with:

select2("foo", from: "Label of the dropdown", search: true)

If select2 field has tags option you can use:

select2_tag('value', from: 'Label of input')

About

Helper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%