class SQLite3QuotingTest

Public Instance Methods

setup() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 8
def setup
  @conn = ActiveRecord::Base.connection
  @initial_represent_boolean_as_integer = ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer
end
teardown() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 13
def teardown
  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = @initial_represent_boolean_as_integer
end
test_quoted_time_returns_date_qualified_time() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 52
def test_quoted_time_returns_date_qualified_time
  value = ::Time.utc(2000, 1, 1, 12, 30, 0, 999999)
  type = ActiveRecord::Type::Time.new

  assert_equal "'2000-01-01 12:30:00.999999'", @conn.quote(type.serialize(value))
end
test_quoting_binary_strings() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 45
def test_quoting_binary_strings
  value = "hello".encode("ascii-8bit")
  type = ActiveRecord::Type::String.new

  assert_equal "'hello'", @conn.quote(type.serialize(value))
end
test_type_cast_bigdecimal() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 40
def test_type_cast_bigdecimal
  bd = BigDecimal.new "10.0"
  assert_equal bd.to_f, @conn.type_cast(bd)
end
test_type_cast_binary_encoding_without_logger() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 17
def test_type_cast_binary_encoding_without_logger
  @conn.extend(Module.new { def logger; end })
  binary = SecureRandom.hex
  expected = binary.dup.encode!(Encoding::UTF_8)
  assert_equal expected, @conn.type_cast(binary)
end
test_type_cast_false() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 32
def test_type_cast_false
  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = false
  assert_equal "f", @conn.type_cast(false)

  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true
  assert_equal 0, @conn.type_cast(false)
end
test_type_cast_true() click to toggle source
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 24
def test_type_cast_true
  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = false
  assert_equal "t", @conn.type_cast(true)

  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true
  assert_equal 1, @conn.type_cast(true)
end