1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/command_line/dash_upper_k_spec.rb
eregon 2dca35b9b1 Update to ruby/spec@007e908
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-27 16:22:21 +00:00

65 lines
2.2 KiB
Ruby

require_relative '../spec_helper'
describe 'The -K command line option' do
before :each do
@test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
end
describe 'sets __ENCODING__ and Encoding.default_external' do
it "to Encoding::ASCII_8BIT with -Ka" do
ruby_exe(@test_string, options: '-Ka').should ==
[Encoding::ASCII_8BIT.name, Encoding::ASCII_8BIT.name, nil].inspect
end
it "to Encoding::ASCII_8BIT with -KA" do
ruby_exe(@test_string, options: '-KA').should ==
[Encoding::ASCII_8BIT.name, Encoding::ASCII_8BIT.name, nil].inspect
end
it "to Encoding::ASCII_8BIT with -Kn" do
ruby_exe(@test_string, options: '-Kn').should ==
[Encoding::ASCII_8BIT.name, Encoding::ASCII_8BIT.name, nil].inspect
end
it "to Encoding::ASCII_8BIT with -KN" do
ruby_exe(@test_string, options: '-KN').should ==
[Encoding::ASCII_8BIT.name, Encoding::ASCII_8BIT.name, nil].inspect
end
it "to Encoding::EUC_JP with -Ke" do
ruby_exe(@test_string, options: '-Ke').should ==
[Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
end
it "to Encoding::EUC_JP with -KE" do
ruby_exe(@test_string, options: '-KE').should ==
[Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
end
it "to Encoding::UTF_8 with -Ku" do
ruby_exe(@test_string, options: '-Ku').should ==
[Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
end
it "to Encoding::UTF_8 with -KU" do
ruby_exe(@test_string, options: '-KU').should ==
[Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
end
it "to Encoding::Windows_31J with -Ks" do
ruby_exe(@test_string, options: '-Ks').should ==
[Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
end
it "to Encoding::Windows_31J with -KS" do
ruby_exe(@test_string, options: '-KS').should ==
[Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
end
end
it "ignores unknown codes" do
locale = Encoding.find('locale')
ruby_exe(@test_string, options: '-KZ').should ==
[Encoding::UTF_8.name, locale.name, nil].inspect
end
end