-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1436 from mbj/improve/capture-stdout
Change to improved command capture
- Loading branch information
Showing
8 changed files
with
108 additions
and
63 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
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
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
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
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 |
---|---|---|
|
@@ -60,16 +60,19 @@ def apply | |
described_class.load_from_git(world) | ||
end | ||
|
||
let(:world) { instance_double(Mutant::World) } | ||
|
||
before do | ||
allow(world).to receive(:capture_stdout, &commands.public_method(:fetch)) | ||
allow(world).to receive(:capture_command, &commands.public_method(:fetch)) | ||
end | ||
|
||
let(:git_remote_result) { right(git_remote) } | ||
let(:allowed_repositories) { %w[github.com/mbj/mutant] } | ||
let(:allowed_repositories) { %w[github.com/mbj/mutant] } | ||
let(:git_remote_result) { right(git_remote_status) } | ||
let(:world) { instance_double(Mutant::World) } | ||
|
||
let(:git_remote_status) do | ||
instance_double(Mutant::World::CommandStatus, stdout: git_remote_stdout) | ||
end | ||
|
||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\t[email protected]:mbj/Mutant (fetch) | ||
origin\t[email protected]:mbj/Mutant (push) | ||
|
@@ -102,7 +105,7 @@ def apply | |
end | ||
|
||
context 'on ssh url with protocol and without suffix' do | ||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\tssh://[email protected]/mbj/mutant (fetch) | ||
origin\tssh://[email protected]/mbj/mutant (push) | ||
|
@@ -113,7 +116,7 @@ def apply | |
end | ||
|
||
context 'on ssh url with protocol and suffix' do | ||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\tssh://[email protected]/mbj/mutant.git (fetch) | ||
origin\tssh://[email protected]/mbj/mutant.git (push) | ||
|
@@ -124,7 +127,7 @@ def apply | |
end | ||
|
||
context 'on https url without suffix' do | ||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\thttps://github.com/mbj/mutant (fetch) | ||
origin\thttps://github.com/mbj/mutant (push) | ||
|
@@ -135,7 +138,7 @@ def apply | |
end | ||
|
||
context 'on multiple different urls' do | ||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\thttps://github.com/mbj/mutant (fetch) | ||
origin\thttps://github.com/mbj/mutant (push) | ||
|
@@ -161,7 +164,7 @@ def apply | |
end | ||
|
||
context 'on https url with .git suffix' do | ||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\thttps://github.com/mbj/mutant.git (fetch) | ||
origin\thttps://github.com/mbj/mutant.git (push) | ||
|
@@ -172,13 +175,13 @@ def apply | |
end | ||
|
||
context 'when git remote line cannot be parsed' do | ||
let(:git_remote) { "some-bad-remote-line\n" } | ||
let(:git_remote_stdout) { "some-bad-remote-line\n" } | ||
|
||
it_fails 'Unmatched remote line: "some-bad-remote-line\n"' | ||
end | ||
|
||
context 'when git remote url cannot be parsed' do | ||
let(:git_remote) { "some-unknown\thttp://github.com/mbj/mutant (fetch)\n" } | ||
let(:git_remote_stdout) { "some-unknown\thttp://github.com/mbj/mutant (fetch)\n" } | ||
|
||
it_fails 'Unmatched git remote URL: "http://github.com/mbj/mutant"' | ||
end | ||
|
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 |
---|---|---|
|
@@ -77,7 +77,7 @@ def apply | |
let(:world) { instance_double(Mutant::World) } | ||
|
||
before do | ||
allow(world).to receive(:capture_stdout, &commands.public_method(:fetch)) | ||
allow(world).to receive(:capture_command, &commands.public_method(:fetch)) | ||
end | ||
|
||
def self.it_fails(expected) | ||
|
@@ -99,9 +99,13 @@ def self.it_fails_with_message(expected) | |
end | ||
|
||
describe 'on opensource license' do | ||
let(:git_remote_result) { right(git_remote) } | ||
let(:git_remote_result) { right(git_remote_status) } | ||
let(:allowed_repositories) { %w[github.com/mbj/mutant] } | ||
|
||
let(:git_remote_status) do | ||
instance_double(Mutant::World::CommandStatus, stdout: git_remote_stdout) | ||
end | ||
|
||
let(:license_json) do | ||
{ | ||
'type' => 'oss', | ||
|
@@ -117,7 +121,7 @@ def self.it_fails_with_message(expected) | |
} | ||
end | ||
|
||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\t[email protected]:mbj/mutant (fetch) | ||
origin\t[email protected]:mbj/mutant (push) | ||
|
@@ -127,7 +131,7 @@ def self.it_fails_with_message(expected) | |
context 'on one of many match' do | ||
let(:allowed_repositories) { %w[github.com/mbj/something github.com/mbj/mutant] } | ||
|
||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\t[email protected]:mbj/mutant (fetch) | ||
origin\t[email protected]:mbj/mutant (push) | ||
|
@@ -182,7 +186,11 @@ def self.it_fails_with_message(expected) | |
|
||
describe 'on commercial license' do | ||
context 'on organization licenses' do | ||
let(:git_remote_result) { right(git_remote) } | ||
let(:git_remote_result) { right(git_remote_status) } | ||
|
||
let(:git_remote_status) do | ||
instance_double(Mutant::World::CommandStatus, stdout: git_remote_stdout) | ||
end | ||
|
||
let(:license_json) do | ||
{ | ||
|
@@ -200,7 +208,7 @@ def self.it_fails_with_message(expected) | |
} | ||
end | ||
|
||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\t[email protected]:mbj/Mutant (fetch) | ||
origin\t[email protected]:mbj/Mutant (push) | ||
|
@@ -227,7 +235,7 @@ def self.it_fails_with_message(expected) | |
context 'on a one of many match' do | ||
let(:allowed_repositories) { %w[github.com/mbj/something github.com/mbj/mutant] } | ||
|
||
let(:git_remote) do | ||
let(:git_remote_stdout) do | ||
<<~REMOTE | ||
origin\t[email protected]:mbj/mutant (fetch) | ||
origin\t[email protected]:mbj/mutant (push) | ||
|
@@ -268,10 +276,24 @@ def self.it_fails_with_message(expected) | |
end | ||
|
||
shared_examples 'individual licenses' do | ||
let(:git_config_author) { "[email protected]\n" } | ||
let(:git_config_result) { Mutant::Either::Right.new(git_config_author) } | ||
let(:git_show_author) { "[email protected]\n" } | ||
let(:git_show_result) { Mutant::Either::Right.new(git_show_author) } | ||
let(:git_config_author) { "[email protected]\n" } | ||
let(:git_config_result) { Mutant::Either::Right.new(git_config_author_status) } | ||
let(:git_show_author) { "[email protected]\n" } | ||
let(:git_show_result) { Mutant::Either::Right.new(git_show_author_status) } | ||
|
||
let(:git_config_author_status) do | ||
instance_double( | ||
Mutant::World::CommandStatus, | ||
stdout: git_config_author | ||
) | ||
end | ||
|
||
let(:git_show_author_status) do | ||
instance_double( | ||
Mutant::World::CommandStatus, | ||
stdout: git_show_author | ||
) | ||
end | ||
|
||
let(:licensed_authors) do | ||
%w[ | ||
|
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
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