diff options
| author | Ben Muschol | 2017-08-13 13:10:38 -0400 |
|---|---|---|
| committer | Ben Muschol | 2017-08-13 15:03:44 -0400 |
| commit | e93ec12b32f3449f4669cf53469a4d5308b10cc3 (patch) | |
| tree | 72476000915220c84b580c3628a33efe26d524b1 /Library/Homebrew/test/utils/github_spec.rb | |
| parent | d6d681ca01f8acf6b8d5e66cc1ca67310e9b8913 (diff) | |
| download | brew-e93ec12b32f3449f4669cf53469a4d5308b10cc3.tar.bz2 | |
Remove duplicate url generation logic in Github module
Diffstat (limited to 'Library/Homebrew/test/utils/github_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/utils/github_spec.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 9b539262f..cf5f6c808 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -2,12 +2,30 @@ 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%3aTest&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 end |
