Skip to content

Instantly share code, notes, and snippets.

@isseium
Last active September 17, 2021 03:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save isseium/5822504 to your computer and use it in GitHub Desktop.
Save isseium/5822504 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