rspec - Rails: How to test state_machine? -


Please help me, I am confused. I know how to write the state-run behavior of the model, but I do not know what I should write in the spec ...

See my model. Rb file

  Class Raptation & lt; ActiveRecord :: Base is_to: User attr_protected: status_events state_machine: status,: initial => : Boss State: Boss State: Owner State: Disclaimer State: Incident: Transit Permission: Boss = & gt; : Owner, owner = & gt; : Ended Event: Transition [: Boss, Owner] => : Degradation End Event: Repeat Infection: declarant = & gt;  

Post-text "itemprop =" text ">

The question is old, but I had the same one. Take the example from: : Parked Event: Park Transition [: idling, first_gear] = & gt;: Parked and Event: Kindle Infection: Stall = & Gt; equal,: vertical =>: ending and event: inactivate transition: first_gear =>: ending and event: shift_up transition: idling =>: first_gear ,: First_gear = & gt;: seconds_gear,: seconds_gear = & gt;: third gear and event: shift_down transition: third_gear = & gt;: seconds_gear,: seconds_gear = & gt;: first gear and end

My solution was:

  Describe before the vehicle: each @ veil = factory (: vehicle) describes the end 'states' Do not describe': parked 'do it' Must be a starting state # # For the vehicle should be the check # parked? True? Vehicle should end it. It should change: Clues: Ignite 'do @ vehicle.ignite! @home.may be the end [' shift_up! ',' Shift_down! ']. Do each. Action | This will increase an error for "# {action}" lambda {@job_father. send (action)}. Raise_error End And End And End  

I was using:

  • Ruby (1.9.3)
  • Rail (
  • rspec (2.8.0.rc1)
  • factory_girl (2.3.2)
  • state_matin (1.1.0)
  • < / Ul>

    Comments

    Popular posts from this blog

    windows - Heroku throws SQLITE3 Read only exception -

    lex - Building a lexical Analyzer in Java -

    python - rename keys in a dictionary -