@@ -27,7 +27,7 @@ def write(file, content)
27
27
28
28
# use fake home for .ssh hacks
29
29
run "mkdir #{ dir } /home"
30
- ENV [ "HOME" ] = File . expand_path ( "#{ dir } /home" )
30
+ ENV [ "HOME" ] = File . absolute_path ( "#{ dir } /home" )
31
31
32
32
Dir . chdir dir do
33
33
run "touch a"
@@ -269,13 +269,40 @@ def git_config_value(name, global = false)
269
269
end
270
270
end
271
271
272
- it "fails if it cannot find a pairs file" do
273
- run "git pair ab" , :fail => true
272
+ context "and without a .pairs file in the home directory" do
273
+ it "fails if it cannot find a pairs file" do
274
+ run "git pair ab" , :fail => true
275
+ end
276
+
277
+ it "prints instructions" do
278
+ result = run "git pair ab" , :fail => true
279
+ result . should include ( "Could not find a .pairs file. Create a YAML file in your project or home directory." )
280
+ end
274
281
end
275
282
276
- it "prints instructions" do
277
- result = run "git pair ab" , :fail => true
278
- result . should include ( "Could not find a .pairs file. Create a YAML file in your project or home directory." )
283
+ context "but a .pairs file in the home directory" do
284
+ around do |example |
285
+ file = File . join ( ENV [ "HOME" ] , ".pairs" )
286
+ write file , <<-YAML . unindent
287
+ pairs:
288
+ ab: Aa Bb
289
+ bc: Bb Cc
290
+ cd: Cc Dd
291
+
292
+ email:
293
+ prefix: the-pair
294
+ domain: the-host.com
295
+ YAML
296
+
297
+ example . run
298
+
299
+ FileUtils . rm file
300
+ end
301
+
302
+ it "loads the file" do
303
+ result = run "git pair ab"
304
+ expect_config result , "Aa Bb" , "ab" , "the-pair+aa@the-host.com"
305
+ end
279
306
end
280
307
end
281
308
end
0 commit comments