aboutsummaryrefslogblamecommitdiffstats
path: root/spec/matchers/be_like.rb
blob: c9d4d4b979235d8f817ab9c746f70ae9d1355ad8 (plain) (tree)
1
2
3
4
5
6
7
8
9



                            
 

                                                                        
       
 
                       
                                                      
       
 
                                
                                                        
       
 

                        
   
module BeLikeMatcher
  class BeLike
    def initialize(expected)
      @expected = expected
    end

    def matches?(actual)
      @actual = actual
      @expected.gsub(/\s+/, ' ').strip == @actual.gsub(/\s+/, ' ').strip
    end

    def failure_message
      "expected\n#{@actual}\nto be like\n#{@expected}"
    end

    def negative_failure_message
      "expected\n#{@actual}\nto be unlike\n#{@expected}"
    end
  end

  def be_like(expected)
    BeLike.new(expected)
  end
end