Sha256: d604c74db4707de03ed112627f5b3bba39457edd5ae62507b0df235ab0d52083

Contents?: true

Size: 1.7 KB

Versions: 52

Compression:

Stored size: 1.7 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

with_feature :encoding do
  describe "Encoding.default_external" do
    before(:all) do
      @original_encoding = Encoding.default_external
    end

    after(:all) do
      Encoding.default_external = @original_encoding
    end

    it "returns an Encoding object" do
      Encoding.default_external.should be_an_instance_of(Encoding)
    end

    it "returns the default external encoding" do
      Encoding.default_external = Encoding::UTF_8
      Encoding.default_external.should == Encoding::UTF_8
    end
  end

  describe "Encoding.default_external=" do
    before(:all) do
      @original_encoding = Encoding.default_external
    end

    after(:all) do
      Encoding.default_external = @original_encoding
    end

    it "sets the default external encoding" do
      Encoding.default_external = Encoding::UTF_8
      Encoding.default_external.should == Encoding::UTF_8
    end

    it "can accept a name of an encoding as a String" do
      Encoding.default_external = 'Shift_JIS'
      Encoding.default_external.should == Encoding::SHIFT_JIS
    end

    it "calls #to_s on arguments that are neither Strings nor Encodings" do
      string = mock('string')
      string.should_receive(:to_str).twice.and_return('US-ASCII')
      Encoding.default_external = string
      Encoding.default_external.should == Encoding::ASCII
    end

    it "raises a TypeError unless the argument is an Encoding or convertible to a String" do
      lambda { Encoding.default_external = [] }.should raise_error(TypeError)
    end

    it "raises an ArgumentError if the argument is nil" do
      lambda { Encoding.default_external = nil }.should raise_error(ArgumentError)
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/encoding/default_external_spec.rb