Sha256: 9bde92b06fecfc717bbc1abed9bce1100952e5c4ec3b72ec7aef15978e6863a7
Contents?: true
Size: 639 Bytes
Versions: 1
Compression:
Stored size: 639 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/ 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spreewald-0.5.3 | lib/spreewald_support/custom_matchers.rb |