Sha256: 000c37b9fd4077867496daeb8bf6d7ec19cbf5b772709e7e5862784f14f158c9

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'lerna/state'

RSpec.describe Lerna::State do
  subject { described_class.new(enumerator) }

  let(:enumerator) { -> { enumerations.shift } }

  context 'after the first scan' do
    let(:enumerations) {
      [
        [Lerna::Display.new('HDMI1', false)]
      ]
    }

    before do
      subject.scan!
    end

    it { is_expected.to be_changed }

    it 'lists the current displays' do
      expect(subject.displays).to eq([Lerna::Display.new('HDMI1', false)])
    end
  end

  context 'when the connections have changed' do
    let(:enumerations) {
      [
        [Lerna::Display.new('HDMI1', false)],
        [Lerna::Display.new('HDMI1', true)]
      ]
    }

    before do
      2.times do
        subject.scan!
      end
    end

    it { is_expected.to be_changed }

    it 'lists the current displays' do
      expect(subject.displays).to eq([Lerna::Display.new('HDMI1', true)])
    end
  end

  context 'when the connections have not changed' do
    let(:enumerations) {
      [
        [Lerna::Display.new('HDMI1', true)],
        [Lerna::Display.new('HDMI1', true)]
      ]
    }

    before do
      2.times do
        subject.scan!
      end
    end

    it { is_expected.not_to be_changed }

    it 'lists the current displays' do
      expect(subject.displays).to eq([Lerna::Display.new('HDMI1', true)])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lerna-0.1.1 spec/state_spec.rb
lerna-0.1.0 spec/state_spec.rb