forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for the check_connection? method.
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,5 +345,35 @@ | |
end | ||
end | ||
end | ||
|
||
context "check_connection?" do | ||
require 'net/ping/external' | ||
let(:ext_ping) { instance_double(Net::Ping::External) } | ||
|
||
before do | ||
allow(Net::Ping::External).to receive(:new).and_return(ext_ping) | ||
allow(ext_ping).to receive(:exception) | ||
end | ||
|
||
it "returns true if it can ping the repo" do | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging '.*' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
|
||
it "returns false if it cannot ping the repo" do | ||
allow(ext_ping).to receive(:ping?).and_return(false) | ||
expect($log).to receive(:debug).with(/pinging '.*' to verify network connection/) | ||
expect($log).to receive(:debug).with(/ping failed: .*/) | ||
expect(repo.check_connection?).to eq(false) | ||
end | ||
|
||
it "handles git urls without issue" do | ||
allow(repo).to receive(:url).and_return("[email protected]:ManageIQ/manageiq.git") | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging 'example.com' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
end | ||
end | ||
end |