Sha256: 20dc9b6ae30fbe90e004f9af34e0bf92e6820c44d778cf202f625473b043be63
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
# state_machines_rspec Custom matchers for [state-machines/state_machine](https://github.com/state-machines/state_machine). Forked from [pluginaweek/state_machine](https://github.com/pluginaweek/state_machine). ## Matchers ### `have_state` & `reject_state` ```ruby describe Vehicle do it { should have_states :parked, :idling, :stalled, :first_gear, :second_gear, :third_gear } it { should reject_state :flying } it { should have_states :active, :off, on: :alarm_state } it { should have_state :active, on: :alarm_state, value: 1 } it { should reject_states :broken, :ringing, on: :alarm_state } end ``` ### `handle_event` & `reject_event` ```ruby describe Vehicle do it { should handle_events :shift_down, :crash, when: :third_gear } it { should handle_events :enable_alarm, :disable_alarm, when: :active, on: :alarm_state } it { should reject_events :park, :ignite, :idle, :shift_up, :repair, when: :third_gear } end ``` ## Installation Add these lines to your application's Gemfile: (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) ```ruby group :test do gem 'state_machines_rspec' end ``` And include the matchers in `spec/spec_helper.rb` or `spec/rails_helper.rb` ```ruby RSpec.configure do |config| config.include StateMachinesRspec::Matchers end ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
state_machines_rspec-0.3.2 | README.md |
state_machines_rspec-0.3.1 | README.md |