From 15d660297d2e648ea009df235e53f75ba45c5cd7 Mon Sep 17 00:00:00 2001 From: Aa Bb Date: Wed, 14 Mar 2012 15:16:16 -0700 Subject: [PATCH] Add test for emails without a prefix --- bin/git-pair | 3 ++- spec/cli_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/git-pair b/bin/git-pair index ea78b03..fa318ff 100755 --- a/bin/git-pair +++ b/bin/git-pair @@ -87,7 +87,8 @@ if authors.any? else authors = names[0..-2].join(", ") + " & " + names.last end - email = if email_prefix = config['email']['prefix'] + + email = if config['email'].is_a?(Hash) "#{([config['email']['prefix']] + emails).compact.join('+')}@#{config['email']['domain']}" else config['email'] diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 234d701..5bf3a79 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -167,6 +167,12 @@ def expect_config(result, name, initials, email, options={}) expect_config result, "Aa Bb", "ab", "foo@bar.com" end + it "uses no email prefix when only host is given" do + write ".pairs", File.read(".pairs").sub(/email:.*/m, "email:\n domain: foo.com") + result = run "git pair ab" + expect_config result, "Aa Bb", "ab", "aa@foo.com" + end + it "fails with unknown initials" do result = run "git pair xx", :fail => true result.should include("Couldn't find author name for initials: xx")