rspec で例外が発生するかどうかをテストしたい
以下のような感じでテスト可能
it '100回繰り返すと99回目で例外が発生する' do proc { 100.times { |time| get :somewhere, { id: time } } }.should raise_error(UserDefinedException) { |exception| exception.message.should eq("検証すべき業務エラーです。") } end
以下のような感じでテスト可能
it '100回繰り返すと99回目で例外が発生する' do proc { 100.times { |time| get :somewhere, { id: time } } }.should raise_error(UserDefinedException) { |exception| exception.message.should eq("検証すべき業務エラーです。") } end