Method: RSpec::Matchers#have_attributes

Defined in:
lib/rspec/matchers.rb

#have_attributes(expected) ⇒ Object Also known as: an_object_having_attributes, having_attributes

Note:

It will fail if actual doesn't respond to any of the expected attributes.

Passes if actual's attribute values match the expected attributes hash. This works no matter how you define your attribute readers.

Examples:

Person = Struct.new(:name, :age)
person = Person.new("Bob", 32)

expect(person).to have_attributes(:name => "Bob", :age => 32)
expect(person).to have_attributes(:name => a_string_starting_with("B"), :age => (a_value > 30) )
expect(person).to have_attributes(:color => "red")


616
617
618
# File 'lib/rspec/matchers.rb', line 616

def have_attributes(expected)
  BuiltIn::HaveAttributes.new(expected)
end