|
50 | 50 | end
|
51 | 51 |
|
52 | 52 | subject { error.message.encoding }
|
53 |
| - it { should eql(err_enc) } |
| 53 | + it "#message should transcode from #{db_enc.inspect} to #{err_enc}" do should eql(err_enc) end |
54 | 54 |
|
55 | 55 | subject { error.error.encoding }
|
56 |
| - it { should eql(err_enc) } |
| 56 | + it "#error should transcode from #{db_enc.inspect} to #{err_enc}" do should eql(err_enc) end |
57 | 57 |
|
58 | 58 | subject { error.sql_state.encoding }
|
59 |
| - it { should eql(err_enc) } |
| 59 | + it "#sql_state should transcode from #{db_enc.inspect} to #{err_enc}" do should eql(err_enc) end |
| 60 | + end |
| 61 | + |
| 62 | + shared_examples "mysql2 error encoding (MySQL < 5.5)" do |db_enc, def_enc, err_enc| |
| 63 | + include_examples "mysql2 error encoding", db_enc, def_enc, err_enc |
| 64 | + end |
| 65 | + |
| 66 | + shared_examples "mysql2 error encoding (MySQL >= 5.5)" do |db_enc, def_enc, err_enc| |
| 67 | + include_examples "mysql2 error encoding", db_enc, def_enc, err_enc |
60 | 68 | end
|
61 | 69 |
|
62 | 70 | it_behaves_like "mysql2 error"
|
63 | 71 |
|
64 | 72 | unless RUBY_VERSION =~ /1.8/
|
65 | 73 | mysql_ver = Mysql2::Client.new(DatabaseCredentials['root']).server_info[:id]
|
66 | 74 | if mysql_ver < 50505
|
67 |
| - it_behaves_like "mysql2 error encoding", nil, nil, Encoding::ASCII_8BIT |
68 |
| - it_behaves_like "mysql2 error encoding", 'utf8', Encoding::UTF_8, Encoding::ASCII_8BIT |
69 |
| - it_behaves_like "mysql2 error encoding", 'big5', Encoding::Big5, Encoding::ASCII_8BIT |
70 |
| - it_behaves_like "mysql2 error encoding", 'big5', Encoding::US_ASCII, Encoding::ASCII_8BIT |
| 75 | + it_behaves_like "mysql2 error encoding (MySQL < 5.5)", nil, nil, Encoding::ASCII_8BIT |
| 76 | + it_behaves_like "mysql2 error encoding (MySQL < 5.5)", 'utf8', Encoding::UTF_8, Encoding::ASCII_8BIT |
| 77 | + it_behaves_like "mysql2 error encoding (MySQL < 5.5)", 'big5', Encoding::Big5, Encoding::ASCII_8BIT |
| 78 | + it_behaves_like "mysql2 error encoding (MySQL < 5.5)", 'big5', Encoding::US_ASCII, Encoding::ASCII_8BIT |
71 | 79 | else
|
72 |
| - it_behaves_like "mysql2 error encoding", nil, nil, Encoding::UTF_8 |
73 |
| - it_behaves_like "mysql2 error encoding", 'utf8', Encoding::UTF_8, Encoding::UTF_8 |
74 |
| - it_behaves_like "mysql2 error encoding", 'big5', Encoding::Big5, Encoding::Big5 |
75 |
| - it_behaves_like "mysql2 error encoding", 'big5', Encoding::US_ASCII, Encoding::US_ASCII |
| 80 | + it_behaves_like "mysql2 error encoding (MySQL >= 5.5)", nil, nil, Encoding::UTF_8 |
| 81 | + it_behaves_like "mysql2 error encoding (MySQL >= 5.5)", 'utf8', Encoding::UTF_8, Encoding::UTF_8 |
| 82 | + it_behaves_like "mysql2 error encoding (MySQL >= 5.5)", 'big5', Encoding::Big5, Encoding::Big5 |
| 83 | + it_behaves_like "mysql2 error encoding (MySQL >= 5.5)", 'big5', Encoding::US_ASCII, Encoding::US_ASCII |
76 | 84 | end
|
77 | 85 | end
|
78 | 86 | end
|
0 commit comments