{"id":14969351,"url":"https://github.com/hirurg103/capybara_select2","last_synced_at":"2025-04-08T03:16:57.834Z","repository":{"id":62555104,"uuid":"104745455","full_name":"Hirurg103/capybara_select2","owner":"Hirurg103","description":"Capybara helpers for https://select2.org select box (supports Select2 version 2/3/4)","archived":false,"fork":false,"pushed_at":"2023-04-04T17:07:46.000Z","size":114,"stargazers_count":49,"open_issues_count":1,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T03:16:51.598Z","etag":null,"topics":["cucumber","minitest","rspec","select2","select2-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hirurg103.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-25T12:12:51.000Z","updated_at":"2023-12-28T10:22:05.000Z","dependencies_parsed_at":"2024-06-18T18:36:40.949Z","dependency_job_id":"6668d3ac-a8d8-42d4-8589-426a45949ac4","html_url":"https://github.com/Hirurg103/capybara_select2","commit_stats":{"total_commits":166,"total_committers":10,"mean_commits":16.6,"dds":0.09036144578313254,"last_synced_commit":"05900496eb766e1383f7dacb8f674d01d51f94c6"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hirurg103%2Fcapybara_select2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hirurg103%2Fcapybara_select2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hirurg103%2Fcapybara_select2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hirurg103%2Fcapybara_select2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hirurg103","download_url":"https://codeload.github.com/Hirurg103/capybara_select2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767237,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cucumber","minitest","rspec","select2","select2-rails"],"created_at":"2024-09-24T13:41:44.002Z","updated_at":"2025-04-08T03:16:57.815Z","avatar_url":"https://github.com/Hirurg103.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CapybaraSelect2 for select2 version 2/3/4\n!!! CapybaraSelect2 detects select2 version automatically\n\n[![Build Status](https://travis-ci.org/Hirurg103/capybara_select2.svg?branch=master)](https://travis-ci.org/Hirurg103/capybara_select2)\n[![Maintainability](https://api.codeclimate.com/v1/badges/28e692c7efa07aadbe98/maintainability)](https://codeclimate.com/github/Hirurg103/capybara_select2/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/28e692c7efa07aadbe98/test_coverage)](https://codeclimate.com/github/Hirurg103/capybara_select2/test_coverage)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'capybara-select-2'\nend\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it with `gem install` command:\n\n    $ gem install capybara-select-2\n\n## Configuration\n\n### Minitest\n\n```ruby\n# application_system_test_case.rb\nclass ApplicationSystemTestCase \u003c ActionDispatch::SystemTestCase\n  include CapybaraSelect2\n  include CapybaraSelect2::Helpers # if need specific helpers\nend\n```\n\n### Rspec\n\n```ruby\n# spec_helper.rb\nRSpec.configure do |config|\n  config.include CapybaraSelect2\n  config.include CapybaraSelect2::Helpers # if need specific helpers\nend\n```\n[Note] In RSpec tests `select2` helper is available out of the box\n\n### Cucumber\n\n```ruby\n# env.rb\nWorld CapybaraSelect2\nWorld CapybaraSelect2::Helpers # if need specific helpers\n```\n\n## Usage\n\n### Examples\n\n```ruby\nselect2 'Buy Milk', from: 'Todo'\nselect2 'Buy Milk', css: '#todo'\nselect2 'Buy Milk', xpath: '//div[@id=\"todo\"]'\n```\n\n#### Selecting two or more options\n\n```ruby\nselect2 'Buy Milk', 'Go to gym', from: 'Todo'\n```\n\n#### Searching\n\n```ruby\nselect2 'Buy Milk', from: 'Todo', search: true\n```\n\n#### Searching by text different than an option text\n\n```ruby\nselect2 'Buy Milk', from: 'Todo', search: 'Buy'\n```\n\n#### Tagging\n\n```ruby\nselect2 'Go to gym', from: 'Todo', tag: true\n```\n\n#### Resolving ambiguous match\n\n```ruby\n# Select the first matching option if there are two or more options with text 'Buy'\nselect2 'Buy', from: 'Todo', match: :first\n```\n\n#### Selecting an option by exact text\n\n```ruby\n# Select 'Eat' if there are two or more options with text 'Eat' ('Eat', 'Eat salad')\nselect2 'Eat', from: 'Todo', exact_text: true\n```\n\n[Note] CSS and XPath selectors must identify an HTML node that wraps select2 element or a select2 element itself (an HTML element with the `.select2-container` class)\n\n### Options\n\nOption | Purpose\n:------|:-------\n`css` | Identify select2 element by a CSS selector\n`xpath` | Identify select2 element by an XPath selector\n`from` | Identify select2 element by a label\n`label` | Identify select2 element by a label\n`search` | Search for an option by the passed string. Search by an option text if `true` is passed\n`tag` | Create an option\n`match` | Specifies Capybara's [matching strategy](https://github.com/teamcapybara/capybara#strategy) when selecting an option\n`exact_text` | Whether an option text must match exactly\n\n### Helpers\n\nSpecific select2 helpers that allow more refined access to a select2 control\n\n```ruby\nselect2_open label: 'Todo'\nselect2_close\nselect2_search 'Milk', css: '#todo'\nselect2_select 'Buy Milk', from: 'Todo'\nselect2_clear xpath: \"//div[@id='todo']\"\n```\n\nHelper | Purpose | Options\n:------|:--------|:-------\n`select2_open(options)` | Open select2 control | `label`, `css`, `xpath`\n`select2_close` | Close select2 control | -\n`select2_search(term, options)` | Type into a select2 search field | `label`, `from`, `css`, `xpath`\n`select2_select(value, options)` | Select an option from an opened select2 control | `label`, `from`, `css`, `xpath`, `match`, `exact_text`\n`select2_clear(options)` | Remove selected options (for multi select only) | `label`, `from`, `css`, `xpath`\n\nSee description for each option in the [Options](https://github.com/Hirurg103/capybara_select2#options) section\n\n[Note] Helpers above are not available in tests by default. To use them include `CapybaraSelect2::Helpers` in your test invironment (see [Configuration section](https://github.com/Hirurg103/capybara_select2#configuration))\n\n### RSpec matchers\n\n```ruby\n# Check that a select2 option with specified text is present on the page\nexpect(page).to have_select2_option 'Buy Milk'\n```\n\n## Testing\n\n### See test examples\n\nTo see test examples for a specific select2 version, start Sinatra app first:\n\n```bash\n$ rackup spec/support/select2_examples/config.ru\n```\n\nVisit http://localhost:9292/select2/v4.0.5/examples in your browser to see examples for select2 version `4.0.5`\n\n### Running tests\n\n```bash\n# run spec cases for all select2 versions\n$ bundle exec rspec\n\n# run spec cases for a specific select2 version\n$ SELECT2_VERSION=4.0.5 bundle exec rspec spec/shared\n```\n\n## Contributing\n\n1. Add a test case which covers the bug\n2. Add code which makes the test green\n3. Open pull request\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirurg103%2Fcapybara_select2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirurg103%2Fcapybara_select2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirurg103%2Fcapybara_select2/lists"}