Sha256: 4a667c0c1925b8633e70405422b1602283be9017c2ec73b2bfb8047588521a66
Contents?: true
Size: 869 Bytes
Versions: 40
Compression:
Stored size: 869 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.to_s.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 rspec::Matchers.define :be_sorted do match do |array| sort_method = defined?(array.natural_sort) ? :natural_sort : :sort array == array.send(sort_method) end end end
Version data entries
40 entries across 40 versions & 1 rubygems