Rails: How to test state_machine?

Posted by petRUShka on Stack Overflow See other posts from Stack Overflow or by petRUShka
Published on 2010-06-15T17:46:46Z Indexed on 2010/06/15 17:52 UTC
Read the original article Hit count: 217

Please, help me. I'm confused. I know how to write state-driven behavior of model, but I don't know what should I write in specs...

My model.rb file look

class Ratification < ActiveRecord::Base
  belongs_to :user

  attr_protected :status_events

  state_machine :status, :initial => :boss do
    state :boss
    state :owner
    state :declarant
    state :done

    event :approve do
      transition :boss => :owner, :owner => :done
    end

    event :divert do
      transition [:boss, :owner] => :declarant
    end

    event :repeat do
      transition :declarant => :boss
    end

  end
end

I use state_machine gem.

Please, show me the course.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rspec