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

                            
                                                 
       
 
                        

                                             
       
 
                       
                                                      
       
 
                                
                                                        

       
 


                        
   
module Matchers
  class BeLike
    def initialize(expected)
      @expected = expected.gsub(/\s+/, ' ').strip
    end

    def matches?(actual)
      @actual = actual.gsub(/\s+/, ' ').strip
      @expected == @actual
    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