From e93ec12b32f3449f4669cf53469a4d5308b10cc3 Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Sun, 13 Aug 2017 13:10:38 -0400 Subject: Remove duplicate url generation logic in Github module --- Library/Homebrew/test/utils/github_spec.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') 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 -- cgit v1.2.3 From 24da1ecd3de86177f669072c542c9a01e6d6649d Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Sun, 13 Aug 2017 17:16:45 -0400 Subject: Fix url encoded in expected values --- Library/Homebrew/test/utils/github_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index cf5f6c808..79a26083a 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -15,17 +15,17 @@ describe GitHub do 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") + 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") + 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") + expect(query).to eq("q=user%3AHomebrew+user%3Acaskroom&per_page=100") end end end -- cgit v1.2.3 From 603bdd01a81e62d6b97a5da26d75d409e839a8fa Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Mon, 14 Aug 2017 11:08:56 -0400 Subject: Implement PR feedback --- Library/Homebrew/test/utils/github_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 79a26083a..5c315aec4 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -14,8 +14,8 @@ describe GitHub do 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") + 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 -- cgit v1.2.3 From 68cdb550f7b90318a136e4dd484249ab678f5fbc Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Mon, 14 Aug 2017 11:41:29 -0400 Subject: Spec for issues search --- Library/Homebrew/test/utils/github_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 5c315aec4..80f0ef786 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -28,4 +28,12 @@ describe GitHub do expect(query).to eq("q=user%3AHomebrew+user%3Acaskroom&per_page=100") end end + + describe "::issues_matching", :needs_network do + it "queries GitHub issues with the passed parameters" do + results = subject.issues_matching("brew search", repo: "Homebrew/brew", author: "avetamine", is: "closed") + expect(results.count).to eq(1) + expect(results.first["title"]).to eq("brew search : 422 Unprocessable Entity") + end + end end -- cgit v1.2.3 From 5f8d212ccccb8172985da9f71945fea6a8ea1b1a Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Mon, 14 Aug 2017 12:51:32 -0400 Subject: Unify vocabulary in github module, remove unnecessary logic Fix duplication bug --- Library/Homebrew/test/utils/github_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 80f0ef786..0b19c8c9e 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -29,9 +29,9 @@ describe GitHub do end end - describe "::issues_matching", :needs_network do + describe "::search_issues", :needs_network do it "queries GitHub issues with the passed parameters" do - results = subject.issues_matching("brew search", repo: "Homebrew/brew", author: "avetamine", is: "closed") + results = subject.search_issues("brew search", repo: "Homebrew/brew", author: "avetamine", is: "closed") expect(results.count).to eq(1) expect(results.first["title"]).to eq("brew search : 422 Unprocessable Entity") end -- cgit v1.2.3 From 7a93638105474c8e17a115dd2c16ae52f8f6806f Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Thu, 17 Aug 2017 11:40:32 -0400 Subject: Make test more resilient --- Library/Homebrew/test/utils/github_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 0b19c8c9e..7bfb4a930 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -32,8 +32,8 @@ describe GitHub do 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.count).to eq(1) - expect(results.first["title"]).to eq("brew search : 422 Unprocessable Entity") + expect(results.count).to be > 1 + expect(results.last["title"]).to eq("brew search : 422 Unprocessable Entity") end end end -- cgit v1.2.3 From e096836b7b46e605fb4d1c10c632157dd6b11186 Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Thu, 17 Aug 2017 11:57:58 -0400 Subject: Improve rspec readability --- Library/Homebrew/test/utils/github_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 7bfb4a930..151b6430d 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -32,7 +32,7 @@ describe GitHub do 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.count).to be > 1 + expect(results.count).not_to be_empty expect(results.last["title"]).to eq("brew search : 422 Unprocessable Entity") end end -- cgit v1.2.3 From 564a06dfbb711a995558c64c55b353d1fdfcb473 Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Thu, 17 Aug 2017 13:44:18 -0400 Subject: Fix typo in spec --- Library/Homebrew/test/utils/github_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 151b6430d..9322898ee 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -32,7 +32,7 @@ describe GitHub do 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.count).not_to be_empty + expect(results).not_to be_empty expect(results.last["title"]).to eq("brew search : 422 Unprocessable Entity") end end -- cgit v1.2.3 From b9a33b03a4812e87c88dc009dc0661d4fc7d46fc Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 10 Sep 2017 16:39:18 +0000 Subject: spelling: parameters --- Library/Homebrew/test/utils/github_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test/utils/github_spec.rb') diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 9322898ee..a132894f9 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -2,7 +2,7 @@ require "utils/github" describe GitHub do describe "::search_code", :needs_network do - it "queries GitHub code with the passed paramaters" do + it "queries GitHub code with the passed parameters" do results = subject.search_code(repo: "Homebrew/brew", path: "/", filename: "readme", language: "markdown") -- cgit v1.2.3