Sha256: add0d7171905a15c9fdc05165cbd25d231083bb6456ee99c55b8fd4018b81c53

Contents?: true

Size: 1.91 KB

Versions: 12

Compression:

Stored size: 1.91 KB

Contents

# encoding: utf-8

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

describe 'DataObjects::Oracle with Time' do
  behaves_like 'supporting Time'
end

describe 'DataObjects::Oracle with Time' do

  setup_test_environment

  before do
    @connection = DataObjects::Connection.new(CONFIG.uri)
  end

  after do
    @connection.close
  end

  describe 'reading a Time' do

    describe 'with automatic typecasting' do

      before  do
        @reader = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
        @reader.next!
        @values = @reader.values
      end

      after do
        @reader.close
      end

      it 'should return the correctly typed result' do
        @values.first.should.be.kind_of(Time)
      end

      it 'should return the correct result' do
        @values.first.should == Time.local(2008, 2, 14, 00, 31, 12)
      end

    end

  end

end

describe 'DataObjects::Oracle session time zone' do

  after do
    @connection.close
  end

  describe 'set from environment' do

    before do
      pending "set TZ environment shell variable before running this test" unless ENV['TZ']
      @connection = DataObjects::Connection.new(CONFIG.uri)
    end

    it "should have time zone from environment" do
      @reader = @connection.create_command("SELECT sessiontimezone FROM dual").execute_reader
      @reader.next!
      @reader.values.first.should == ENV['TZ']
    end

  end

  describe "set with connection string option" do

    before do
      @connection = DataObjects::Connection.new(CONFIG.uri+"?time_zone=CET")
    end

    it "should have time zone from connection option" do
      @reader = @connection.create_command("SELECT sessiontimezone FROM dual").execute_reader
      @reader.next!
      @reader.values.first.should == 'CET'
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
do_oracle-0.10.3 spec/typecast/time_spec.rb
do_oracle-0.10.3-x86-mswin32-60 spec/typecast/time_spec.rb
do_oracle-0.10.3-x86-mingw32 spec/typecast/time_spec.rb
do_oracle-0.10.3-java spec/typecast/time_spec.rb
do_oracle-0.10.2-java spec/typecast/time_spec.rb
do_oracle-0.10.2 spec/typecast/time_spec.rb
do_oracle-0.10.2-x86-mswin32-60 spec/typecast/time_spec.rb
do_oracle-0.10.2-x86-mingw32 spec/typecast/time_spec.rb
do_oracle-0.10.1 spec/typecast/time_spec.rb
do_oracle-0.10.1-x86-mswin32-60 spec/typecast/time_spec.rb
do_oracle-0.10.1-x86-mingw32 spec/typecast/time_spec.rb
do_oracle-0.10.1-java spec/typecast/time_spec.rb