Method: RSpec::Matchers#be

Defined in:
lib/rspec/matchers.rb

#be(*args) ⇒ Object Also known as: a_value

Given true, false, or nil, will pass if actual value is true, false or nil (respectively). Given no args means the caller should satisfy an if condition (to be or not to be).

Predicates are any Ruby method that ends in a "?" and returns true or false. Given be_ followed by arbitrary_predicate (without the "?"), RSpec will match convert that into a query against the target object.

The arbitrary_predicate feature will handle any predicate prefixed with "be_an_" (e.g. be_an_instance_of), "be_a_" (e.g. be_a_kind_of) or "be_" (e.g. be_empty), letting you choose the prefix that best suits the predicate.

Examples:

expect(actual).to     be_truthy
expect(actual).to     be_falsey
expect(actual).to     be_nil
expect(actual).to     be_[arbitrary_predicate](*args)
expect(actual).not_to be_nil
expect(actual).not_to be_[arbitrary_predicate](*args)


349
350
351
# File 'lib/rspec/matchers.rb', line 349

def be(*args)
  args.empty? ? Matchers::BuiltIn::Be.new : equal(*args)
end