There was an error while loading. Please reload this page.
Rspec matcher have_states tests the defined states for a given attribute.
have_states
With the follow configuration...
class Post < ActiveRecord::Base include StateGate state_gate :status do state :draft state :pending end end
...it passes with the correct states and attribute.
expect(Post).to have_states(:draft, :pending).for(:status) #=> success
...it fails with a missing state.
expect(Post).to have_states(:pending).for(:status) #=> fails: ':draft is also a valid state for #status.'
...it fails with a non-defined state.
expect(Post).to have_states(:draft, :pending, :dummy).for(:status) #=> fails: ':dummy is not a valid state for #status.'
...it fails with the wrong attribute.
expect(Post).to have_states(:draft, :pending).for(:category) #=> fails: 'no state_gate is defined for #category.'