From b38e71b6f2977dc6619b3317dfddf2b56e674492 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Wed, 20 Apr 2016 10:34:07 +0100 Subject: [PATCH] allow integers to be cmp regexed --- lib/matchers/matchers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matchers/matchers.rb b/lib/matchers/matchers.rb index 3162c589e..83a0d6e75 100644 --- a/lib/matchers/matchers.rb +++ b/lib/matchers/matchers.rb @@ -248,8 +248,8 @@ RSpec::Matchers.define :cmp do |first_expected| # if actual and expected are strings if expected.is_a?(String) && actual.is_a?(String) return actual.casecmp(expected) == 0 if op == :== - elsif expected.is_a?(Regexp) && actual.is_a?(String) - return !actual.match(expected).nil? + elsif expected.is_a?(Regexp) && (actual.is_a?(String) || actual.is_a?(Integer)) + return !actual.to_s.match(expected).nil? elsif expected.is_a?(String) && integer?(expected) && actual.is_a?(Integer) return actual.method(op).call(expected.to_i) elsif expected.is_a?(Integer) && integer?(actual)