Sha256: 4d8e358bd49618e0d99ac74ba26ad82d4553f55f7f9808235ecb322900dcdafc

Contents?: true

Size: 736 Bytes

Versions: 10

Compression:

Stored size: 736 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-rspec-1.12.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.11.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.10.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.9.1 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.9.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.8.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.7.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.6.0 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.5.3 spec/rubocop/rspec/util/one_spec.rb
rubocop-rspec-1.5.2 spec/rubocop/rspec/util/one_spec.rb