-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSpec matchers #147
Comments
👍 |
1 similar comment
👍 |
Now I have time for new features again. Having rspec matchers or minitest assertions available for AASM would be a great feature. Should that be part of a core AASM or more an extra extension gem (e.g. |
In my opinion it should be a core feature. All the other gems i know that provide rspec matchers include these in their core. |
On the other side, it's increasing the gem size and is not really a core feature of a state machine. In my opinion it's an add-on. Any other opinions out there? |
@alto it would increase gem disk usage (by a few kilobytes) but not the memory usage because they won't be required by library code. They will need to be manually required by user in Lot of gems already use this approach, see for instance carrierwave, they provide a single file to be required if used. Having a separate gem only to provide a couple of files would be pointless in my opinion. |
I've updated the matcher above with the version I'm currently using. |
Would these matchers be a start? job = Job.new # single state machine per class
job.should have_state :sleeping
job.should allow_transition_to :running
job.should allow_event :run
job.should allow_event :run!
job.should_not allow_event :clean
job.should_not allow_event :clean!
# and
simple = SimpleMultipleExample.new # multiple state machines per class
simple.should have_state :standing, :on => :move
simple.should allow_transition_to :walking, :on => :move
simple.should allow_event :run
simple.should allow_event :run!
simple.should have_state :sleeping, :on => :work
simple.should allow_transition_to :processing, :on => :work
simple.should allow_event :start
simple.should allow_event :start!
simple.should_not allow_event :stop
simple.should_not allow_event :stop! |
@alto Looks good to me. Do you have already matchers for that or are you planning to write them? |
@kiela I'm planning to write them, based on the code snippets in this ticket. Do you want to help? |
Will be released with #279 . Feel free to have a look and try it out. |
Released version |
Are you interested in bundling some RSpec matchers in your gem?
Currently I'm using a simple matcher which only allows to check for permissible states
Here's the matcher:
The text was updated successfully, but these errors were encountered: