1
Ich verwende ein asm-Juwel, um Zustandsübergänge in meinem Projekt zu behandeln. Ich habe ein einfaches Modell, das wie folgt aussieht:Testen von Aasm-Statusübergängen mit rspec
class TransferPostingBid < ActiveRecord::Base
include AASM
aasm :status do
state :offered, initial: true
state :wait_for_pap_confirmation
state :confirmed_by_pap
state :retracted_by_pap
event :pap_choosed do
transitions from: :offered, to: :wait_for_pap_confirmation
end
event :confirmed_by_pap do
transitions from: :wait_for_pap_confirmation, to: :confirmed_by_pap
end
event :retracted_by_pap do
transitions from: :wait_for_pap_confirmation, to: :retracted_by_pap
end
end
end
Und ich versuche, Übergänge mit AASM in rspec Matcher gebaut zu testen:
require 'rails_helper'
describe TransferPostingBid, type: :model do
describe 'state transitions' do
let(:transfer_posting_bid) { TransferPostingBid.new }
it 'has default state' do
expect(transfer_posting_bid).to transition_from(:offered).to(:wait_for_pap_confirmation).on_event(:pap_choosed)
end
end
end
Wenn ich laufen diese spec es mich gibt folgende Fehlermeldung:
AASM::UnknownStateMachineError:
There is no state machine with the name 'default' defined in TransferPostingBid!
Wie kann ich das beheben?