Created
November 12, 2009 07:08
-
-
Save macks/232675 to your computer and use it in GitHub Desktop.
Spec for DataObjects with encoded string support. (will be failed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/data_objects/lib/data_objects/spec/encoding_spec.rb b/data_objects/lib/data_objects/spec/encoding_spec.rb | |
index 4b14e17..de3a974 100644 | |
--- a/data_objects/lib/data_objects/spec/encoding_spec.rb | |
+++ b/data_objects/lib/data_objects/spec/encoding_spec.rb | |
@@ -40,4 +40,43 @@ share_examples_for 'a driver supporting encodings' do | |
end | |
+ | |
+ if defined?(::Encoding) | |
+ | |
+ describe 'with encoded string support' do | |
+ | |
+ include DataObjectsSpecHelpers | |
+ | |
+ before :all do | |
+ setup_test_environment | |
+ end | |
+ | |
+ describe 'reading a String' do | |
+ before do | |
+ @reader = @connection.create_command("SELECT name FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!') | |
+ @reader.next! | |
+ @values = @reader.values | |
+ end | |
+ | |
+ it 'should return UTF-8 encoded String' do | |
+ @values.first.should be_kind_of(String) | |
+ @values.first.encoding.name.should == 'UTF-8' | |
+ end | |
+ end | |
+ | |
+ describe 'reading a ByteArray' do | |
+ before do | |
+ @reader = @connection.create_command("SELECT ad_image FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!') | |
+ @reader.next! | |
+ @values = @reader.values | |
+ end | |
+ | |
+ it 'should return ASCII-8BIT encoded ByteArray' do | |
+ @values.first.should be_kind_of(::Extlib::ByteArray) | |
+ @values.first.encoding.name.should == 'ASCII-8BIT' | |
+ end | |
+ end | |
+ end | |
+ end | |
+ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment