Hi all,
I am newbie AASM. I just tried to use AASM on my project. I have a problem: at Model
class Job include AASM
aasm :no_direct_assignment => true do state :sleeping, :initial => true state :running state :cleaning event :run do transitions :from => :sleeping, :to => :running end event :clean do transitions :from => :running, :to => :cleaning end event :sleep do transitions :from => [:running, :cleaning], :to => :sleeping end end end
And on rspec unit test
... describe '#clean!' do before do AASM::Configuration.stub(:no_direct_assignment).and_return(false) end describe 'Job clearning cancel' do let(:job) { FactoryGirl.create(:job, aasm_status: 'running') } context "when status is 'running'" do it "should update to cleaning" do job.clean! job.reload job.aasm_status.should eql 'cleaning' end end end end ...
When i run rspec i got error:
Failure/Error: let(:job) { FactoryGirl.create(:job, aasm_status: 'running') } AASM::NoDirectAssignmentError: direct assignment of AASM column has been disabled (see AASM configuration for this class)
Please share me any idea to make pass unit test. How can i stub :no_direct_assignment right?