From 59d49f70c3b36e633b78e82fe3bd85b53f06900b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 13 Feb 2018 23:35:45 +0800 Subject: Rename Git::Repository::Location to Git::Location --- qa/spec/git/location_spec.rb | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 qa/spec/git/location_spec.rb (limited to 'qa/spec/git/location_spec.rb') diff --git a/qa/spec/git/location_spec.rb b/qa/spec/git/location_spec.rb new file mode 100644 index 00000000000..4c68a0cda61 --- /dev/null +++ b/qa/spec/git/location_spec.rb @@ -0,0 +1,55 @@ +describe QA::Git::Location do + describe '.parse' do + context 'when URI starts with ssh://' do + context 'when URI has port' do + it 'parses correctly' do + uri = described_class + .parse('ssh://git@qa.test:2222/sandbox/qa/repo.git') + + expect(uri.user).to eq('git') + expect(uri.host).to eq('qa.test') + expect(uri.port).to eq(2222) + expect(uri.path).to eq('/sandbox/qa/repo.git') + end + end + + context 'when URI does not have port' do + it 'parses correctly' do + uri = described_class + .parse('ssh://git@qa.test/sandbox/qa/repo.git') + + expect(uri.user).to eq('git') + expect(uri.host).to eq('qa.test') + expect(uri.port).to eq(22) + expect(uri.path).to eq('/sandbox/qa/repo.git') + end + end + end + + context 'when URI does not start with ssh://' do + context 'when host does not have colons' do + it 'parses correctly' do + uri = described_class + .parse('git@qa.test:sandbox/qa/repo.git') + + expect(uri.user).to eq('git') + expect(uri.host).to eq('qa.test') + expect(uri.port).to eq(22) + expect(uri.path).to eq('/sandbox/qa/repo.git') + end + end + + context 'when host has a colon' do + it 'parses correctly' do + uri = described_class + .parse('[git@qa:test]:sandbox/qa/repo.git') + + expect(uri.user).to eq('git') + expect(uri.host).to eq('qa%3Atest') + expect(uri.port).to eq(22) + expect(uri.path).to eq('/sandbox/qa/repo.git') + end + end + end + end +end -- cgit v1.2.1 From 305c8751c2845dc9c96f654579c7c9063c760534 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 14 Feb 2018 00:59:38 +0800 Subject: Fix the use to Git::Location --- qa/spec/git/location_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'qa/spec/git/location_spec.rb') diff --git a/qa/spec/git/location_spec.rb b/qa/spec/git/location_spec.rb index 4c68a0cda61..aef906ee836 100644 --- a/qa/spec/git/location_spec.rb +++ b/qa/spec/git/location_spec.rb @@ -1,10 +1,10 @@ describe QA::Git::Location do - describe '.parse' do + describe '.new' do context 'when URI starts with ssh://' do context 'when URI has port' do it 'parses correctly' do uri = described_class - .parse('ssh://git@qa.test:2222/sandbox/qa/repo.git') + .new('ssh://git@qa.test:2222/sandbox/qa/repo.git') expect(uri.user).to eq('git') expect(uri.host).to eq('qa.test') @@ -16,7 +16,7 @@ describe QA::Git::Location do context 'when URI does not have port' do it 'parses correctly' do uri = described_class - .parse('ssh://git@qa.test/sandbox/qa/repo.git') + .new('ssh://git@qa.test/sandbox/qa/repo.git') expect(uri.user).to eq('git') expect(uri.host).to eq('qa.test') @@ -30,7 +30,7 @@ describe QA::Git::Location do context 'when host does not have colons' do it 'parses correctly' do uri = described_class - .parse('git@qa.test:sandbox/qa/repo.git') + .new('git@qa.test:sandbox/qa/repo.git') expect(uri.user).to eq('git') expect(uri.host).to eq('qa.test') @@ -42,7 +42,7 @@ describe QA::Git::Location do context 'when host has a colon' do it 'parses correctly' do uri = described_class - .parse('[git@qa:test]:sandbox/qa/repo.git') + .new('[git@qa:test]:sandbox/qa/repo.git') expect(uri.user).to eq('git') expect(uri.host).to eq('qa%3Atest') -- cgit v1.2.1