Sha256: 6ff840dc1b21effeeb38640964c5b2906ebf755ee46f8b59aeb72b86efdedd48
Contents?: true
Size: 880 Bytes
Versions: 4
Compression:
Stored size: 880 Bytes
Contents
module Spec module Matchers class SmartMatch def initialize(expected) @expected = expected end def matches?(actual) @actual = actual # Satisfy expectation here. Return false or raise an error if it's not met. if @expected =~ /^\/.*\/?$/ || @expected =~ /^".*"$/ regex_or_string = eval(@expected) if Regexp === regex_or_string (@actual =~ regex_or_string) ? true : false else @actual.index(regex_or_string) != nil end else false end end def failure_message "expected #{@actual} to smart_match #{@expected}" end def negative_failure_message "expected #{@actual} not to smart_match #{@expected}" end end def smart_match(expected) SmartMatch.new(expected) end end end
Version data entries
4 entries across 4 versions & 2 rubygems