Sha256: f98435df1f6fd9bbd60843027ffd5458ea4ab39ce2acb32b1d05dbc94f81b261

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

# backtick_javascript: true

require 'spec_helper'

describe "Runtime String helpers" do
  context 'Opal.enc' do
    it 'sets the encoding boxing literal strings' do
      -> {
        `Opal.enc("foo", 'UTF-8')`
      }.should_not raise_error
    end
  end

  context 'Opal.set_encoding' do
    it 'sets the encoding for boxed strings' do
      expect(`Opal.set_encoding(new String("foo"), 'UTF-8')`.encoding).to eq(Encoding::UTF_8)
      expect(`Opal.set_encoding("foo".$dup(), 'UTF-8')`.encoding).to eq(Encoding::UTF_8)
      expect(`Opal.set_encoding("foo".$clone(), 'UTF-8')`.encoding).to eq(Encoding::UTF_8)
    end

    it 'raises FrozenError when provided a literal' do
      -> {
        `Opal.set_encoding("foo", 'UTF-8')`
      }.should raise_error(FrozenError)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/opal/core/runtime/string_spec.rb
opal-1.8.2 spec/opal/core/runtime/string_spec.rb
opal-1.8.1 spec/opal/core/runtime/string_spec.rb
opal-1.8.0 spec/opal/core/runtime/string_spec.rb
opal-1.8.0.beta1 spec/opal/core/runtime/string_spec.rb
opal-1.8.0.alpha1 spec/opal/core/runtime/string_spec.rb