test/configuration_test.rb in sifttter-redux-0.5.1 vs test/configuration_test.rb in sifttter-redux-0.5.2

- old
+ new

@@ -10,67 +10,69 @@ def teardown File.delete('/tmp/srd_config') if File.exists?('/tmp/srd_config') end def test_add_data - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration['section1'] = { 'a' => 'test', 'b' => 'test' } - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => { 'a' => 'test', 'b' => 'test' } }) + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration::section1.merge!( a: 'test', b: 'test' ) + assert_equal(SifttterRedux::Configuration::dump, { section1: { a: 'test', b: 'test' } }) - SifttterRedux::Configuration['section1']['a'] = 'bigger test' - SifttterRedux::Configuration['section1']['c'] = 'little test' - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => { 'a' => 'bigger test', 'b' => 'test', 'c' => 'little test' } }) + SifttterRedux::Configuration::section1[:a] = 'bigger test' + SifttterRedux::Configuration::section1[:c] = 'little test' + assert_equal(SifttterRedux::Configuration::dump, { section1: { a: 'bigger test', b: 'test', c: 'little test' } }) end def test_add_section - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration::add_section('section2') - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {}, 'section2' => {} }) + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration::add_section(:section2) + assert_equal(SifttterRedux::Configuration::dump, { section1: {}, section2: {} }) end def test_add_section_duplicate - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration::add_section('section2') - SifttterRedux::Configuration::add_section('section2') - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {}, 'section2' => {} }) + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration::add_section(:section2) + SifttterRedux::Configuration::add_section(:section2) + assert_equal(SifttterRedux::Configuration::dump, { section1: {}, section2: {} }) end def test_config_path assert_equal(SifttterRedux::Configuration::config_path, '/tmp/srd_config') end def test_delete_section - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration::add_section('section2') - SifttterRedux::Configuration::delete_section('section2') - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {} }) + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration::add_section(:section2) + SifttterRedux::Configuration::delete_section(:section2) + assert_equal(SifttterRedux::Configuration::dump, { section1: {} }) end def test_delete_section_nonexistant - SifttterRedux::Configuration::add_section('section1') + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) SifttterRedux::Configuration::delete_section('section12723762323') - assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {} }) + assert_equal(SifttterRedux::Configuration::dump, { section1: {} }) end def test_reset - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration::add_section('section2') - SifttterRedux::Configuration::add_section('section3') SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration::add_section(:section2) + SifttterRedux::Configuration::add_section(:section3) + SifttterRedux::Configuration::reset assert_equal(SifttterRedux::Configuration::dump, {}) end def test_save - SifttterRedux::Configuration::add_section('section1') - SifttterRedux::Configuration['section1'] = { 'a' => 'test', 'b' => 'test' } + SifttterRedux::Configuration::reset + SifttterRedux::Configuration::add_section(:section1) + SifttterRedux::Configuration.section1.merge!({ a: 'test', b: 'test' }) SifttterRedux::Configuration::save File.open('/tmp/srd_config', 'r') do |f| - assert_output("---\nsection1:\n a: test\n b: test\n") { puts f.read } + assert_output("---\n:section1:\n :a: test\n :b: test\n") { puts f.read } end - end - - def test_section_exists - SifttterRedux::Configuration::add_section('section1') - assert_equal(SifttterRedux::Configuration::section_exists?('section1'), true) end end