Skip to content

Commit 3f3c7be

Browse files
committed
Spec titling for MySQL version under test
1 parent 0fedea1 commit 3f3c7be

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

spec/mysql2/error_spec.rb

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,37 @@
5050
end
5151

5252
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
5454

5555
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
5757

5858
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
6068
end
6169

6270
it_behaves_like "mysql2 error"
6371

6472
unless RUBY_VERSION =~ /1.8/
6573
mysql_ver = Mysql2::Client.new(DatabaseCredentials['root']).server_info[:id]
6674
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
7179
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
7684
end
7785
end
7886
end

0 commit comments

Comments
 (0)