-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3aaf224
commit c04fd18
Showing
5 changed files
with
94 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Commenter do | ||
let(:github) do | ||
spy("GitHub", comments: [ | ||
{ "body" => "Oh, hi! I didn't see you there." }, | ||
{ "body" => "Ah, that's just because of my invisibility powers." } | ||
], | ||
delete_comment: true) | ||
end | ||
|
||
describe "#block_duplicates?" do | ||
it "default" do | ||
commenter = Commenter.new(github: github, message: "") | ||
expect(commenter.block_duplicates?).to eq true | ||
end | ||
|
||
it "given true" do | ||
commenter = Commenter.new(github: github, message: "", check_for_duplicates: true) | ||
expect(commenter.block_duplicates?).to eq true | ||
end | ||
|
||
it "given 'true'" do | ||
commenter = Commenter.new(github: github, message: "", check_for_duplicates: "true") | ||
expect(commenter.block_duplicates?).to eq true | ||
end | ||
|
||
it "given 'false'" do | ||
commenter = Commenter.new(github: github, message: "", check_for_duplicates: false) | ||
expect(commenter.block_duplicates?).to eq false | ||
end | ||
|
||
it "given nil" do | ||
commenter = Commenter.new(github: github, message: "", check_for_duplicates: nil) | ||
expect(commenter.block_duplicates?).to eq false | ||
end | ||
end | ||
|
||
describe "#existing_duplicates?" do | ||
context "default/no pattern" do | ||
it "finds exact comment" do | ||
commenter = Commenter.new(github: github, message: "Ah, that's just because of my invisibility powers.") | ||
expect(commenter.existing_duplicates?).to eq true | ||
end | ||
|
||
it "gives false when no matches" do | ||
commenter = Commenter.new(github: github, message: "Today I will say a sentence never been said.") | ||
expect(commenter.existing_duplicates?).to eq false | ||
end | ||
end | ||
|
||
context "given pattern" do | ||
it "finds matching comment" do | ||
commenter = Commenter.new(github: github, message: "Is anyone listening?", duplicate_pattern: "invisibility powers") | ||
expect(commenter.existing_duplicates?).to eq true | ||
end | ||
|
||
it "gives false when no matches" do | ||
commenter = Commenter.new(github: github, message: "Is anyone listening?", duplicate_pattern: "common idioms") | ||
expect(commenter.existing_duplicates?).to eq false | ||
end | ||
end | ||
end | ||
|
||
describe "#delete_matching_comments!" do | ||
it "does nothing by default" do | ||
commenter = Commenter.new(github: github, message: "") | ||
expect(commenter.delete_matching_comments!).to eq nil | ||
expect(github).to have_received(:delete_comment).exactly(0).times | ||
end | ||
|
||
it "does nothing given empty string" do | ||
commenter = Commenter.new(github: github, message: "", delete_previous_pattern: "") | ||
expect(commenter.delete_matching_comments!).to eq nil | ||
expect(github).to have_received(:delete_comment).exactly(0).times | ||
end | ||
|
||
it "deletes matching comments given pattern" do | ||
commenter = Commenter.new(github: github, message: "", delete_previous_pattern: "invisibility") | ||
expect(commenter.delete_matching_comments!).to_not eq nil | ||
expect(github).to have_received(:delete_comment).once | ||
end | ||
end | ||
|
||
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require "spec_helper" | ||
require "pry" | ||
|
||
RSpec.describe GitHub do | ||
describe "#pr_number" do | ||
|
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