Sha256: d33a953c97f41d5c082169775a2beb6b0cb19ff4cac1982da55c285a465f0e4c

Contents?: true

Size: 742 Bytes

Versions: 28

Compression:

Stored size: 742 Bytes

Contents

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

28 entries across 28 versions & 1 rubygems

Version Path
rubocop-rspec-1.32.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.31.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.30.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.30.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.29.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.29.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.28.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.27.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.26.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.25.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/rspec/util/one_spec.rb