Sha256: 9cc55d54c912be1ac8e46aef71eaf118d6f04236d505d8326e535f4dbd15c466
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
require File.dirname(__FILE__) + '/../../test_helper' require 'radiant/config' class Radiant::ConfigTest < Test::Unit::TestCase def setup @conf = Radiant::Config set('test', 'cool') set('foo', 'bar') end def test_brackets assert_equal 'cool', @conf['test'] end def test_brackets_with_non_existant_key assert_equal nil, @conf['non-existant-key'] end def test_assign_to_brackets v = @conf['bar'] = 'baz' assert_equal 'baz', @conf['bar'] assert_equal 'baz', v end def test_assign_to_brackets_existing_key @conf['foo'] = 'normal' v = @conf['foo'] = 'replaced' assert_equal 'replaced', @conf['foo'] assert_equal 'replaced', v end def test_to_hash h = @conf.to_hash assert_instance_of Hash, h assert_equal 'cool', h['test'] assert h.size > 1 end def test_boolean_values set('bool?', true) assert @conf["bool?"] set('bool?', false) assert !@conf["bool?"] set('bool2', true) assert_equal 'true', @conf['bool2'] set('bool2', :blahblahblah) assert_equal 'blahblahblah', @conf['bool2'] end private def set(key, value) setting = Radiant::Config.find_by_key(key) setting.destroy if setting Radiant::Config.new(:key => key, :value => value).save end end
Version data entries
4 entries across 4 versions & 1 rubygems