File: date_spec.rb

package info (click to toggle)
ruby-dataobjects-postgres 0.10.17-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 344 kB
  • sloc: ansic: 1,509; ruby: 511; sh: 60; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 917 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# encoding: utf-8

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
require 'data_objects/spec/shared/typecast/date_spec'

describe 'DataObjects::Postgres with Date' do
  it_should_behave_like 'supporting Date'
  it_should_behave_like 'supporting Date autocasting'

  describe 'exotic dates' do

    before do
      @connection = DataObjects::Connection.new(CONFIG.uri)
      @connection.create_command("INSERT INTO widgets (release_date) VALUES ('0001-01-01')").execute_non_query

      @command = @connection.create_command("SELECT release_date FROM widgets WHERE release_date = '0001-01-01'")
      @reader = @command.execute_reader
      @reader.next!
      @values = @reader.values
    end

    after do
      @reader.close
      @connection.close
    end

    it 'should return the number of created rows' do
      @values.first.should == Date.civil(1, 1, 1)
    end

  end

end