This page looks best with JavaScript enabled
【RSpec】たまに使うちょっとトリッキーなマッチャ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# subjectがArrayクラスであることを検証する
it { is_expected.to be_kind_of Array }
# 全要素がHashであることを検証する
it { is_expected.to all(be_kind_of Hash) }
# ハッシュの中身について検証する
it '各パラメータの値' do
expect(Article.first.attributes.deep_symbolize_keys).to match(
title: be_a(String),
position: be_an(Integer),
body: start_with('こんにちは')
)
end
|