module RuboCop::RSpec::Util

Utility methods

Constants

SizeError

Error raised by `Util.one` if size is less than zero or greater than one

Public Instance Methods

one(array) click to toggle source

Return only element in array if it contains exactly one member

# File lib/rubocop/rspec/util.rb, line 11
def one(array)
  return array.first if array.one?

  raise SizeError,
        "expected size to be exactly 1 but size was #{array.size}"
end