Sha256: 4ee6f22096e6194ad7686f4ef3a431b0fbad32516dfea4c7c6bd337b11bc24bd

Contents?: true

Size: 1.37 KB

Versions: 56

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/core_ext/array/list'

RSpec.describe Array do
  context '#to_list' do
    it 'handles single value' do
      input = %w(test)

      expect(input.to_list).to eq '"test"'
    end

    it 'handles two values' do
      input = %w(test1 test2)

      expect(input.to_list).to eq '"test1", "test2"'
    end

    it 'converts array to a list of values' do
      input = %w(test1 test2 test3)

      expect(input.to_list).to eq '"test1", "test2", "test3"'
    end

    it 'converts array to a list of values' do
      input = %w(test1 test2 test3 test4)

      expect(input.to_list).to eq '"test1", "test2", "test3", "test4"'
    end

    it 'supports to change the last separator' do
      input = %w(test1 test2 test3)

      expect(input.to_list(last_separator: ' or ')).to eq '"test1", "test2" or "test3"'
    end

    it 'supports to change the separator' do
      input = %w(test1 test2 test3)

      expect(input.to_list(separator: ':')).to eq '"test1":"test2":"test3"'
    end

    it 'change multiple things' do
      input = %w(test1 test2 test3)

      expect(input.to_list(around: '', separator: ':')).to eq 'test1:test2:test3'
    end

    it 'supports to change the string to surround items' do
      input = %w(test1 test2 test3)

      expect(input.to_list(around: '$')).to eq '$test1$, $test2$, $test3$'
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.17 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.16 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.15 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.14 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.12 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.11 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.9 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.8 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.7 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.6 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.5 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.4 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.3 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.2 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.1 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.11.0 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.10.9 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.10.8 spec/core_ext/array/list_spec.rb
fedux_org-stdlib-0.10.7 spec/core_ext/array/list_spec.rb