読者です 読者をやめる 読者になる 読者になる

RSpec Mocks Receive Counts

RSpec

全然覚えられないのでここに書いたということだけ覚えましょう

## 何も指定しないと1回です
# 1回
double.should_receive(:msg).once
# 2回
double.should_receive(:msg).twice
# n回
double.should_receive(:msg).exactly(n).times
# 最低1回
double.should_receive(:msg).at_least(:once)
# 最低2回
double.should_receive(:msg).at_least(:twice)
# 最低n回
double.should_receive(:msg).at_least(n).times
# 最高1回
double.should_receive(:msg).at_most(:once)
# 最高2回
double.should_receive(:msg).at_most(:twice)
# 最高n回
double.should_receive(:msg).at_most(n).times
# 何回でも
double.should_receive(:msg).any_number_of_times