{"id":13880203,"url":"https://github.com/davidcelis/spec-me-maybe","last_synced_at":"2025-04-09T21:23:54.424Z","repository":{"id":21175045,"uuid":"24479360","full_name":"davidcelis/spec-me-maybe","owner":"davidcelis","description":":question: Introduces the `maybe` syntax to RSpec.","archived":false,"fork":false,"pushed_at":"2014-10-29T03:35:15.000Z","size":246,"stargazers_count":167,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T20:06:10.473Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidcelis.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":"2014-09-25T23:54:50.000Z","updated_at":"2024-10-18T13:53:06.000Z","dependencies_parsed_at":"2022-08-22T18:30:57.450Z","dependency_job_id":null,"html_url":"https://github.com/davidcelis/spec-me-maybe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcelis%2Fspec-me-maybe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcelis%2Fspec-me-maybe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcelis%2Fspec-me-maybe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcelis%2Fspec-me-maybe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidcelis","download_url":"https://codeload.github.com/davidcelis/spec-me-maybe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113197,"owners_count":21049802,"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-08-06T08:02:51.878Z","updated_at":"2025-04-09T21:23:54.393Z","avatar_url":"https://github.com/davidcelis.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# spec-me-maybe [![Build Status][travis-badge]][travis]\n\nAre your tests order-dependent? Tired of all those randomly failing specs? Can't be bothered to use [Timecop][timecop]? Just give up and surrender. But at least use a proper syntax.\n\nIntroducing the `maybe` syntax for RSpec.\n\n[timecop]: https://github.com/travisjeffery/timecop\n[travis]: https://travis-ci.org/davidcelis/spec-me-maybe\n[travis-badge]: http://img.shields.io/badge/build-probably-yellow.svg\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'spec-me-maybe'\n```\n\nAnd then execute:\n\n```sh\n$ bundle\n```\n\nOr install it yourself as:\n\n```sh\n$ gem install spec-me-maybe\n```\n\nThen, in your `spec_helper.rb` file:\n\n```ruby\nrequire 'rspec/maybes'\n\nRSpec.configure do |config|\n  config.expect_with :rspec do |expectations|\n    # Enable the `maybe` syntax from spec-me-maybe, e.g.:\n    #   maybe(actual).will eq(expected)\n    expectations.syntax = :maybe\n  end\nend\n```\n\n## Usage\n\nThe \"maybe\" syntax looks and feels almost exactly like the \"expect\" syntax:\n\n```ruby\ndescribe User do\n  describe '#initialize' do\n    let(:user) { User.new(name: 'David Celis') }\n\n    it 'should set up a name' do\n      maybe(user.name).will eq 'David Celis'\n    end\n\n    it 'probably should not raise any sort of error' do\n      maybe { user }.will_not raise_error\n    end\n  end\nend\n```\n\nWhereas `expect` would set up an `RSpec::Expectations::ExpectationTarget`, `maybe` will instead set up an `RSpec::Maybe::MaybeTarget`. Like expectations, maybes may or may not fail. In the case of maybes, however, they will fail randomly regardless of your code. But hey, maybe your Expectations were like that too.\n\nIf your colleagues' complaints of broken specs are totally bullshit because you're _super_ sure they work on your machine, we've got you covered. Here's the above example again, but this time it'll totally always pass:\n\n```ruby\ndescribe User do\n  describe '#initialize' do\n    let(:user) { User.new(name: 'David Celis') }\n\n    it 'should set up a name' do\n      maybe(user.name).will eq('David Celis').on_my_machine\n    end\n\n    it 'probably should not raise any sort of error' do\n      maybe { user }.will_not raise_error.on_my_machine\n    end\n  end\nend\n```\n\n## Contributing\n\n1. [Fork it](https://github.com/davidcelis/spec-me-maybe/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%2Fdavidcelis%2Fspec-me-maybe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcelis%2Fspec-me-maybe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcelis%2Fspec-me-maybe/lists"}