【发布时间】:2010-06-15 17:46:46
【问题描述】:
请帮帮我。我很困惑。我知道如何编写模型的状态驱动行为,但我不知道我应该在规范中写什么...
我的model.rb文件看起来
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
我使用state_machine gem。
请告诉我课程。
【问题讨论】:
-
有什么方法可以在不访问数据库的情况下做到这一点?似乎我们应该能够剔除 state_machine 用来访问数据库的任何内容,并且仍然可以获得我们期望的所有更改。
标签: ruby-on-rails rspec state-machine