Sha256: 53d0436b75dc4bfe32b89c49a3d3885af88b13b0d3f57dcb7d22544fad65a4e6
Contents?: true
Size: 982 Bytes
Versions: 3
Compression:
Stored size: 982 Bytes
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_file = 'tmp/atomic.test' after do File.delete(tmp_file) if File.exist?(tmp_file) Dir.delete('tmp') if File.exist?('tmp') end it 'should save data to a file' do Dir.mkdir('tmp') 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
torm-0.2.0 | test/torm/tools_test.rb |
torm-0.1.0 | test/torm/tools_test.rb |
torm-0.0.1 | test/torm/tools_test.rb |