|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -describe ErrbitGithubPlugin::IssueTracker do |
| 3 | +require "spec_helper" |
| 4 | + |
| 5 | +RSpec.describe ErrbitGithubPlugin::IssueTracker do |
4 | 6 | describe ".label" do |
5 | 7 | it "return LABEL" do |
6 | 8 | expect(described_class.label).to eq described_class::LABEL |
|
108 | 110 | end |
109 | 111 | let(:fake_github_client) do |
110 | 112 | double("Fake GitHub Client").tap do |github_client| |
111 | | - github_client.stub(:create_issue).and_return(fake_issue) |
| 113 | + expect(github_client).to receive(:create_issue).and_return(fake_issue) |
112 | 114 | end |
113 | 115 | end |
114 | 116 | let(:fake_issue) do |
115 | 117 | double("Fake Issue").tap do |issue| |
116 | | - issue.stub(:html_url).and_return("http://github.com/user/repos/issues/878") |
| 118 | + expect(issue).to receive(:html_url).and_return("http://github.com/user/repos/issues/878").twice |
117 | 119 | end |
118 | 120 | end |
119 | 121 |
|
|
125 | 127 | } |
126 | 128 | end |
127 | 129 | it "return issue url" do |
128 | | - Octokit::Client.stub(:new).with( |
| 130 | + expect(Octokit::Client).to receive(:new).with( |
129 | 131 | login: user["github_login"], access_token: user["github_oauth_token"] |
130 | 132 | ).and_return(fake_github_client) |
131 | 133 | expect(subject).to eq fake_issue.html_url |
|
135 | 137 | context "signed in with password" do |
136 | 138 | let(:user) { {} } |
137 | 139 | it "return issue url" do |
138 | | - Octokit::Client.stub(:new).with( |
| 140 | + expect(Octokit::Client).to receive(:new).with( |
139 | 141 | login: options["username"], password: options["password"] |
140 | 142 | ).and_return(fake_github_client) |
141 | 143 | expect(subject).to eq fake_issue.html_url |
|
147 | 149 | {"github_login" => "alice", "github_oauth_token" => "invalid_token"} |
148 | 150 | end |
149 | 151 | it "raise AuthenticationError" do |
150 | | - Octokit::Client.stub(:new).with( |
| 152 | + expect(Octokit::Client).to receive(:new).with( |
151 | 153 | login: user["github_login"], access_token: user["github_oauth_token"] |
152 | 154 | ).and_raise(Octokit::Unauthorized) |
153 | | - expect { subject }.to raise_error |
| 155 | + expect { subject }.to raise_error(ErrbitGithubPlugin::AuthenticationError) |
154 | 156 | end |
155 | 157 | end |
156 | 158 | end |
|
0 commit comments