Sha256: 9c407bb3a57b1aaca6d15a59f084e34125e7b5c870dd9c11ad7fe50d292b7b33

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env rspec
# encoding: utf-8

require_relative '../helpers'

require 'pg'


describe PG::TypeMap do
	let!(:tm){ PG::TypeMap.new }

	it "should respond to fit_to_query" do
		expect{ tm.fit_to_query( [123] ) }.to raise_error(NotImplementedError, /not suitable to map query params/)
	end

	it "should respond to fit_to_result" do
		res = @conn.exec( "SELECT 1" )
		expect{ tm.fit_to_result( res ) }.to raise_error(NotImplementedError, /not suitable to map result values/)
	end

	it "should check params type" do
		expect{ tm.fit_to_query( :invalid ) }.to raise_error(TypeError, /expected Array/)
	end

	it "should check result class" do
		expect{ tm.fit_to_result( :invalid ) }.to raise_error(TypeError, /expected kind of PG::Result/)
	end

	it "should raise an error when used for param type casts" do
		expect{
			@conn.exec_params( "SELECT $1", [5], 0, tm )
		}.to raise_error(NotImplementedError, /not suitable to map query params/)
	end

	it "should raise an error when used for result type casts" do
		res = @conn.exec( "SELECT 1" )
		expect{ res.map_types!(tm) }.to raise_error(NotImplementedError, /not suitable to map result values/)
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pg-0.18.0.pre20141117110243-x86-mingw32 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141117110243-x64-mingw32 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141117110243 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141017160319-x86-mingw32 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141017160319-x64-mingw32 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141017160319 spec/pg/type_map_spec.rb
pg-0.18.0.pre20141017155815 spec/pg/type_map_spec.rb