From 74b888584b88cf3d12372b7ea80d722e2e56b897 Mon Sep 17 00:00:00 2001 From: Yuri Smirnov Date: Sat, 26 Oct 2024 13:02:46 +0300 Subject: [PATCH] rework specs --- spec/umbrellio_utils/checks_spec.rb | 35 +++++++++++++---------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/spec/umbrellio_utils/checks_spec.rb b/spec/umbrellio_utils/checks_spec.rb index 76f8c28..256830d 100644 --- a/spec/umbrellio_utils/checks_spec.rb +++ b/spec/umbrellio_utils/checks_spec.rb @@ -4,26 +4,21 @@ describe "#valid_email?" do subject(:result) { described_class.valid_email?(input) } - let(:input) { "user@example.com" } - - it { is_expected.to eq(true) } - - context "invalid input" do - let(:input) { "invalid" } - - it { is_expected.to eq(false) } - end - - context "input with subdomains and digits" do - let(:input) { "user@one.two42.com" } - - it { is_expected.to eq(true) } - end - - context "non-string input" do - let(:input) { 123 } - - it { is_expected.to eq(false) } + expectations = { + "user@example.com" => true, + "user@one.two42.com" => true, + "invalid" => false, + 123 => false, + nil => false, + } + + expectations.each do |input, expected_result| + context "with input #{input.inspect} should return #{expected_result.inspect}" do + let(:input) { input } + let(:expected_result) { expected_result } + + it { is_expected.to eq(expected_result) } + end end end end