summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/b_spec.rb
blob: 4b1fafff11780656f420f15bfa1cea40b5f0f150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- encoding: utf-8 -*-
# frozen_string_literal: false
require_relative '../../spec_helper'

describe "String#b" do
  it "returns a binary encoded string" do
    "Hello".b.should == "Hello".force_encoding(Encoding::BINARY)
    "こんちには".b.should == "こんちには".force_encoding(Encoding::BINARY)
  end

  it "returns new string without modifying self" do
    str = "こんちには"
    str.b.should_not equal(str)
    str.should == "こんちには"
  end
end