Sha256: f0790162c7f8b43c269bce1d2af5e1cbdc0ee7518c997080853c85c8fffcf572

Contents?: true

Size: 959 Bytes

Versions: 5

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

require "cases/helper"
require "models/binary"

class BinaryTest < ActiveRecord::TestCase
  FIXTURES = %w(flowers.jpg example.log test.txt)

  def test_mixed_encoding
    str = +"\x80"
    str.force_encoding("ASCII-8BIT")

    binary = Binary.new name: "いただきます!", data: str
    binary.save!
    binary.reload
    assert_equal str, binary.data

    name = binary.name
    assert_equal "いただきます!", name
  end

  def test_load_save
    Binary.delete_all

    FIXTURES.each do |filename|
      data = File.read(ASSETS_ROOT + "/#{filename}")
      data.force_encoding("ASCII-8BIT")
      data.freeze

      bin = Binary.new(data: data)
      assert_equal data, bin.data, "Newly assigned data differs from original"

      bin.save!
      assert_equal data, bin.data, "Data differs from original after save"

      assert_equal data, bin.reload.data, "Reloaded data differs from original"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ibm_db-5.5.0 test/cases/binary_test.rb
ibm_db-5.4.1 test/cases/binary_test.rb
ibm_db-5.4.0 test/cases/binary_test.rb
ibm_db-5.3.2 test/cases/binary_test.rb
ibm_db-5.3.1 test/cases/binary_test.rb