Sha256: 54e562eb751e7f28be8882e392a407677aee93caf7a2392199994ef23d527171

Contents?: true

Size: 1.96 KB

Versions: 17

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

module ChangeManager
    describe Change do

        it 'has a valid factory' do
        	FactoryGirl.create(:change).should be_valid
        end

        it 'should have a change_owner' do
        	FactoryGirl.build(:change, owner: nil).should_not be_valid
        end

        it 'should have a change_target' do
        	FactoryGirl.build(:change, target: nil).should_not be_valid
        end

        it 'should have a change_type' do
        	FactoryGirl.build(:change, change_type: nil).should_not be_valid
        end

        it 'should be initialized as false' do
            FactoryGirl.build(:change).cancelled.should be_false
        end

        # seperate describe blocks, wrap in context
        context 'instance method' do
            let(:cancelled_change) { FactoryGirl.build(:change, cancelled: true) }
            let(:change) { FactoryGirl.build(:change) }
            describe '#cancel' do
                after { change.cancelled = false }
            	it 'should cancel a notification' do
                    change.cancel
            		change.cancelled.should be_true
            	end
            end

            describe '#cancelled?' do
            	it 'should return whether a notification is cancelled' do
            		change.cancelled.should be_false
            		cancelled_change.cancelled?.should be_true
            	end
            end

            describe '#inverse_of?' do
                let(:inverse_change) { FactoryGirl.build(:change, change_type: 'removed_as_delegate')}
                let(:noninverse_change) { FactoryGirl.build(:change, change_type: 'added_as_editor')}
                
                it 'should accurately detect inverse changes' do
                    change.inverse_of?(inverse_change).should be_true
                end

                it 'should not detect non-inverse changes' do
                    change.inverse_of?(noninverse_change).should be_false
                end
            end
        end
    end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
change_manager-0.3.2 spec/models/change_manager/change_spec.rb
change_manager-0.3.1 spec/models/change_manager/change_spec.rb
change_manager-0.3.0 spec/models/change_manager/change_spec.rb
change_manager-0.2.0 spec/models/change_manager/change_spec.rb
change_manager-0.1.5 spec/models/change_manager/change_spec.rb
change_manager-0.1.2 spec/models/change_manager/change_spec.rb
change_manager-0.1.1 spec/models/change_manager/change_spec.rb
change_manager-0.1.0 spec/models/change_manager/change_spec.rb
change_manager-0.0.9 spec/models/change_manager/change_spec.rb
change_manager-0.0.8 spec/models/change_manager/change_spec.rb
change_manager-0.0.7 spec/models/change_manager/change_spec.rb
change_manager-0.0.6 spec/models/change_manager/change_spec.rb
change_manager-0.0.5 spec/models/change_manager/change_spec.rb
change_manager-0.0.4 spec/models/change_manager/change_spec.rb
change_manager-0.0.3 spec/models/change_manager/change_spec.rb
change_manager-0.0.2 spec/models/change_manager/change_spec.rb
change_manager-0.0.1 spec/models/change_manager/change_spec.rb