forked from cristibalan/braid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_spec.rb
59 lines (48 loc) · 1.55 KB
/
config_spec.rb
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
49
50
51
52
53
54
55
56
57
58
59
require File.dirname(__FILE__) + '/test_helper'
describe "Braid::Config, when empty" do
before(:each) do
@config = Braid::Config.new("tmp.yml")
end
after(:each) do
FileUtils.rm("tmp.yml") rescue nil
end
it "should not get a mirror by name" do
@config.get("path").should be_nil
lambda { @config.get!("path") }.should raise_error(Braid::Config::MirrorDoesNotExist)
end
it "should add a mirror and its params" do
@mirror = build_mirror
@config.add(@mirror)
@config.get("path").path.should_not be_nil
end
end
describe "Braid::Config, with one mirror" do
before(:each) do
@config = Braid::Config.new("tmp.yml")
@mirror = build_mirror
@config.add(@mirror)
end
after(:each) do
FileUtils.rm("tmp.yml") rescue nil
end
it "should get the mirror by name" do
@config.get("path").should == @mirror
@config.get!("path").should == @mirror
end
it "should raise when trying to overwrite a mirror on add" do
lambda { @config.add(@mirror) }.should raise_error(Braid::Config::PathAlreadyInUse)
end
it "should remove the mirror" do
@config.remove(@mirror)
@config.get("path").should be_nil
end
it "should update the mirror with new params" do
@mirror.branch = "other"
@config.update(@mirror)
@config.get("path").attributes.should == {"branch" => "other"}
end
it "should raise when trying to update nonexistent mirror" do
@mirror.instance_variable_set("@path", "other")
lambda { @config.update(@mirror) }.should raise_error(Braid::Config::MirrorDoesNotExist)
end
end