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.
349 350 351 |
# File 'lib/rspec/matchers.rb', line 349 def be(*args) args.empty? ? Matchers::BuiltIn::Be.new : equal(*args) end |