Sha256: 62efdae08eb50fe46fc811aea4cee534e55549641d2c0d1492eb5c28f9851cdd
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require 'minitest_helper' # This module is included in Torm, so we use that to test its behavior. describe Torm::Tools do describe '#atomic_save' do tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'tmp')) tmp_file = "#{tmp_dir}/atomic.test" before do Dir.mkdir(tmp_dir) unless File.exist?(tmp_dir) end after do File.delete(tmp_file) if File.exist?(tmp_file) end it 'should save data to a file' do Torm.atomic_save(tmp_file, 'test') assert File.exist?(tmp_file) _(File.read(tmp_file)).must_equal 'test' end end describe '#symbolize_keys' do it 'should convert string keys to symbols' do _(Torm.symbolize_keys({ 'a' => 'b', :c => :d })).must_equal({ a: 'b', c: :d }) end end describe '#slice' do it 'should return a hash with only the white listed keys' do hash = { foo: 1, baz: 3 } _(Torm.slice(hash, :foo, :bar)).must_equal({ foo: 1 }) # Ensure we did not modify the original Hash _(hash[:baz]).must_equal 3 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
torm-0.3.0 | test/torm/tools_test.rb |