{"id":17256997,"url":"https://github.com/waterlink/contracts-rspec","last_synced_at":"2025-04-14T06:10:47.041Z","repository":{"id":30134015,"uuid":"33684074","full_name":"waterlink/contracts-rspec","owner":"waterlink","description":"Plugin for contracts.ruby that fixes issues with rspec-mocks.","archived":false,"fork":false,"pushed_at":"2015-04-09T18:14:54.000Z","size":124,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T04:41:26.939Z","etag":null,"topics":[],"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/waterlink.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":"2015-04-09T17:59:53.000Z","updated_at":"2017-08-10T15:16:32.000Z","dependencies_parsed_at":"2022-08-17T18:35:11.847Z","dependency_job_id":null,"html_url":"https://github.com/waterlink/contracts-rspec","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waterlink%2Fcontracts-rspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waterlink%2Fcontracts-rspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waterlink%2Fcontracts-rspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waterlink%2Fcontracts-rspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waterlink","download_url":"https://codeload.github.com/waterlink/contracts-rspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830395,"owners_count":21168272,"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":[],"created_at":"2024-10-15T07:16:05.651Z","updated_at":"2025-04-14T06:10:47.004Z","avatar_url":"https://github.com/waterlink.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contracts::Rspec\n\nPlugin for [contracts.ruby](https://github.com/egonSchiele/contracts.ruby/) that fixes issues with rspec-mocks.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'contracts-rspec'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install contracts-rspec\n\n## Usage\n\nJust `require 'contracts/rspec'` and `include Contracts::RSpec::Mocks` into your example group and you will be able to use enhanced `instance_double`:\n\n```ruby\nrequire 'contracts'\nrequire 'contracts/rspec'\n\nclass Example\n  include Contracts\n\n  Contract Something =\u003e Any\n  def do_something(something)\n    something.call\n  end\nend\n\nRSpec.describe Example do\n  # If you not include this, you will get ContractError, telling you\n  # that `RSpec::Mocks::InstanceVerifyingDouble` is not a `Something`.\n  include Contracts::RSpec::Mocks\n\n  subject(:example) { Example.new }\n  let(:something) { instance_double(Something) }\n\n  it \"works\" do\n    expect { example.do_something(something) }.not_to raise_error\n  end\nend\n```\n\n## How it works\n\nWhen you `include Contracts::RSpec::Mocks`, you basically make your `instance_double` calls additionally stub out `:is_a?` message, when received with specified class to return true. Which makes contract succeed.\n\nYou can do it yourself simply:\n\n```ruby\nsomething = instance_double(Something)\nallow(something).to receive(:is_a?).with(Something).and_return(true)\n```\n\nThis library only provides a shortcut.\n\n## Contributing\n\n1. Fork it ( https://github.com/waterlink/contracts-rspec/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaterlink%2Fcontracts-rspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaterlink%2Fcontracts-rspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaterlink%2Fcontracts-rspec/lists"}