Sha256: b3f54c5de934483cc1a0ac99d1d5ff8be70075ed99ac06094563a143e1c66091

Contents?: true

Size: 896 Bytes

Versions: 13

Compression:

Stored size: 896 Bytes

Contents

require 'spec_helper'

describe 'SplitKey' do
  include ::I18n::Tasks::SplitKey

  [['', %w()],
   ['a', %w(a)],
   ['a.b', %w(a b)],
   ['a.b.', %w(a b)],
   ['a.b.c', %w(a b c)],
   ['a.#{b.c}', %w(a #{b.c})],
   ['a.#{b.c}.', %w(a #{b.c})],
   ['a.#{b.c}.d', %w(a #{b.c} d)],
   ['a.#{b.c}.d.[e.f]', %w(a #{b.c} d [e.f])],
  ].each do |(arg, ret)|
    it "#{arg} is split into #{ret.inspect}" do
      expect(split_key arg).to eq(ret)
    end
  end

  it 'limits results to second argument' do
    expect(split_key 'a.b.c', 1).to eq(['a.b.c'])
    expect(split_key 'a.b.c', 2).to eq(['a', 'b.c'])
    expect(split_key 'a.b.c.', 2).to eq(['a', 'b.c.'])
    expect(split_key 'a.b.c.d.e.f', 4).to eq(['a', 'b', 'c', 'd.e.f'])
  end

  it 'last part' do
    expect(last_key_part 'a.b.c').to eq('c')
    expect(last_key_part 'a').to eq('a')
    expect(last_key_part 'a.b.c.d').to eq('d')
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
i18n-tasks-0.8.5 spec/split_key_spec.rb
i18n-tasks-0.8.4 spec/split_key_spec.rb
i18n-tasks-0.8.3 spec/split_key_spec.rb
i18n-tasks-0.8.2 spec/split_key_spec.rb
i18n-tasks-0.8.1 spec/split_key_spec.rb
i18n-tasks-0.8.0 spec/split_key_spec.rb
i18n-tasks-0.7.13 spec/split_key_spec.rb
i18n-tasks-0.7.12 spec/split_key_spec.rb
i18n-tasks-0.7.11 spec/split_key_spec.rb
i18n-tasks-0.7.10 spec/split_key_spec.rb
i18n-tasks-0.7.9 spec/split_key_spec.rb
i18n-tasks-0.7.8 spec/split_key_spec.rb
i18n-tasks-0.7.7 spec/split_key_spec.rb