Sha256: e2fb26be420a2365c1affe92fd13dbc89cdb4d6b1fbb278537c340c9d04f9a83
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
# coding: utf-8 require 'spec_helper' RSpec.describe 'Key pattern' do include I18n::Tasks::KeyPatternMatching describe 'matching' do describe '*' do it 'as suffix' do expect('devise.*').to match_key 'devise.some.key' end it 'as prefix' do expect('*.some.key').to match_key 'devise.some.key' end it 'as infix' do expect('*.some.*').to match_key 'devise.some.key' end it 'matches multiple namespaces' do expect('a.*.e*').to match_key 'a.b.c.d.eeee' end end describe ':' do it 'as suffix' do expect('a.b.:').to match_key 'a.b.c' expect('a.b.:').not_to match_key 'a.b.c.d' end it 'as prefix' do expect(':.b.c').to match_key 'a.b.c' expect(':.b.c').not_to match_key 'x.a.b.c' end it 'as infix' do expect('a.:.c').to match_key 'a.b.c' expect('a.:.c').not_to match_key 'a.b.x.c' end end describe '{sets}' do it 'matches' do p = 'a.{x,y}.b' expect(p).to match_key 'a.x.b' expect(p).to match_key 'a.y.b' expect(p).not_to match_key 'a.z.b' end it 'supports :' do expect('a.{:}.c').to match_key 'a.b.c' expect('a.{:}.c').not_to match_key 'a.b.x.c' end it 'supports *' do expect('a.{*}.c').to match_key 'a.b.c' expect('a.{*}.c').to match_key 'a.b.x.y.c' end it 'captures' do p = 'a.{x,y}.{:}' compile_key_pattern(p) =~ 'a.x.c' expect([$1, $2]).to eq(['x', 'c']) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n-tasks-0.8.7 | spec/key_pattern_matching_spec.rb |
i18n-tasks-0.8.6 | spec/key_pattern_matching_spec.rb |