$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'buildmaster/build_number_file' module BuildMaster class BuildNumberFileTest < Test::Unit::TestCase def test_load_file path = tmp_file(2) build_number = BuildNumberFile.new(path) assert_equal(2, build_number.number) end def test_increase_build path = tmp_file(3) build_number = BuildNumberFile.new(path) build_number.increase_build assert_equal(4, build_number.number) reloaded = BuildNumberFile.new(path) assert_equal(4, reloaded.number) end private def tmp_file(build_number) path = File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'buildnumber') File.open(path, "w") {|file| file.puts build_number} return path end end end