{"id":15240458,"url":"https://github.com/neoeno/rspec-isolate","last_synced_at":"2025-04-10T13:42:58.232Z","repository":{"id":56892892,"uuid":"138520080","full_name":"neoeno/rspec-isolate","owner":"neoeno","description":" Enforce isolation in your unit tests.","archived":false,"fork":false,"pushed_at":"2018-06-27T10:07:11.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T12:21:46.716Z","etag":null,"topics":["rspec","testing"],"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/neoeno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-24T22:35:39.000Z","updated_at":"2021-02-26T19:17:32.000Z","dependencies_parsed_at":"2022-08-20T16:10:34.614Z","dependency_job_id":null,"html_url":"https://github.com/neoeno/rspec-isolate","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/neoeno%2Frspec-isolate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoeno%2Frspec-isolate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoeno%2Frspec-isolate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoeno%2Frspec-isolate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neoeno","download_url":"https://codeload.github.com/neoeno/rspec-isolate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247749963,"owners_count":20989714,"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":["rspec","testing"],"created_at":"2024-09-29T11:05:03.269Z","updated_at":"2025-04-10T13:42:58.206Z","avatar_url":"https://github.com/neoeno.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSpec Isolate\n\nEnforce isolation in your unit tests.\n\nWhen asked, it will block access to collaborator classes, making your tests fail until you mock out the dependencies.\n\nThis is a learning and feedback tool. Use it to help you achieve isolation in your unit tests, but don't rely on it for anything heavy.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rspec-isolate'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\n## Usage\n\nRequire `rspec/isolate` in your `spec_helper.rb` as below.\n\n```ruby\n# spec_helper.rb\nrequire 'rspec/isolate'\n```\n\nAdd a tag to your describe block as below.\n\n```ruby\nRSpec.describe ClassUnderTest, error_on_call: [ CollaboratorClassOne, CollaboratorClassTwo ] do\n  # Calling any method on `CollaboratorClassOne` and `CollaboratorClassTwo` in\n  # the course of this test suite will raise an error.\nend\n```\n\nOr, if you prefer warnings to errors.\n\n```ruby\nRSpec.describe ClassUnderTest, warn_on_call: [ CollaboratorClassOne, CollaboratorClassTwo ] do\n  # Calling any method on `CollaboratorClassOne` and `CollaboratorClassTwo` in\n  # the course of this test suite will present a warning.\nend\n```\n\nA fuller example follows.\n\n```ruby\n# lib/statement_formatter.rb\nclass StatementFormatter\n  HEADER = \"Date | Amount\"\n\n  def initialize\n    @transaction_formatter = TransactionFormatter.new\n  end\n\n  def format(transactions)\n    HEADER + \"\\n\" + format_transactions(transactions)\n  end\n\n  private\n\n  def format_transactions\n    transactions.map do |transaction|\n      @transaction_formatter.format(transaction)\n    end.join(\"\\n\")\n  end\nend\n\n# lib/transaction_formatter.rb\nclass TransactionFormatter\n  def format\n    \"#{transaction[:date]} | #{transaction[:amount]}\"\n  end\nend\n\n# spec/statement_formatter.rb\n\nRSpec.describe StatementFormatter, error_on_call: [ TransactionFormatter ] do\n  describe \"#format\" do\n\n    # This will fail, as `StatementFormatter` will call `TransactionFormatter`\n    it \"formats a statement\" do\n      statement_formatter = StatementFormatter.new\n      formatted = statement_formatter.format([\n        {date: \"01/01/70\", amount: 400},\n        {date: \"02/01/70\", amount: -200}\n      ])\n      expect(formatted).to eq(\n        \"Date | Amount\\n\" \\\n        \"01/01/70 | 400\\n\" \\\n        \"02/01/70 | -200\" \\\n      )\n    end\n  end\nend\n```\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## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/neoeno/rspec-isolate. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `rspec-isolate` project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec-isolate/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoeno%2Frspec-isolate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneoeno%2Frspec-isolate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoeno%2Frspec-isolate/lists"}