aboutsummaryrefslogtreecommitdiffstats
path: root/spec/rubyspec/core/argf/set_encoding_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/core/argf/set_encoding_spec.rb')
-rw-r--r--spec/rubyspec/core/argf/set_encoding_spec.rb31
1 files changed, 22 insertions, 9 deletions
diff --git a/spec/rubyspec/core/argf/set_encoding_spec.rb b/spec/rubyspec/core/argf/set_encoding_spec.rb
index 16d49a8c44..f6ec74ded1 100644
--- a/spec/rubyspec/core/argf/set_encoding_spec.rb
+++ b/spec/rubyspec/core/argf/set_encoding_spec.rb
@@ -1,28 +1,41 @@
require File.expand_path('../../../spec_helper', __FILE__)
-# These specs need to be run to a separate process as there is no way to reset ARGF encoding
describe "ARGF.set_encoding" do
before :each do
@file = fixture __FILE__, "file1.txt"
end
it "sets the external encoding when passed an encoding instance" do
- enc = ruby_exe('ARGF.set_encoding(Encoding::UTF_8); print ARGF.gets.encoding', args: [@file])
- enc.should == "UTF-8"
+ argf [@file] do
+ @argf.set_encoding(Encoding::US_ASCII)
+ @argf.external_encoding.should == Encoding::US_ASCII
+ @argf.gets.encoding.should == Encoding::US_ASCII
+ end
end
it "sets the external encoding when passed an encoding name" do
- enc = ruby_exe('ARGF.set_encoding("utf-8"); print ARGF.gets.encoding', args: [@file])
- enc.should == "UTF-8"
+ argf [@file] do
+ @argf.set_encoding("us-ascii")
+ @argf.external_encoding.should == Encoding::US_ASCII
+ @argf.gets.encoding.should == Encoding::US_ASCII
+ end
end
it "sets the external, internal encoding when passed two encoding instances" do
- enc = ruby_exe('ARGF.set_encoding(Encoding::UTF_8, Encoding::EUC_JP); print ARGF.gets.encoding', args: [@file])
- enc.should == "EUC-JP"
+ argf [@file] do
+ @argf.set_encoding(Encoding::US_ASCII, Encoding::EUC_JP)
+ @argf.external_encoding.should == Encoding::US_ASCII
+ @argf.internal_encoding.should == Encoding::EUC_JP
+ @argf.gets.encoding.should == Encoding::EUC_JP
+ end
end
it "sets the external, internal encoding when passed 'ext:int' String" do
- enc = ruby_exe('ARGF.set_encoding("utf-8:euc-jp"); print ARGF.gets.encoding', args: [@file])
- enc.should == "EUC-JP"
+ argf [@file] do
+ @argf.set_encoding("us-ascii:euc-jp")
+ @argf.external_encoding.should == Encoding::US_ASCII
+ @argf.internal_encoding.should == Encoding::EUC_JP
+ @argf.gets.encoding.should == Encoding::EUC_JP
+ end
end
end