{"id":18234203,"url":"https://github.com/mocktools/ruby-rspec-mock","last_synced_at":"2025-09-08T14:43:06.380Z","repository":{"id":261036024,"uuid":"882756724","full_name":"mocktools/ruby-rspec-mock","owner":"mocktools","description":"RSpec dual mocking compatibility. Use RSpec's mocks as secondary, alongside a primary, alternative mocking library.","archived":false,"fork":false,"pushed_at":"2024-11-10T20:06:52.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T06:22:18.295Z","etag":null,"topics":["developer-tools","hacktoberfest","mock","mocktools","rspec","rspec-mock","rspec-rails","rspec-testing","ruby","rubygem","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/mocktools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["bestwebua"]}},"created_at":"2024-11-03T17:20:21.000Z","updated_at":"2024-11-11T21:27:16.000Z","dependencies_parsed_at":"2025-04-03T23:31:06.578Z","dependency_job_id":"5b32fc16-0707-4da2-92e4-1c922fddad59","html_url":"https://github.com/mocktools/ruby-rspec-mock","commit_stats":null,"previous_names":["mocktools/ruby-rspec-mock"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mocktools/ruby-rspec-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fruby-rspec-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fruby-rspec-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fruby-rspec-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fruby-rspec-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mocktools","download_url":"https://codeload.github.com/mocktools/ruby-rspec-mock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fruby-rspec-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274201130,"owners_count":25240208,"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-09-08T02:00:09.813Z","response_time":121,"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":["developer-tools","hacktoberfest","mock","mocktools","rspec","rspec-mock","rspec-rails","rspec-testing","ruby","rubygem","testing"],"created_at":"2024-11-04T20:04:56.464Z","updated_at":"2025-09-08T14:43:06.069Z","avatar_url":"https://github.com/mocktools.png","language":"Ruby","funding_links":["https://github.com/sponsors/bestwebua"],"categories":["Ruby"],"sub_categories":[],"readme":"# Seamless migration from third-party mocks to RSpec built-in mocking framework\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/8a7a9ca7f590838bf02f/maintainability)](https://codeclimate.com/github/mocktools/ruby-rspec-mock/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/8a7a9ca7f590838bf02f/test_coverage)](https://codeclimate.com/github/mocktools/ruby-rspec-mock/test_coverage)\n[![CircleCI](https://circleci.com/gh/mocktools/ruby-rspec-mock/tree/master.svg?style=svg)](https://circleci.com/gh/mocktools/ruby-rspec-mock/tree/master)\n[![Gem Version](https://badge.fury.io/rb/rspec-mock.svg)](https://badge.fury.io/rb/rspec-mock)\n[![Downloads](https://img.shields.io/gem/dt/rspec-mock.svg?colorA=004d99\u0026colorB=0073e6)](https://rubygems.org/gems/rspec-mock)\n[![GitHub](https://img.shields.io/github/license/mocktools/ruby-rspec-mock)](LICENSE.txt)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n`rspec-mock` is a lightweight gem designed to ease the transition to RSpec's built-in mocking framework by allowing developers to use RSpec's mocks as secondary, alongside a primary, alternative mocking library. This setup enables new code to leverage RSpec’s built-in mocks directly, while still supporting legacy code that relies on an external mocking library.\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Configuration](#configuration)\n  - [Integration](#integration)\n  - [Migration Analytics](#migration-analytics)\n- [Contributing](#contributing)\n- [License](#license)\n- [Code of Conduct](#code-of-conduct)\n- [Credits](#credits)\n- [Versioning](#versioning)\n- [Changelog](CHANGELOG.md)\n\n## Features\n\n- Dual Mocking Compatibility: Use RSpec’s built-in mock framework as a secondary, with your primary mock of choice (e.g., Mocha, FlexMock).\n- Seamless Transition: Adopt `RSpec::Mocks` in new tests gradually, without disrupting existing tests dependent on an alternative mocking library.\n- Simplified Migration Path: Makes it easy to phase out external mocking libraries over time, moving towards a more unified, RSpec-native mocking approach.\n\n## Requirements\n\nRuby MRI 2.4.0+\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngroup :test do\n  gem 'rspec-mock', require: false\nend\n```\n\nAnd then execute:\n\n```bash\nbundle\n```\n\nOr install it yourself as:\n\n```bash\ngem install rspec-mock\n```\n\n## Usage\n\n### Configuration\n\n```ruby\n# spec/support/config/rspec_mock.rb\n\nrequire 'rspec/mock'\n\nRSpec.configure do |config|\n  config.rspec_mock do |mock|\n    mock.verify_partial_doubles = true\n  end\n\n  config.include RSpec::Mock::Methods\nend\n```\n\n### Integration\n\n```ruby\n# spec/spec_helper.rb\n\nRSpec.configure do |config|\n  config.mock_framework = :flexmock\nend\n\n# spec/sandbox_spec.rb\n\nRSpec.describe Sandbox do\n  describe '.call' do\n    subject(:service) { described_class.call(*args, **kwargs) }\n\n    let(:args) { [1, 2, 3] }\n    let(:kwargs) { { a: 1, b: 2 } }\n    let(:expected_result) { { args:, kwargs: } }\n\n    context 'when multiple mocks' do\n      before do\n        flexmock(described_class)\n          .should_receive(:new)\n          .with(*args, **kwargs)\n          .pass_thru\n\n        rspec_mock do\n          allow(described_class)\n            .to receive(:call)\n            .with(*args, **kwargs)\n            .and_call_original\n        end\n      end\n\n      it { is_expected.to eq(expected_result) }\n    end\n\n    context 'when single mock' do\n      it do\n        rspec_mock do\n          expect(described_class)\n            .to receive(:call)\n            .with(*args, **kwargs)\n            .and_call_original\n          expect(service).to eq(expected_result)\n        end\n      end\n    end\n  end\nend\n```\n\n### Migration Analytics\n\nThis time implemented migration analytics for [Flexmock](https://github.com/doudou/flexmock) only. You can run Rake task to analyze Flexmock usage and track migration progress to RSpec mocks.\n\nFor non-Rails applications to use the task, you need to load it:\n\n```ruby\nrequire 'rspec/mock/task'\n\nRSpec::Mock::Task.load\n```\n\nFor Rails applications it will be automatically loaded, so just run:\n\n```bash\n# Analyze entire spec directory (default)\nrake rspec_mock:migration_analytics:flexmock\n\n# Analyze specific directory\nrake rspec_mock:migration_analytics:flexmock spec/services\n\n# Analyze specific file\nrake rspec_mock:migration_analytics:flexmock spec/services/sandbox_service_spec.rb\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at \u003chttps://github.com/mocktools/ruby-rspec-mock\u003e. 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. Please check the [open tickets](https://github.com/mocktools/ruby-rspec-mock/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).\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::Mock project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n\n## Credits\n\n- [The Contributors](https://github.com/mocktools/ruby-rspec-mock/graphs/contributors) for code and awesome suggestions\n- [The Stargazers](https://github.com/mocktools/ruby-rspec-mock/stargazers) for showing their support\n\n## Versioning\n\nRSpec::Mock uses [Semantic Versioning 2.0.0](https://semver.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmocktools%2Fruby-rspec-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmocktools%2Fruby-rspec-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmocktools%2Fruby-rspec-mock/lists"}