From 149d746f655573918bf5381b102b4fdbd954c134 Mon Sep 17 00:00:00 2001 From: Jelani Woods Date: Sun, 9 Oct 2022 20:02:52 -0500 Subject: [PATCH] Improve find value specs --- spec/scripts/hash_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/scripts/hash_spec.rb b/spec/scripts/hash_spec.rb index 4630742..0e6b494 100644 --- a/spec/scripts/hash_spec.rb +++ b/spec/scripts/hash_spec.rb @@ -77,7 +77,7 @@ describe "hash_find_value.rb" do - it "prints Hash of '22 is under the key: e.', when input is '22'", points: 1 do + it "prints Hash of '0 is under the key: g.', when input is '0'", points: 1 do # Un-require hash_find_value.rb hash_find_value = $".select{|r| r.include? 'hash_find_value.rb'} $".delete(hash_find_value.first) @@ -85,19 +85,19 @@ allow_any_instance_of(Object).to receive(:gets).and_return("22\n") allow_any_instance_of(Kernel).to receive(:rand).and_return(22) - response = /22 is under the key: e/i + response = /0 is under the key: g/i # expect { require_relative("../../hash_find_value") }.to output(response).to_stdout output = with_captured_stdout { require_relative('../../hash_find_value')} output = "empty" if output.empty? expect(output.match?(response)).to be(true), - "Expected output to be 'Enter an integer to find:\\n22 is under the key: e', but was #{output}." + "Expected output to be:\n'Enter an integer to find:\n0 is under the key: g', but was:\n #{output}." end end describe "hash_find_value.rb" do - it "prints Hash of '32 is under the key: e.', when input is '32'", points: 1 do + it "prints Hash of '300 is under the key: c.', when input is '300'", points: 1 do # Un-require hash_find_value.rb hash_find_value = $".select{|r| r.include? 'hash_find_value.rb'} $".delete(hash_find_value.first) @@ -105,13 +105,13 @@ allow_any_instance_of(Object).to receive(:gets).and_return("32\n") allow_any_instance_of(Kernel).to receive(:rand).and_return(32) - response = /32 is under the key: e/i + response = /300 is under the key: c/i # expect { require_relative("../../hash_find_value") }.to output(response).to_stdout output = with_captured_stdout { require_relative('../../hash_find_value')} output = "empty" if output.empty? expect(output.match?(response)).to be(true), - "Expected output to be 'Enter an integer to find:\\n32 is under the key: e', but was #{output}." + "Expected output to be 'Enter an integer to find:\\n300 is under the key: c', but was #{output}." end end