Sha256: 98203dfe9ceda19e6b5365d776cccc7ab5ca10ec4a2f71e3ea09b9861743eebe

Contents?: true

Size: 1.24 KB

Versions: 188

Compression:

Stored size: 1.24 KB

Contents

###
### $Release: 2.7.0 $
### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
###

require 'test/unit'
require 'tempfile'


module Test
  module Unit
    class TestCase

      def assert_text_equal(expected, actual, message=nil, diffopt='-u', flag_cut=true)
        if expected == actual
          assert(true)
          return
        end
        if expected[-1] != ?\n || actual[-1] != ?\n
          expected += "\n"
          actual   += "\n"
        end
        begin
          expfile = Tempfile.new(".expected.")
          expfile.write(expected); expfile.flush()
          actfile = Tempfile.new(".actual.")
          actfile.write(actual);   actfile.flush()
          diff = `diff #{diffopt} #{expfile.path} #{actfile.path}`
        ensure
          expfile.close(true) if expfile
          actfile.close(true) if actfile
        end
        # cut 1st & 2nd lines
        message = (flag_cut ? diff.gsub(/\A.*\n.*\n/, '') : diff) unless message
        #raise Test::Unit::AssertionFailedError.new(message)
        assert_block(message) { false }  # or assert(false, message)
      end

      alias assert_equal_with_diff assert_text_equal    # for compatibility
      alias assert_text_equals     assert_text_equal    # for typo

    end
  end
end

Version data entries

188 entries across 162 versions & 41 rubygems

Version Path
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/assert-text-equal.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/test/assert-text-equal.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/test/assert-text-equal.rb