Skip to content

Commit ebc2824

Browse files
committed
Cleanup
1 parent c29ebd8 commit ebc2824

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

spec/errbit_github_plugin/issue_tracker_spec.rb

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@
44

55
RSpec.describe ErrbitGithubPlugin::IssueTracker do
66
describe ".label" do
7-
it "return LABEL" do
8-
expect(described_class.label).to eq described_class::LABEL
9-
end
7+
it { expect(described_class.label).to eq("github") }
108
end
119

1210
describe ".note" do
13-
it "return NOTE" do
14-
expect(described_class.note).to eq described_class::NOTE
15-
end
11+
it { expect(described_class.note).to start_with("Please configure your GitHub") }
1612
end
1713

1814
describe ".fields" do
19-
it "return FIELDS" do
20-
expect(described_class.fields).to eq described_class::FIELDS
15+
it do
16+
expect(described_class.fields).to eq(
17+
{
18+
username: {
19+
placeholder: "Your username on GitHub"
20+
},
21+
password: {
22+
placeholder: "Password for your account"
23+
}
24+
}
25+
)
2126
end
2227
end
2328

@@ -55,7 +60,7 @@
5560
end
5661
context "without errors" do
5762
let(:options) do
58-
{username: "foo", password: "bar", github_repo: "user/repos"}
63+
{username: "foo", password: "bar", github_repo: "user/repository"}
5964
end
6065
it "return true" do
6166
expect(tracker.configured?).to eq true
@@ -105,14 +110,17 @@
105110

106111
describe "#create_issue" do
107112
subject { tracker.create_issue("title", "body", user: user) }
113+
108114
let(:options) do
109115
{username: "foo", password: "bar", github_repo: "user/repos"}
110116
end
117+
111118
let(:fake_github_client) do
112119
double("Fake GitHub Client").tap do |github_client|
113120
expect(github_client).to receive(:create_issue).and_return(fake_issue)
114121
end
115122
end
123+
116124
let(:fake_issue) do
117125
double("Fake Issue").tap do |issue|
118126
expect(issue).to receive(:html_url).and_return("http://github.com/user/repos/issues/878").twice
@@ -126,20 +134,24 @@
126134
"github_oauth_token" => "valid_token"
127135
}
128136
end
137+
129138
it "return issue url" do
130139
expect(Octokit::Client).to receive(:new).with(
131140
login: user["github_login"], access_token: user["github_oauth_token"]
132141
).and_return(fake_github_client)
142+
133143
expect(subject).to eq fake_issue.html_url
134144
end
135145
end
136146

137147
context "signed in with password" do
138148
let(:user) { {} }
149+
139150
it "return issue url" do
140151
expect(Octokit::Client).to receive(:new).with(
141152
login: options["username"], password: options["password"]
142153
).and_return(fake_github_client)
154+
143155
expect(subject).to eq fake_issue.html_url
144156
end
145157
end
@@ -148,10 +160,12 @@
148160
let(:user) do
149161
{"github_login" => "alice", "github_oauth_token" => "invalid_token"}
150162
end
163+
151164
it "raise AuthenticationError" do
152165
expect(Octokit::Client).to receive(:new).with(
153166
login: user["github_login"], access_token: user["github_oauth_token"]
154167
).and_raise(Octokit::Unauthorized)
168+
155169
expect { subject }.to raise_error(ErrbitGithubPlugin::AuthenticationError)
156170
end
157171
end

0 commit comments

Comments
 (0)