Test that a hash contains a partial hash with RSpec

Updated . Posted . Visible to the public.

To test whether a hash includes an expected sub-hash:

expect(user.attributes).to match(hash_including('name' => 'Bruce Wayne'))
expect(User).to receive(:create!).with(hash_including('name' => 'Bruce Wayne'))
Henning Koch
Last edit
Deleted user #20
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-03-29 15:54)