You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When using binding_event: rspec does not reset the bound state causing failures when calling transitions_from(:state).on(:second_state) in the same block
Describe the solution you'd like
I can see two routes for this, either we should be updating the rspec helper to allow the user to specify the multiple states used in the binding event, or reload the object's initial state before runing the transitions_from test
transitions_from(status: :pending, status_2: :draft).to(:cancelled, :missing) or something of the sort. Being able to set the bound event's state and the currently state in the transitions_from
Describe alternatives you've considered
Making the object reload after each test, could solve the problem, though can slow down tests significantly since we have to go pull the object back from the db before each run. Even worse would be to set each state in its own it block since we then would be recreating the subject after each test causing even more of a slow down.
Currently using an after: :method block instead of the binding_event does work, though the use of the binding event would be much cleaner to use.
Additional context
Example
In this example we can move status to cancelled only from draft.
if status_2 goes to missing, we want to tranisition status to cancelled through the binding_event, but only if the status is draft.
itdois_expected.totransition_from(:open).to(:missing).on_event(:miss).on(:status_2)# the above test will pass, but the object is now set as `status: canceled, status_2: missing`# when running the next test, the helper sets status_2 to `missing`, but leaves status in `cancelled` instead of reverting to `draft`causingafailureinthetestsbelowis_expected.totransition_from(:draft).to(:missing).on_event(:miss).on(:status_2)...end
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When using
binding_event:
rspec does not reset the bound state causing failures when callingtransitions_from(:state).on(:second_state)
in the same blockDescribe the solution you'd like
I can see two routes for this, either we should be updating the rspec helper to allow the user to specify the multiple states used in the binding event, or reload the object's initial state before runing the
transitions_from
testtransitions_from(status: :pending, status_2: :draft).to(:cancelled, :missing)
or something of the sort. Being able to set the bound event's state and the currently state in the transitions_fromDescribe alternatives you've considered
Making the object reload after each test, could solve the problem, though can slow down tests significantly since we have to go pull the object back from the db before each run. Even worse would be to set each state in its own
it
block since we then would be recreating the subject after each test causing even more of a slow down.Currently using an
after: :method
block instead of thebinding_event
does work, though the use of the binding event would be much cleaner to use.Additional context
Example
In this example we can move status to cancelled only from draft.
if status_2 goes to missing, we want to tranisition status to cancelled through the binding_event, but only if the status is draft.
RSpec test:
The text was updated successfully, but these errors were encountered: