aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMarkus Reiter2017-08-18 16:26:30 +0200
committerGitHub2017-08-18 16:26:30 +0200
commit3b92f69869f0bc88c2f99854392535d4d522902c (patch)
tree1563205d2b103f94207af17f10a870379ee76fa5 /Library/Homebrew/test
parentdaa0ea4b8a53b3d2965b84ff673c58310a6937ed (diff)
parentca05c7f010ed952b316fe541f94a8fc2a83446ec (diff)
downloadbrew-3b92f69869f0bc88c2f99854392535d4d522902c.tar.bz2
Merge pull request #3054 from BenMusch/github-refactor
Clean-up code in GitHub module to reduce duplication & coupling w/ Github API
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/utils/github_spec.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb
index 9b539262f..9322898ee 100644
--- a/Library/Homebrew/test/utils/github_spec.rb
+++ b/Library/Homebrew/test/utils/github_spec.rb
@@ -2,12 +2,38 @@ require "utils/github"
describe GitHub do
describe "::search_code", :needs_network do
- it "searches code" do
- results = subject.search_code("repo:Homebrew/brew", "path:/", "filename:readme", "language:markdown")
+ it "queries GitHub code with the passed paramaters" do
+ results = subject.search_code(repo: "Homebrew/brew", path: "/",
+ filename: "readme", language: "markdown")
expect(results.count).to eq(1)
expect(results.first["name"]).to eq("README.md")
expect(results.first["path"]).to eq("README.md")
end
end
+
+ describe "::query_string" do
+ it "builds a query with the given hash parameters formatted as key:value" do
+ query = subject.query_string(user: "Homebrew", repo: "brew")
+ expect(query).to eq("q=user%3AHomebrew+repo%3Abrew&per_page=100")
+ end
+
+ it "adds a variable number of top-level string parameters to the query when provided" do
+ query = subject.query_string("value1", "value2", user: "Homebrew")
+ expect(query).to eq("q=value1+value2+user%3AHomebrew&per_page=100")
+ end
+
+ it "turns array values into multiple key:value parameters" do
+ query = subject.query_string(user: ["Homebrew", "caskroom"])
+ expect(query).to eq("q=user%3AHomebrew+user%3Acaskroom&per_page=100")
+ end
+ end
+
+ describe "::search_issues", :needs_network do
+ it "queries GitHub issues with the passed parameters" do
+ results = subject.search_issues("brew search", repo: "Homebrew/brew", author: "avetamine", is: "closed")
+ expect(results).not_to be_empty
+ expect(results.last["title"]).to eq("brew search : 422 Unprocessable Entity")
+ end
+ end
end