spec/undo_spec.rb in mongoid-undo-0.2.1 vs spec/undo_spec.rb in mongoid-undo-0.3.0

- old
+ new

@@ -10,20 +10,18 @@ field :name, type: String end subject { Document.new(name: 'foo') } - let(:name) { subject.name } - let(:action) { subject.send(:_action) } describe 'creating' do before { subject.save } it 'sets action to :create' do - action.must_equal :create + subject.action.must_equal :create end describe 'undoing' do before { subject.undo } @@ -33,11 +31,11 @@ subject.persisted?.wont_equal true end it 'keeps :create action' do - action.must_equal :create + subject.action.must_equal :create end describe 'redoing' do before { subject.redo } @@ -47,60 +45,60 @@ subject.persisted?.must_equal true end it 'keeps :create action' do - action.must_equal :create + subject.action.must_equal :create end end end describe 'updating' do before { subject.update_attributes(name: 'bar') } it 'sets action to :update' do - action.must_equal :update + subject.action.must_equal :update end describe 'undoing' do before { subject.undo } it 'retrieves' do - name.must_equal 'foo' + subject.name.must_equal 'foo' end it 'saves a new version' do subject.version.must_equal 3 end it 'keeps :update action' do - action.must_equal :update + subject.action.must_equal :update end describe 'redoing' do before { subject.redo } it 'retrieves' do - name.must_equal 'bar' + subject.name.must_equal 'bar' end it 'saves a new version' do subject.version.must_equal 4 end it 'keeps :update action' do - action.must_equal :update + subject.action.must_equal :update end end end end @@ -108,11 +106,11 @@ describe 'destroying' do before { subject.destroy } it 'sets action to :destroy' do - action.must_equal :destroy + subject.action.must_equal :destroy end it 'marks as destroyed' do subject.persisted?.must_equal false @@ -127,11 +125,11 @@ subject.persisted?.wont_equal false end it 'keeps :destroy action' do - action.must_equal :destroy + subject.action.must_equal :destroy end describe 'redoing' do before { subject.redo } @@ -141,11 +139,11 @@ subject.persisted?.must_equal false end it 'keeps :destroy action' do - action.must_equal :destroy + subject.action.must_equal :destroy end end end end end @@ -156,17 +154,17 @@ subject.method(:redo).must_equal subject.method(:undo) end end - describe :_action do + describe :action do it 'is a symbol' do - subject.fields['_action'].options[:type].must_equal Symbol + subject.fields['action'].options[:type].must_equal Symbol end it 'is versionless' do - subject.fields['_action'].options[:versioned].must_equal false + subject.fields['action'].options[:versioned].must_equal false end end describe 'localization' do