{"id":13878956,"url":"https://github.com/state-machines/state_machines-rspec","last_synced_at":"2025-04-12T03:30:59.190Z","repository":{"id":36458735,"uuid":"40763824","full_name":"state-machines/state_machines-rspec","owner":"state-machines","description":null,"archived":false,"fork":false,"pushed_at":"2021-06-09T21:57:14.000Z","size":74,"stargazers_count":17,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T23:22:16.382Z","etag":null,"topics":["rspec","ruby","state-machine"],"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/state-machines.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}},"created_at":"2015-08-15T14:19:59.000Z","updated_at":"2024-11-21T02:09:27.000Z","dependencies_parsed_at":"2022-08-18T03:05:49.694Z","dependency_job_id":null,"html_url":"https://github.com/state-machines/state_machines-rspec","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-rspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-rspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-rspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-rspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/state-machines","download_url":"https://codeload.github.com/state-machines/state_machines-rspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512497,"owners_count":21116613,"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","ruby","state-machine"],"created_at":"2024-08-06T08:02:05.325Z","updated_at":"2025-04-12T03:30:58.453Z","avatar_url":"https://github.com/state-machines.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# state_machines-rspec\n[![Gem Version](https://badge.fury.io/rb/state_machines-rspec.svg)](https://badge.fury.io/rb/state_machines-rspec)\n[![Build Status](https://travis-ci.org/state-machines/state_machines-rspec.svg?branch=master)](https://travis-ci.org/state-machines/state_machines-rspec)\n\nCustom RSpec matchers for [state-machines/state_machines](https://github.com/state-machines/state_machines).\n\nThis repo is forked from [modocache/state_machine_rspec](https://github.com/modocache/state_machine_rspec).\n\n## Matchers\n\n### `have_state` \u0026 `reject_state`\n\n```ruby\ndescribe Vehicle do\n  it { is_expected.to have_states :parked, :idling, :stalled, :first_gear,\n                                  :second_gear, :third_gear }\n  it { is_expected.to reject_state :flying }\n\n  it { is_expected.to have_states :active, :off, on: :alarm_state }\n  it { is_expected.to have_state :active, on: :alarm_state, value: 1 }\n  it { is_expected.to reject_states :broken, :ringing, on: :alarm_state }\nend\n```\n\n### `handle_event` \u0026 `reject_event`\n\n```ruby\ndescribe Vehicle do\n  it { is_expected.to handle_events :shift_down, :crash, when: :third_gear }\n  it { is_expected.to handle_events :enable_alarm, :disable_alarm,\n                                    when: :active, on: :alarm_state }\n  it { is_expected.to reject_events :park, :ignite, :idle, :shift_up, :repair,\n                                    when: :third_gear }\nend\n```\n\n### `transition_from`\n\n```ruby\ndescribe Vehicle do\n  it { is_expected.to transition_from :idling, to_state: :parked,\n                                      on_event: :park }\n  it { is_expected.to transition_from :idling, :first_gear,\n                                      to_state: :parked, on_event: :park }\n  it { is_expected.to transition_from :active, to_state: :off,\n                                      on_event: :disable_alarm, on: :alarm_state }\n  it { is_expected.to transition_from :_any_, to_state: :stoped, on_event: :stop }\nend\n```\n\n\n## Installation\n\nAdd these lines to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'state_machines-rspec'\nend\n```\n\n(Note that the orginal `state_machine_rspec` used `state_machine` singular and I'm using `state_machines` plural to fit in with `state-machines/state_machines`.)\n\nAnd include the matchers in `spec/spec_helper.rb` or `spec/rails_helper.rb`\n\n```ruby\nRSpec.configure do |config|\n  config.include StateMachinesRspec::Matchers\nend\n```\n\n## Contributing\n\n1. Fork it\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 new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machines%2Fstate_machines-rspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstate-machines%2Fstate_machines-rspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machines%2Fstate_machines-rspec/lists"}