Sha256: 97b3bc2ab0ce0e3c22aea7b5ab4b069dba36a3319042be17b06aad21ed8c5e34
Contents?: true
Size: 773 Bytes
Versions: 4
Compression:
Stored size: 773 Bytes
Contents
# frozen_string_literal: true RSpec.describe RuboCop::RSpec::Util, '.one' do let(:first) { instance_double(Object) } let(:array) { instance_double(Array, one?: true, first: first) } let(:client) { Class.new.extend(described_class) } it 'returns first element' do expect(client.one(array)).to be(first) end it 'fails if the list is empty' do expect { client.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 { client.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
4 entries across 4 versions & 1 rubygems