diff options
| author | Gautham Goli | 2017-10-12 00:29:19 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-10-13 19:50:46 +0530 |
| commit | 7fa51f71f1a8a21b905bafc1fb4106f0222d654f (patch) | |
| tree | 098d2477a8262a5770310fed4693da31c4392e1c /Library/Homebrew/test/utils/github_spec.rb | |
| parent | afdd0e2437426ec85ff86e5b7562d3a6a69ba3e5 (diff) | |
| parent | 56458f03fcc68ef6d8ee3ee4a7c1d16021aa5800 (diff) | |
| download | brew-7fa51f71f1a8a21b905bafc1fb4106f0222d654f.tar.bz2 | |
Merge branch 'master' into audit_line_rubocop_part_4_rebase_attempt_1
Diffstat (limited to 'Library/Homebrew/test/utils/github_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/utils/github_spec.rb | 30 |
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..a132894f9 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 parameters" 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 |
