state-machines / state_machines

Adds support for creating state machines for attributes on any Ruby class
https://github.com/state-machines/state_machines
MIT License
814 stars 91 forks source link

question regarding state machine collections #25

Closed JohnSmall closed 9 years ago

JohnSmall commented 9 years ago

I'm working on updating the state_machine_rspec gem to use state_machines and I've come across a critical difference in behaviour. In the old pluginaweek/state_machine the class method #state_machine returned a collection of state_machines, and the collection was inherited from Hash. In the state_machine_rspec gem there's a line which relies on [] to get a named machine from the collection. I can't find the equivalent method in the new state-machines/state_machines.

The difference is that in the new style the class method #state_machine returns a single state_machine and there doesn't seem to be a way to get one of possibly many named state machines.

This is blocking me from updating the state_machine_rspec gem (updated to state_machines_rspec gem) for the new state-machines/state_machine.

Any idea how I can solve this issue?

JohnSmall commented 9 years ago

Solved it. My bad. I'd used sed to make global updates from state_machine to state_machines and then selectively edited state_machines back to state_machine where required, this was one case where I'd made the wrong edit. So the code was state_machine, where it should have been state_machines. Now I've solved that I'm moving on to the next fail.

JohnSmall commented 9 years ago

The new gem 'state_machines_rspec' is now passing all specs. I've not updated the pending specs carried over from the original 'state_machine_rspec', but it does work with state-machines/state_machines

see https://github.com/JohnSmall/state_machine_rspec

seuros commented 9 years ago

Awesome job @JohnSmall. Would you mind moving the repo to the state-machines org ? I can add you if you are willing to maintain it.

JohnSmall commented 9 years ago

Ok, will do I'm hard at work on a project this afternoon, that makes use of the gem. So I'm giving it a good workout.

I'll maintain the gem (when I get time), so add me to the group that can add repos to state-machines.