public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
Search Repo:
francois (author)
Thu Apr 17 10:52:40 -0700 2008
commit  e90f935a38bb88f37da5a3ba849531173c107413
tree    0755fdbf6d95bc51b4ec83248c2d10c676a80f46
parent  b6776eee6a822c7644b49807e3060d794fed93cf
piston / test / unit / test_working_copy_rememberance.rb
100644 48 lines (39 sloc) 1.449 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require File.dirname(__FILE__) + "/../test_helper"
 
class TestWorkingCopyRememberance < Test::Unit::TestCase
  def setup
    @wcdir = Pathname.new("tmp/wc")
    @wcdir.rmtree rescue nil
    @wcdir.mkpath
    @wc = Piston::WorkingCopy.new(@wcdir)
  end
 
  def teardown
    @wcdir.rmtree rescue nil
  end
 
  def test_remember_generates_piston_yml_file_in_wc
    @wc.remember({}, "a" => "b")
    assert((@wcdir + ".piston.yml").exist?, "tmp/wc/.piston.yml file doesn't exist")
  end
 
  def test_writes_values_as_yaml_under_handler_key
    expected = {"a" => "b"}
    @wc.remember({}, expected)
    actual = YAML.load((@wcdir + ".piston.yml").read)
    assert_equal expected, actual["handler"]
  end
 
  def test_remember_calls_after_remember_with_path_to_piston_yml_file
    @wc.expects(:after_remember).with(@wcdir + ".piston.yml")
    @wc.remember({}, "a" => "b")
  end
 
  def test_remember_with_two_args_remembers_handler_values_separately
    values = {"lock" => true}
    handler_values = {"a" => "b"}
 
    @wc.remember(values, handler_values)
 
    actual = YAML.load((@wcdir + ".piston.yml").read)
    assert_equal values.merge("format" => 1, "handler" => handler_values), actual
  end
 
  def test_recall_returns_hash_of_values
    values = {"a" => "b", "handler" => {"b" => "c"}}
    File.expects(:read).with(@wcdir + ".piston.yml").returns(:data)
    YAML.expects(:load).with(:data).returns(values)
    assert_equal values, @wc.recall
  end
end