Sha256: 4c232db344dc3da446cf602f700e2ec512b3b2c3d10c4361a2717bfd6e52c85d
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
require 'test_helper' module Mayl describe Locale do before do hash = { 'ca' => { 'activerecord' => { 'models' => { 'post' => 'Article' } } } } @locale = Locale.new('some/ca.yml', hash) end it 'gets a key' do @locale.get('activerecord.models.post').must_equal 'Article' end it 'sets and retrieves a given key' do @locale.set('activerecord.models.comment', 'Comentari') @locale.get('activerecord.models.comment').must_equal 'Comentari' end describe '#commit' do it 'does not commit if there are no changes' do @locale.commit.must_equal false end end it 'saves changes to disk' do @locale.set('activerecord.whatever', 'foo') YAML.expects(:dump).with({ 'ca' => { 'activerecord' => { 'models' => { 'post' => 'Article' }, 'whatever' => 'foo' } } }).returns dumped_contents = stub File.expects(:open).with('some/ca.yml', 'w').yields file = stub file.expects(:write).with dumped_contents @locale.commit end it 'peeks the contents of a given key' do @locale.peek('activerecord').must_equal ['models'] @locale.peek('activerecord.models').must_equal ['post'] @locale.peek('activerecord.models.post').must_equal nil end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mayl-0.2.1 | test/mayl/locale_test.rb |
mayl-0.2.0 | test/mayl/locale_test.rb |
mayl-0.1.0 | test/mayl/locale_test.rb |
mayl-0.0.1 | test/mayl/locale_test.rb |