下記のrubyプログラムのif文の中を、aが2以上ならばraiseで"エラー"を、そうでなければ変数msgに"エラーではない"という文字列を代入して、minitestのassertを使ってテストコードを書きたいのですがうまくいきません。どのようにしたら良いでしょうか?
cul.rb⇩
Ruby
1 2class Keisan 3 4a = 1 5 6 def self.cul(a) 7 if a > 2 8 raise 'エラー' 9 else 10 msg = "エラーではない" 11 end 12 end 13 14end
test_cul.rb⇩
class TestCul < MiniTest::Test def test_cul(a) Keisan.cul(a) assert_raise_with_message(RuntimeError, "エラー") do raise ArgumentError, "エラー" end end end

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/03 03:26
退会済みユーザー
2016/11/03 03:29
2017/01/08 05:00