summaryrefslogtreecommitdiff
path: root/spec/shogun/github_score_spec.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-12-21 10:04:34 -0700
committermo khan <mo@mokhan.ca>2021-12-21 10:04:34 -0700
commit1da7737f8970000fc7bd592c19aa6c647d49c347 (patch)
tree8374631214504ecdae929013638d5d73dc80e889 /spec/shogun/github_score_spec.rb
parent752ec386ab387a76f60b2571d43c42faf71e2e29 (diff)
refactor: move files to lib/spec/bin
Diffstat (limited to 'spec/shogun/github_score_spec.rb')
-rw-r--r--spec/shogun/github_score_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/shogun/github_score_spec.rb b/spec/shogun/github_score_spec.rb
new file mode 100644
index 0000000..60deb11
--- /dev/null
+++ b/spec/shogun/github_score_spec.rb
@@ -0,0 +1,31 @@
+RSpec.describe Shogun::GithubScore do
+ describe "#score" do
+ subject(:github_score) { described_class.new(handle) }
+ let(:handle) { "tenderlove" }
+
+ context "when calculating the score for a known user" do
+ let(:events) { [{type: 'PushEvent'}, {type: 'IssuesEvent'}] }
+
+ before do
+ stub_request(:get, "https://api.github.com/users/#{handle}/events/public")
+ .to_return(status: 200, body: events.to_json)
+ end
+
+ it { expect(github_score.score).to eq(4) }
+ end
+
+ context "when attempting to retrive the score for an unknown user" do
+ before do
+ stub_request(:get, "https://api.github.com/users/#{handle}/events/public")
+ .to_return(status: 404, body: {
+ "message": "Not Found",
+ "documentation_url": "https://docs.github.com/rest/reference/activity#list-public-events-for-a-user"
+ }.to_json)
+ end
+
+ it { expect { github_score.score }.to raise_error(Shogun::UserNotFound) }
+ end
+
+ # it times out
+ end
+end