1 require_relative '../spec_helper'
3 describe 'The -K command line option' do
5 @test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
8 describe 'sets __ENCODING__ and Encoding.default_external' do
9 it "to Encoding::BINARY with -Ka" do
10 ruby_exe(@test_string, options: '-Ka').should ==
11 [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
14 it "to Encoding::BINARY with -KA" do
15 ruby_exe(@test_string, options: '-KA').should ==
16 [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
19 it "to Encoding::BINARY with -Kn" do
20 ruby_exe(@test_string, options: '-Kn').should ==
21 [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
24 it "to Encoding::BINARY with -KN" do
25 ruby_exe(@test_string, options: '-KN').should ==
26 [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
29 it "to Encoding::EUC_JP with -Ke" do
30 ruby_exe(@test_string, options: '-Ke').should ==
31 [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
34 it "to Encoding::EUC_JP with -KE" do
35 ruby_exe(@test_string, options: '-KE').should ==
36 [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
39 it "to Encoding::UTF_8 with -Ku" do
40 ruby_exe(@test_string, options: '-Ku').should ==
41 [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
44 it "to Encoding::UTF_8 with -KU" do
45 ruby_exe(@test_string, options: '-KU').should ==
46 [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
49 it "to Encoding::Windows_31J with -Ks" do
50 ruby_exe(@test_string, options: '-Ks').should ==
51 [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
54 it "to Encoding::Windows_31J with -KS" do
55 ruby_exe(@test_string, options: '-KS').should ==
56 [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
60 it "ignores unknown codes" do
61 external = Encoding.find('external')
62 ruby_exe(@test_string, options: '-KZ').should ==
63 [Encoding::UTF_8.name, external.name, nil].inspect