summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/chars_spec.rb
blob: ee854305745bcc2d724d090fe55b928962800ec8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require_relative "../../spec_helper"
require_relative 'shared/chars'

describe "String#chars" do
  it_behaves_like :string_chars, :chars

  it "returns an array when no block given" do
    "hello".chars.should == ['h', 'e', 'l', 'l', 'o']
  end

  it "returns Strings in the same encoding as self" do
    "hello".encode("US-ASCII").chars.each do |c|
      c.encoding.should == Encoding::US_ASCII
    end
  end
end