No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
RSpec matchers for state_machine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.0.rc1
 Project Readme

state_machine_rspec

Build Status

Custom matchers for pluginaweek/state_machine.

Matchers

have_state & reject_state

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

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:

group :test do
  gem 'state_machine_rspec'
end

And include the matchers in spec/spec_helper.rb:

RSpec.configure do |config|
  config.include StateMachineRspec::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