Skip to content

Instantly share code, notes, and snippets.

@maxy
Forked from isseium/gist:5822504
Created October 21, 2020 23:45
Show Gist options
  • Save maxy/9edb5f84df47abc998a4c1ab404645f4 to your computer and use it in GitHub Desktop.
Save maxy/9edb5f84df47abc998a4c1ab404645f4 to your computer and use it in GitHub Desktop.
rspec の include で hash 構造をチェックするテスト
describe "Rspec include test" do
it "include" do
hash = {:a => 'A', :b => 'B', :c => { :ca => 'CA' }}
expect(hash).to include(:c => {:ca => 'CA'}); #
expect(hash).to include(:a => 'A', :c => {:ca => 'CA'}); # ならべてもいいっぽい
expect(hash).to_not include(:ca => 'CA'); # ちゃんと構造みてくれる
expect(hash).to include(:a); # キーだけでもOK
expect(hash).to_not include(:d); # キーだけでもOK
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment