Sha256: 1d5b384889eea8493980aaa038e3b9b8737de5d3a06bc3d9de1d48c084cccc3f
Contents?: true
Size: 679 Bytes
Versions: 11
Compression:
Stored size: 679 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.to_s @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.inspect} did not match #{@expected_string.inspect}" end failure_message_for_should_not do "The field's content #{@field_value.inspect} matches #{@expected_string.inspect}" end end end
Version data entries
11 entries across 11 versions & 1 rubygems