Sha256: 61daa31c2be65af053261ec1577dd0c927db8bae1c797aa34b65a3c1e5ef1de6

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe Synchronisable do
  describe 'synchronization' do
    subject do
      -> { Synchronisable.sync }
    end

    describe 'models specified in configuration' do
      context 'only Team and Match' do
        before :all do
          Synchronisable.models = %w(Match Team)
        end

        it { is_expected.to change { Match.count }.by(1) }
        it { is_expected.to change { Team.count }.by(2) }
        it { is_expected.to change { Player.count }.by(4) }
        it { is_expected.to change { MatchPlayer.count }.by(4) }

        it { is_expected.to change { Synchronisable::Import.count }.by(11) }
      end

      context 'all' do
        before :all do
          Synchronisable.models = %w(
            Tournament Team
            Match MatchPlayer Player
          )
        end

        it { is_expected.to change { Tournament.count }.by(1) }
        it { is_expected.to change { Stage.count }.by(2) }
        it { is_expected.to change { Match.count }.by(1) }
        it { is_expected.to change { Team.count }.by(2) }
        it { is_expected.to change { MatchPlayer.count }.by(4) }
        it { is_expected.to change { Player.count }.by(4) }

        it { is_expected.to change { Synchronisable::Import.count }.by(14) }
      end

      context 'when models setting is overriden in method call' do
        before :all do
          Synchronisable.models = %w(Team Match)
        end

        subject do
          -> { Synchronisable.sync(Match, Player) }
        end

        it { is_expected.to change { Match.count }.by(1) }
        it { is_expected.to change { Team.count }.by(2) }
        it { is_expected.to change { Player.count }.by(4) }
        it { is_expected.to change { MatchPlayer.count }.by(4) }

        it { is_expected.not_to change { Stage.count } }
        it { is_expected.not_to change { Tournament.count } }

        it { is_expected.to change { Synchronisable::Import.count }.by(11) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
synchronisable-1.1.5 spec/synchronisable/synchronisable_spec.rb
synchronisable-1.1.4 spec/synchronisable/synchronisable_spec.rb