RSpec partial match against a nested hash

前端 未结 2 993
梦如初夏
梦如初夏 2021-02-05 05:02

I\'ve got a JSON structure that I\'d like to match a single nested element in, while ignoring other data. The JSON looks like this (minimally):

{
  \"employee\":         


        
2条回答
  •  太阳男子
    2021-02-05 05:48

    With rspec 3.6.0, this works for me:

    expect(subject).to match(a_hash_including(key: value))
    

提交回复
热议问题