summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared/each_char_without_block.rb
blob: 397100ce0eb389f195e954053ed0b926a7de72aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- encoding: utf-8 -*-
require_relative '../../../spec_helper'
require_relative '../fixtures/classes'

describe :string_each_char_without_block, shared: true do
  describe "when no block is given" do
    it "returns an enumerator" do
      enum = "hello".send(@method)
      enum.should be_an_instance_of(Enumerator)
      enum.to_a.should == ['h', 'e', 'l', 'l', 'o']
    end

    describe "returned enumerator" do
      describe "size" do
        it "should return the size of the string" do
          str = "hello"
          str.send(@method).size.should == str.size
          str = "ola"
          str.send(@method).size.should == str.size
          str = "\303\207\342\210\202\303\251\306\222g"
          str.send(@method).size.should == str.size
        end
      end
    end
  end
end