{"id":31714256,"url":"https://github.com/vshaveyko/pickles","last_synced_at":"2026-03-02T04:03:34.024Z","repository":{"id":56888033,"uuid":"99712890","full_name":"vshaveyko/pickles","owner":"vshaveyko","description":"Set of capybara helpers and predefined cucumber steps","archived":false,"fork":false,"pushed_at":"2017-11-16T19:58:45.000Z","size":103,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-01T13:39:12.930Z","etag":null,"topics":["capybara","cucumber","helpers","steps"],"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/vshaveyko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-08T16:19:13.000Z","updated_at":"2018-01-26T09:51:52.000Z","dependencies_parsed_at":"2022-08-20T15:20:49.364Z","dependency_job_id":null,"html_url":"https://github.com/vshaveyko/pickles","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/vshaveyko/pickles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshaveyko%2Fpickles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshaveyko%2Fpickles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshaveyko%2Fpickles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshaveyko%2Fpickles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vshaveyko","download_url":"https://codeload.github.com/vshaveyko/pickles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshaveyko%2Fpickles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877088,"owners_count":26061380,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["capybara","cucumber","helpers","steps"],"created_at":"2025-10-09T01:17:10.724Z","updated_at":"2025-10-09T01:17:13.989Z","avatar_url":"https://github.com/vshaveyko.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pickles\n\u003cdetails\u003e\n  \u003csummary\u003e Available steps summary \u003c/summary\u003e\n\n  ```rb\n   When I click \"My button\" \n   When I click \"=Mo\" \n   When I click \"\u003eMo\" \n   When I navigate:\n     | click | My button   |\n     | hover | My span     |\n\n   When I fill in the following:\n     | User data       | Sex         (select) | Male       |\n     |                 | Avatar               | avatar.png |\n\n   When I attach the file \"test.png\" to \"Avatar\" within \"User data\"\n   When I fill \"Name\" with \"Peter\" within \"User data\" \n   When I fill \"Avatar\" with \"test.png\" within \"User data\" \n\n   Then fields are filled with:\n     | Account Number       | 5002       |\n     | Expiry date          | 2009-11-01 |\n\n   Then I can see:\n     | form                       | Sarah |\n     | menu_item \"profile change\" | admin |\n\n   Then I can see video \"cool_stuff\"\n   Then I cannot see image \"test.png\"\n   Then focus is on \"Sample\"\n   Then focus is on form_field \"Fill user data\"\n   ```\n\n\u003c/details\u003e\n\nThis gem contains some helpers to simplify testing with capybara along with afew predefined cucumber steps.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pickles', require: false\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install pickles\n\n```rb\nrequire 'cucumber/pickles/helpers' # require only helpers without steps\n# or\nrequire 'cucumber/pickles' # require everything alltogether\n```\n\n## Configure\n\n```rb\nPickles.configure do |c|\n\n  #\n  # Usually referring to elements on page as .some-css-class is a bad practice.\n  #\n  # You can provide a map with aliases pointing to that stuff in this config \n  #   Ex: c.css_node_map = { some_block: '.some-css-class' }\n  #\n  # And refer to it across within blocks in every predefined step or by manually using detect_node_helper\n  # \n  c.css_node_map = {} \n  # Same as above but shouled be aliased to xpath selector\n  c.xpath_node_map = {} \n\n  #\n  # Log xhr error response to browser console, \n  # \n  # You can configure capybara to log this to your console: ( For example if example failed )\n  #\n  # puts page.driver.browser.manage.logs.get('browser').select { |log| log.level == 'SEVERE' }.map(\u0026:message).map(\u0026:red)\n  #\n  c.log_xhr_response = false \n  \n  # \n  # In some table steps you can provide '(...)' identifier to override how that step should be handled\n  # \n  # See 'I fill in the following:' for explaination\n  #\n  c.fill_tag_steps_map = { 'select' =\u003e Select }\n\n  #\n  # Same as above for 'fields are filled with:' step\n  #\n  c.check_tag_steps_map = { 'text' =\u003e Text }\n\nend\n```\n\n### Capybara test helpers\n\nBunch of usefull helpers for everyday testing with capybara.\n\nMostly usefull if you're building a SPA app or just have tons of javascript and standard Capybara helper methods isnt enough.\n\n#### Start with:\n If you're using cucumber you may want to:\n ```rb\n World(Pickles)\n ```\n\n Or you can use it through:\n ```rb\n Pickles.helper_name\n ```\n\n### Index:\n\n1. [wait_for_ajax](#wait_for_ajax)\n2. [Locator string](#locator-string-text2)\n3. [find_node](#find_nodelocator-within-nil)\n4. [detect_node](#detect_nodeel_alias-locator--nil-within-nil)\n5. [find_input](#find_inputlocator-within-nil)\n6. [blur](#blurnode)\n7. [select_input](#select_inputinput-value--nil)\n8. [attach_file](#attach_fileinput-file_name)\n\n+ ####  Locator string: `Ex: \"=Text[2]\"`:\n  + 'Text' - required - text to look up by\n  + '='    - optional - lookup exact text in node if given\n  + '[2]'  - optional - index of element on page. If found 4 elements than 3rd will be selected - indexed from 0. \n\n+ #### find_node(locator, within: nil)\n  \n  Find node on page by [Locator string](#locator-string-text2)\n\n  within - capybara node to limit lookup\n\n  returns: capybara node\n\n+ #### find_input(locator, within: nil)\n\n  Find `input | textarea | [contenteditable]` on page identified by [Locator string](#locator-string-text2)\n\n+ #### detect_node(el_alias, locator = nil, within: nil)\n\n  Does lookup based on provided in config maps\n\n  if within.present? =\u003e limit search to within\n  if locator.present? =\u003e use locator in step location\n\n  Use el_alias to find needed xpath / css in maps provided to config.\n  Priority xpath_map =\u003e css_map =\u003e el_alias as it is\n\n  locator and el_alias can use index configuration from [Locator string](#locator-string-text2)\n\n+ #### wait_for_ajax\n  \n  Waits for ajax requests to end before proceeding further.\n  Terminated with `Capybara::ElementNotFound` after `Capybara.default_wait_time` seconds\n\n+ #### blur(node)\n  \n  Triggers *node* blur event and clicks on body to perform blur\n\n+ #### select_input(input, value = nil)\n\n  Selects *input*[type=\"checkbox\"] OR *input*[type=\"radio\"] on form\n\n  Triggers click after selection to trigger javascript events ( may change in future )\n\n+ #### attach_file(input, file_name)\n\n  Attaches file with *file_name* to *input*[type=\"file\"]\n\n  *file_name* is fetched from `features/support/attachments/*file_name*` and raises RuntimeError if file not found\n\n### Supported cucumber steps:\n\n+ Navigation \n\n  1.  `When I (?:click|navigate) \"([^\"]*)\"( within (?:.*))?`\n\n      ##### Examples:\n      ```rb\n      When I click \"My button\" # standard click by text\n\n      When I click \"=Mo\" # click node that has exact this text. i.e. ignore: Monday, Moth\n        \n      When I click \"\u003eMo\" # ajax wait requests done before clicking\n      When I click \"Mo\u003e\" # ajax wait requests done after clicking\n        \n      When I click \"\u003eMo\u003e\" # both of the above\n        \n      When I click \"My button,=Mo\" # chain clicks ( click My button then click exact Mo )\n\n      When I click \"My button-\u003e=Mo\" # same as above (-\u003e is for chaining sequential clicks)\n        \n      When I click \"My button\u003e-\u003e=Mo\u003e\" # click My button, ajax wait then click Mo\n\n      When I navigate ... # alias\n\n      ```\n\n      ##### Description:\n        + for within checkout docs\n\n  2.  `When I (?:click|navigate):( within (?:.*))?`\n\n     ##### Examples:\n     ```rb\n     When I navigate:\n       | click | My button   |\n       | hover | My span     |\n       | hover | Your span   |\n       | click | Your button |\n         \n     When I navigate: within form \"User data\"\n       | click | Submit   |\n     ```\n\n     ##### Description:\n     + Same as previous, but allows table as argument.\n     + note ` : ` in the definition\n\n+ Forms:\n  + Fill:\n     1. `When (?:|I )fill in the following:( within (?:.*))?`\n\n        ##### Examples:\n         ```rb\n         When I fill in the following:\n           |                 | Account Number       | 5002       |\n           |                 | Expiry date          | 2009-11-01 |\n           |                 | Note                 | Nice guy   |\n           |                 | Wants Email?         |            |\n           | User data       | Sex         (select) | Male       |\n           |                 | Avatar               | avatar.png |\n           |                 | Due date             | 12:35      |\n           | Additional data | Accept user agrement | true       |\n           |                 | Send me letters      | false      |\n           |                 | radio 1              | true       |\n         ```\n\n         ##### Description:\n           + Fills form fields identified by second column.\n           + First column is optional and defines 'within block' - see docs for within\n           + Add custom (...) block for second column to define your own form fill steps in `config.fill_tag_steps_map`\n             supported by default:\n               (select) - uses `When I select \"..\" with \"..\"` under the hood.\n               Ex:\n               ```rb\n               class FillDatepicker\n\n                 def initialize(label, value, within)\n                   # label = 'Date of birth'\n                   @label = label\n                   # value = '23.12.1998'\n                   @value = Date.parse(value)\n                   # within = detect_node(\"form\", \"User profile\", within: page)\n                   @within = within\n                 end\n                 \n                 def call\n                    # implement datepicker selecting logic\n                 end\n               end\n\n               Pickles.configure do |c|\n                 c.fill_tag_steps_map = { datepicker: FillDatepicker }\n               end\n\n               When I fill in the following:\n                 | form \"User profile\" | Date of birth (datepicker) | 23.12.1998 |\n               ```\n\n\n     2.  `When (?:|I )attach the file \"([^\"]*)\" to \"([^\"]*)\"( within (?:.*))?`\n\n         ##### Examples:\n           ```rb\n            When I attach the file \"test.png\" to \"Avatar\" within \"User data\"\n           ```\n\n         ##### Description:\n           + Attaches given file to identified fields\n           + Params:\n             1. `features/support/attachments/` + `file_name` is used to identify file\n             2. Input identifier. see `find_input` helper for searching details\n             3. within block identifier\n          + within part is optional\n            \n     4.  `When (?:|I )(?:fill|select)(?: \"([^\"]*)\")?(?: with \"([^\"]*)\")?( within (?:.*))?`\n\n         ##### Examples:\n           ```rb\n            When I fill \"Name\" with \"Peter\" within \"User data\" # input[type=\"text\"]\n            When I fill \"Avatar\" with \"test.png\" within \"User data\" # input[type=\"file\"]\n\n            When I fill \"Male\" within \"User data\" # input[type=\"checkbox\"] || input[type=\"radio\"]\n            When I select \"Male\" \n\n            When I select \"sex\" with \"Male\" # selector\n\n           ```\n\n         ##### Description:\n           + Tries to fill data by guessing field type from found input type(text|checkbox|radio|etc)\n           + There MUST always be an input identified by identifier\n           + within part is optional\n       \n + Check\n\n   `Then fields are filled with:( within (?:.*))?`\n\n   ##### Examples: \n     ```rb\n     Then fields are filled with:\n       | Account Number       | 5002       |\n       | Expiry date          | 2009-11-01 |\n       | Note                 | Nice guy   |\n       | Wants Email?         | true       |\n       | Sex                  | Male       |\n       | Accept user agrement | true       |\n       | Send me letters      | false      |\n       | radio 1              | true       |\n       | Avatar               | avatar.png |\n       | Due date             | 12:35      |\n     ```\n\n   ##### Description:\n     + Check fields filled by `I fill in the folllwing`\n     + Supports exact same table syntax and optional column\n\n   `Then I can(not)? see:`\n   ##### Examples: \n     ```rb\n     Then I can see:\n       | form                       | Sarah |\n       | menu_item \"profile change\" | admin |\n     ```\n   ##### Description:\n     + First column is optional for identifying within blocks\n\n   `Then I can(not)? see video (\".*?\")( within (?:.*))?`\n\n   ##### Examples: \n     ```rb\n     Then I can see video \"cool_stuff\"\n     ```\n\n   ##### Description:\n     + value is src link to the video ( i.e. youtube link )\n\n   `Then I can(not)? see image (\".*?\")( within (?:.*))?`\n\n   ##### Examples: \n     ```rb\n     Then I cannot see image \"test.png\"\n     ```\n\n   ##### Description:\n     + value is image_url ( i.e. assets/images/first.png )\n\n   `Then focus is on (.*) ?\"(.*?)\"`\n\n   ##### Examples: \n     ```rb\n     Then focus is on \"Sample\"\n     Then focus is on form_field \"Fill user data\"\n     ```\n\n   ##### Description:\n     + first matching group is optional and used from node maps ( see #detect_node )\n\n## Contributing\n\n     Bug reports and pull requests are welcome on GitHub at https://github.com/vshaveyko/pickles.\n\n\n## License\n\n     The 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%2Fvshaveyko%2Fpickles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvshaveyko%2Fpickles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshaveyko%2Fpickles/lists"}