test/test_config_file.rb in mercurial-ruby-0.5.0 vs test/test_config_file.rb in mercurial-ruby-0.6.0

- old
+ new

@@ -46,10 +46,29 @@ FileUtils.rm_rf('/tmp/another-repo') repository = Mercurial::Repository.create('/tmp/another-repo') repository.config.add_setting("something", "super", "True") repository.config.contents.must_equal "[something]\nsuper = True\n" end + + it "should detect if setting was already added" do + @config.add_setting('hooks', 'incoming', 'hg update') + @config.add_setting('somethingelse', 'shikaka', 'True') + @config.add_setting('somethingelse', 'monster', 'False') + @config.delete_setting!('somethingelse', 'shikaka') + + assert @config.setting_exists?('hooks', 'incoming') + assert @config.setting_exists?('somethingelse', 'monster') + assert !@config.setting_exists?('somethingelse', 'shikaka') + assert !@config.setting_exists?('merge-tools', 'kdiff') + end + + it "should raise an error when trying to add a duplicating setting" do + @config.add_setting('hooks', 'incoming', 'hg update') + assert_raises Mercurial::ConfigFile::DuplicateSetting do + @config.add_setting('hooks', 'incoming', 'hg update') + end + end private def hgrc_with_incoming_hook_added %q[[paths] @@ -100,6 +119,6 @@ [somethingelse] shikaka = True ] end -end \ No newline at end of file +end