{"id":20081924,"url":"https://github.com/eval/respectable","last_synced_at":"2025-03-02T13:41:43.466Z","repository":{"id":66250916,"uuid":"86565584","full_name":"eval/respectable","owner":"eval","description":"Test different inputs against an rspec-expectation (mirror)","archived":false,"fork":false,"pushed_at":"2017-03-29T09:53:30.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T01:44:30.034Z","etag":null,"topics":["rails","rspec","ruby","testing"],"latest_commit_sha":null,"homepage":"https://gitlab.com/eval/respectable/tree/master#respectable","language":"Ruby","has_issues":false,"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/eval.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-03-29T09:50:04.000Z","updated_at":"2017-10-24T15:01:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba576460-b8c3-44c5-93fd-a6f0843f3a1f","html_url":"https://github.com/eval/respectable","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Frespectable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Frespectable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Frespectable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Frespectable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eval","download_url":"https://codeload.github.com/eval/respectable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241515953,"owners_count":19975140,"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":["rails","rspec","ruby","testing"],"created_at":"2024-11-13T15:40:55.987Z","updated_at":"2025-03-02T13:41:43.443Z","avatar_url":"https://github.com/eval.png","language":"Ruby","readme":"# Respectable\n\n[![build status](https://gitlab.com/eval/respectable/badges/master/build.svg)](https://gitlab.com/eval/respectable/commits/master)\n\nRespectable allows you to structure your specs similar to [scenario outlines in Cucumber](https://github.com/cucumber/cucumber/wiki/Scenario-outlines).\n\n![](logo.jpg)\n\nSo instead of:\n\n```ruby\ndescribe '#full_name' do\n  it 'concats first and last' do\n    expect(User.new(first: 'Foo', last: 'Bar').full_name).to eq 'Foo Bar'\n  end\n\n  it 'does smart casing stuff' do\n    expect(User.new(first: 'Foo', last: 'Van Bar').full_name).to eq 'Foo van Bar'\n  end\n\n  it 'handles last being nil' do\n    expect(User.new(first: 'First', last: nil).full_name).to eq 'Foo'\n  end\n\n  it 'handles first being nil' do\n    expect(User.new(first: nil, last: 'Bar').full_name).to eq 'Bar'\n  end\nend\n```\n\n...you throw a bunch of cases at an expectation:\n\n```ruby\ndescribe '#full_name' do\n  specify_each(\u003c\u003c-TABLE) do |first, last, expected|\n    #| first | last    | expected    |\n     | Foo   | Bar     | Foo Bar     |\n     | Foo   | Van Bar | Foo van Bar |\n     | Foo   | `nil`   | Foo         |\n     | `nil` | Bar     | Bar         |\n    TABLE\n\n    expect(User.new(first: first, last: last).full_name).to eq expected\n  end\nend\n```\n\nYou just got yourself a *table* in your *rspec*! (who told you naming was hard?)\n\n## Details\n\n### Literal values\n\nBy default values from the table are passed to the block as stripped strings. For more expressiveness you can use backticks; this allows you to pass literal values (e.g. \\`nil\\`, \\`:some_symbol\\`, \\`true\\`, \\`1 + 1\\`) to the block.\n\n### Description\n\nFor every row in the table an it-block is created. The description of this block will be of the format:  \n`column1-name: \"cell-value\", column2-name: \"cell-value\" yields \"value of last column\"`.  \nSo for the full_name-example above the full RSpec-output (using `--format documentation`) is:  \n```\n#full_name\n  first: \"Foo\", last: \"Bar\" yields \"Foo Bar\"\n  first: \"Foo\", last: \"Van Bar\" yields \"Foo van Bar\"\n  first: \"Foo\", last: \"`nil`\" yields \"Foo\"\n  first: \"`nil`\", last: \"Bar\" yields \"Bar\"\n```\n\nYou can customize the description by passing a template to `specify_each` in which you can use the block parameters, e.g.:  \n```ruby\nspecify_each(\u003c\u003c-TABLE, desc: 'full_name(%{first}, %{last}) =\u003e %{expected}') do |first, last, expected|\n```\n\nIf you want the standard RSpec-description you can pass `desc: nil` to `specify_each`.\n\n### Comments\n\nJust like in Ruby, you can comment (the remainder of) a line by using `#`. This helps to document the table:  \n```ruby\nspecify_each(\u003c\u003c-TABLE) do |arg1, arg2, result|\n  # | arg1 (never negative) | arg2 | +  |\n    | 1                     |   2  | 3  |\n    | 10                    |   2  | 12 | # \u003c= important edge-case\nTABLE\n  expect(...)\nend\n```\n\n### Various\n\nYou can escape the pipe character (`|`) by prefixing it with `\\\\`:\n```\n| This table has one cell with a \\\\| |\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'respectable', require: false\nend\n```\n\nThen in `rails_helper.rb` or `spec_helper.rb`:\n\n```\nrequire 'respectable'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install respectable\n\n## Usage\n\nCheckout the [specs](spec/respectable_spec.rb).\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feval%2Frespectable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feval%2Frespectable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feval%2Frespectable/lists"}