spec/mongoid/mongoid_spec.rb in edge-state-machine-0.9.1 vs spec/mongoid/mongoid_spec.rb in edge-state-machine-1.0.0

- old
+ new

@@ -2,11 +2,13 @@ describe 'mongoid state machine' do context 'existing mongo document' do before do - Mongoid.master.collections.reject { |c| c.name =~ /^system\./ }.each(&:drop) + session = Moped::Session.new([ 'localhost:27017' ]) + session.use 'edge-state-machine-test' + session.drop end let :light do MongoTrafficLight.create! end @@ -45,11 +47,11 @@ loaded_light = MongoTrafficLight.find(light.id) loaded_light.current_state.should == :red end it 'should raise error on transition to an invalid state' do - expect { light.yellow_on }.should raise_error EdgeStateMachine::NoTransitionFound + expect { light.yellow_on }.to raise_error EdgeStateMachine::NoTransitionFound light.current_state.should == :off end it 'should persist state when state is protected on transition' do protected_light = MongoProtectedTrafficLight.create! @@ -68,16 +70,16 @@ light.valid?.should_not == true end it 'should raise exception when model validation fails on transition' do validating_light = MongoValidatingTrafficLight.create! - expect {validating_light.reset!}.should raise_error Mongoid::Errors::Validations + expect {validating_light.reset!}.to raise_error Mongoid::Errors::Validations end it 'should state query method used in a validation condition' do validating_light = MongoConditionalValidatingTrafficLight.create! - #expect {validating_light.reset!}.should raise_error Mongoid::RecordInvalid + #expect {validating_light.reset!}.to raise_error Mongoid::RecordInvalid validating_light.off?.should == true end it 'should reload the model when current state resets' do light.reset @@ -116,20 +118,22 @@ end end context 'timestamp' do before do - Mongoid.master.collections.reject { |c| c.name =~ /^system\./ }.each(&:drop) + session = Moped::Session.new([ 'localhost:27017' ]) + session.use 'edge-state-machine-test' + session.drop end def create_order(state = nil) MongoOrder.create! order_number: 234, state: state end # control case, no timestamp has been set so we should expect default behaviour it 'should not raise any exceptions when moving to placed' do @order = create_order - expect { @order.place! }.should_not raise_error + expect { @order.place! }.to_not raise_error @order.state.should == 'placed' end end end \ No newline at end of file