Sha256: 4665d8f02a5a1beb6c9bc15946cef2063a02ed1b2e0169717d1c2c9df03baa90
Contents?: true
Size: 634 Bytes
Versions: 30
Compression:
Stored size: 634 Bytes
Contents
module CustomMatchers rspec = defined?(RSpec) ? RSpec : Spec rspec::Matchers.define :contain_with_wildcards do |expected_string| match do |field_value| @field_value = field_value @expected_string = expected_string regex_parts = expected_string.split('*', -1).collect { |part| Regexp.escape(part) } @field_value =~ /\A#{regex_parts.join(".*")}\z/m end failure_message_for_should do "The field's content #@field_value did not match #@expected_string" end failure_message_for_should_not do "The field's content #@field_value matches #@expected_string" end end end
Version data entries
30 entries across 30 versions & 1 rubygems