Sha256: 4a14e58df9e7e091b6426f71282e3e38e9722a686dd55c9d7aa4d1979b8a52c9

Contents?: true

Size: 722 Bytes

Versions: 20

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Util, '.one' do
  let(:first) { instance_double(Object)                          }
  let(:array) { instance_double(Array, one?: true, first: first) }

  it 'returns first element' do
    expect(described_class.one(array)).to be(first)
  end

  it 'fails if the list is empty' do
    expect { described_class.one([]) }
      .to raise_error(described_class::SizeError)
      .with_message('expected size to be exactly 1 but size was 0')
  end

  it 'fails if the list has more than one element' do
    expect { described_class.one([1, 2]) }
      .to raise_error(described_class::SizeError)
      .with_message('expected size to be exactly 1 but size was 2')
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/unit/mutant/util/one_spec.rb
mutant-0.9.10 spec/unit/mutant/util/one_spec.rb
mutant-0.9.9 spec/unit/mutant/util/one_spec.rb
mutant-0.9.8 spec/unit/mutant/util/one_spec.rb
mutant-0.9.7 spec/unit/mutant/util/one_spec.rb
mutant-0.9.6 spec/unit/mutant/util/one_spec.rb
mutant-0.9.5 spec/unit/mutant/util/one_spec.rb
mutant-0.9.4 spec/unit/mutant/util/one_spec.rb
mutant-0.9.3 spec/unit/mutant/util/one_spec.rb
mutant-0.9.2 spec/unit/mutant/util/one_spec.rb
mutant-0.9.1 spec/unit/mutant/util/one_spec.rb
mutant-0.9.0 spec/unit/mutant/util/one_spec.rb
mutant-0.8.24 spec/unit/mutant/util/one_spec.rb
mutant-0.8.23 spec/unit/mutant/util/one_spec.rb
mutant-0.8.22 spec/unit/mutant/util/one_spec.rb
mutant-0.8.21 spec/unit/mutant/util/one_spec.rb
mutant-0.8.20 spec/unit/mutant/util/one_spec.rb
mutant-0.8.19 spec/unit/mutant/util/one_spec.rb
mutant-0.8.18 spec/unit/mutant/util/one_spec.rb
mutant-0.8.17 spec/unit/mutant/util/one_spec.rb