File: auto_cast_date_and_time_spec.rb

package info (click to toggle)
ruby-sequel 5.97.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,188 kB
  • sloc: ruby: 123,115; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require_relative "spec_helper"

describe "auto_cast_date_and_time extension" do
  before do
    @db = Sequel.mock.extension :auto_cast_date_and_time
  end

  it "should automatically cast Time instances" do
    @db.literal(Time.local(2000)).must_equal "TIMESTAMP '2000-01-01 00:00:00.000000'"
  end

  it "should automatically cast DateTime instances" do
    @db.literal(DateTime.new(2000)).must_equal "TIMESTAMP '2000-01-01 00:00:00.000000'"
  end

  it "should automatically cast SQLTime instances" do
    @db.literal(Sequel::SQLTime.create(10, 20, 30)).must_equal "TIME '10:20:30.000000'"
  end

  it "should automatically cast Date instances" do
    @db.literal(Date.new(2000)).must_equal "DATE '2000-01-01'"
  end
end