From 7fc3a686100da68f415ede8bce091ba87bb551ae Mon Sep 17 00:00:00 2001 From: Matthias Kalb Date: Tue, 5 Jan 2016 14:22:25 +0100 Subject: [PATCH] fixed valid? method to return boolean type --- lib/bic_validation/bic.rb | 6 +++--- spec/bic_validation/bic_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bic_validation/bic.rb b/lib/bic_validation/bic.rb index 38b7a8d..84e17d6 100644 --- a/lib/bic_validation/bic.rb +++ b/lib/bic_validation/bic.rb @@ -13,16 +13,16 @@ def of_valid_length? end def of_valid_format? - @code =~ format + !!(@code =~ format) end def has_valid_country_code? - country_codes.include? country + country_codes.include?(country) end def has_valid_location_code? # WTF? http://de.wikipedia.org/wiki/ISO_9362 - location[0] =~ /[^01]/ && location[1] =~ /[^O]/ + !!(location[0] =~ /[^01]/ && location[1] =~ /[^O]/) end def known? diff --git a/spec/bic_validation/bic_spec.rb b/spec/bic_validation/bic_spec.rb index b9f6753..cba1d15 100644 --- a/spec/bic_validation/bic_spec.rb +++ b/spec/bic_validation/bic_spec.rb @@ -25,7 +25,7 @@ module BicValidation subject { @bic } describe '#valid?' do - it { should be_valid } + it { expect([true, false]).to include(subject.valid?) } end describe '#known?' do @@ -55,7 +55,7 @@ module BicValidation subject { @bic } describe '#valid?' do - it { should be_valid } + it { expect([true, false]).to include(subject.valid?) } end describe '#known?' do