From 5e1283c181d9f551b0cc2f47a6ffb513dc768a37 Mon Sep 17 00:00:00 2001 From: mjrode Date: Mon, 25 Apr 2016 13:38:35 -0400 Subject: [PATCH] Added tests for MultipleChoiceExpectation. Test when parameter is present but is nil --- test/multiple_choice_expectation_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/multiple_choice_expectation_test.rb b/test/multiple_choice_expectation_test.rb index abc0acb..46acf3f 100644 --- a/test/multiple_choice_expectation_test.rb +++ b/test/multiple_choice_expectation_test.rb @@ -26,6 +26,14 @@ class MultipleChoiceExpectation < Minitest::Test end end + should "parameters hash should pass when the second parameter is not nil" do + ex = MultipleChoiceExpectation.new([:name, :age, :id]) + params = {age: 12} + assert_nothing_raised do + ex.verify(params) + end + end + should "parameters hash should pass even if some parameters are missing" do ex = MultipleChoiceExpectation.new([:name, :age, :id]) params = {name: "Michael"} @@ -42,4 +50,12 @@ class MultipleChoiceExpectation < Minitest::Test end end + should "parameters hash should fail if parameter is present and nil" do + ex = MultipleChoiceExpectation.new([:name, :age, :id]) + params = {age: nil} + assert_raises (MissingParameterError) do + ex.verify(params) + end + end + end