|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | RSpec.describe ErrbitGithubPlugin::IssueTracker do
|
4 |
| - describe '.label' do |
5 |
| - it 'return LABEL' do |
| 4 | + describe ".label" do |
| 5 | + it "return LABEL" do |
6 | 6 | expect(described_class.label).to eq described_class::LABEL
|
7 | 7 | end
|
8 | 8 | end
|
9 | 9 |
|
10 |
| - describe '.note' do |
11 |
| - it 'return NOTE' do |
| 10 | + describe ".note" do |
| 11 | + it "return NOTE" do |
12 | 12 | expect(described_class.note).to eq described_class::NOTE
|
13 | 13 | end
|
14 | 14 | end
|
15 | 15 |
|
16 |
| - describe '.fields' do |
17 |
| - it 'return FIELDS' do |
| 16 | + describe ".fields" do |
| 17 | + it "return FIELDS" do |
18 | 18 | expect(described_class.fields).to eq described_class::FIELDS
|
19 | 19 | end
|
20 | 20 | end
|
21 | 21 |
|
22 |
| - describe '.icons' do |
23 |
| - |
24 |
| - it 'puts create icon onto the icons' do |
25 |
| - expect(described_class.icons[:create][0]).to eq 'image/png' |
| 22 | + describe ".icons" do |
| 23 | + it "puts create icon onto the icons" do |
| 24 | + expect(described_class.icons[:create][0]).to eq "image/png" |
26 | 25 | expect(
|
27 | 26 | described_class.icons[:create][1]
|
28 |
| - ).to eq ErrbitGithubPlugin.read_static_file('github_create.png') |
| 27 | + ).to eq ErrbitGithubPlugin.read_static_file("github_create.png") |
29 | 28 | end
|
30 | 29 |
|
31 |
| - it 'puts goto icon onto the icons' do |
32 |
| - expect(described_class.icons[:goto][0]).to eq 'image/png' |
| 30 | + it "puts goto icon onto the icons" do |
| 31 | + expect(described_class.icons[:goto][0]).to eq "image/png" |
33 | 32 | expect(
|
34 | 33 | described_class.icons[:goto][1]
|
35 |
| - ).to eq ErrbitGithubPlugin.read_static_file('github_goto.png') |
| 34 | + ).to eq ErrbitGithubPlugin.read_static_file("github_goto.png") |
36 | 35 | end
|
37 | 36 |
|
38 |
| - it 'puts inactive icon onto the icons' do |
39 |
| - expect(described_class.icons[:inactive][0]).to eq 'image/png' |
| 37 | + it "puts inactive icon onto the icons" do |
| 38 | + expect(described_class.icons[:inactive][0]).to eq "image/png" |
40 | 39 | expect(
|
41 | 40 | described_class.icons[:inactive][1]
|
42 |
| - ).to eq ErrbitGithubPlugin.read_static_file('github_inactive.png') |
| 41 | + ).to eq ErrbitGithubPlugin.read_static_file("github_inactive.png") |
43 | 42 | end
|
44 | 43 | end
|
45 | 44 |
|
46 | 45 | let(:tracker) { described_class.new(options) }
|
47 | 46 |
|
48 |
| - describe '#configured?' do |
49 |
| - context 'with errors' do |
50 |
| - let(:options) { { invalid_key: '' } } |
| 47 | + describe "#configured?" do |
| 48 | + context "with errors" do |
| 49 | + let(:options) { {invalid_key: ""} } |
51 | 50 |
|
52 |
| - it 'return false' do |
| 51 | + it "return false" do |
53 | 52 | expect(tracker.configured?).to eq false
|
54 | 53 | end
|
55 | 54 | end
|
56 |
| - context 'without errors' do |
| 55 | + context "without errors" do |
57 | 56 | let(:options) do
|
58 |
| - { username: 'foo', password: 'bar', github_repo: 'user/repos' } |
| 57 | + {username: "foo", password: "bar", github_repo: "user/repos"} |
59 | 58 | end
|
60 | 59 |
|
61 |
| - it 'return true' do |
| 60 | + it "return true" do |
62 | 61 | expect(tracker.configured?).to eq true
|
63 | 62 | end
|
64 | 63 | end
|
65 | 64 | end
|
66 | 65 |
|
67 |
| - describe '#url' do |
68 |
| - let(:options) { { github_repo: 'repo' } } |
| 66 | + describe "#url" do |
| 67 | + let(:options) { {github_repo: "repo"} } |
69 | 68 |
|
70 |
| - it 'returns issues url' do |
71 |
| - expect(tracker.url).to eq 'https://github.com/repo/issues' |
| 69 | + it "returns issues url" do |
| 70 | + expect(tracker.url).to eq "https://github.com/repo/issues" |
72 | 71 | end
|
73 | 72 | end
|
74 | 73 |
|
75 |
| - describe '#errors' do |
| 74 | + describe "#errors" do |
76 | 75 | subject { tracker.errors }
|
77 | 76 |
|
78 |
| - context 'without username' do |
79 |
| - let(:options) { { username: '', password: 'bar', github_repo: 'repo' } } |
| 77 | + context "without username" do |
| 78 | + let(:options) { {username: "", password: "bar", github_repo: "repo"} } |
80 | 79 |
|
81 | 80 | it { is_expected.not_to be_empty }
|
82 | 81 | end
|
83 | 82 |
|
84 |
| - context 'without password' do |
| 83 | + context "without password" do |
85 | 84 | let(:options) do
|
86 |
| - { username: '', password: 'bar', github_repo: 'repo' } |
| 85 | + {username: "", password: "bar", github_repo: "repo"} |
87 | 86 | end
|
88 | 87 |
|
89 | 88 | it { is_expected.not_to be_empty }
|
90 | 89 | end
|
91 | 90 |
|
92 |
| - context 'without github_repo' do |
| 91 | + context "without github_repo" do |
93 | 92 | let(:options) do
|
94 |
| - { username: 'foo', password: 'bar', github_repo: '' } |
| 93 | + {username: "foo", password: "bar", github_repo: ""} |
95 | 94 | end
|
96 | 95 |
|
97 | 96 | it { is_expected.not_to be_empty }
|
98 | 97 | end
|
99 | 98 |
|
100 |
| - context 'with completed options' do |
| 99 | + context "with completed options" do |
101 | 100 | let(:options) do
|
102 |
| - { username: 'foo', password: 'bar', github_repo: 'repo' } |
| 101 | + {username: "foo", password: "bar", github_repo: "repo"} |
103 | 102 | end
|
104 | 103 |
|
105 | 104 | it { is_expected.to be_empty }
|
106 | 105 | end
|
107 | 106 | end
|
108 | 107 |
|
109 |
| - describe '#repo' do |
110 |
| - let(:options) { { github_repo: 'baz' } } |
| 108 | + describe "#repo" do |
| 109 | + let(:options) { {github_repo: "baz"} } |
111 | 110 |
|
112 |
| - it 'returns github repo' do |
113 |
| - expect(tracker.repo).to eq 'baz' |
| 111 | + it "returns github repo" do |
| 112 | + expect(tracker.repo).to eq "baz" |
114 | 113 | end
|
115 | 114 | end
|
116 | 115 |
|
117 |
| - describe '#create_issue' do |
118 |
| - subject { tracker.create_issue('title', 'body', user: user) } |
| 116 | + describe "#create_issue" do |
| 117 | + subject { tracker.create_issue("title", "body", user: user) } |
119 | 118 |
|
120 | 119 | let(:options) do
|
121 |
| - { username: 'foo', password: 'bar', github_repo: 'user/repos' } |
| 120 | + {username: "foo", password: "bar", github_repo: "user/repos"} |
122 | 121 | end
|
123 | 122 |
|
124 | 123 | let(:fake_github_client) do
|
125 |
| - double('Fake GitHub Client').tap do |github_client| |
| 124 | + double("Fake GitHub Client").tap do |github_client| |
126 | 125 | expect(github_client).to receive(:create_issue).and_return(fake_issue)
|
127 | 126 | end
|
128 | 127 | end
|
129 | 128 |
|
130 | 129 | let(:fake_issue) do
|
131 |
| - double('Fake Issue').tap do |issue| |
132 |
| - expect(issue).to receive(:html_url).and_return('http://github.com/user/repos/issues/878').twice |
| 130 | + double("Fake Issue").tap do |issue| |
| 131 | + expect(issue).to receive(:html_url).and_return("http://github.com/user/repos/issues/878").twice |
133 | 132 | end
|
134 | 133 | end
|
135 | 134 |
|
136 |
| - context 'signed in with token' do |
| 135 | + context "signed in with token" do |
137 | 136 | let(:user) do
|
138 | 137 | {
|
139 |
| - 'github_login' => 'bob', |
140 |
| - 'github_oauth_token' => 'valid_token' |
| 138 | + "github_login" => "bob", |
| 139 | + "github_oauth_token" => "valid_token" |
141 | 140 | }
|
142 | 141 | end
|
143 | 142 |
|
144 |
| - it 'return issue url' do |
| 143 | + it "return issue url" do |
145 | 144 | expect(Octokit::Client).to receive(:new)
|
146 |
| - .with(login: user['github_login'], access_token: user['github_oauth_token']) |
| 145 | + .with(login: user["github_login"], access_token: user["github_oauth_token"]) |
147 | 146 | .and_return(fake_github_client)
|
148 | 147 |
|
149 | 148 | expect(subject).to eq fake_issue.html_url
|
150 | 149 | end
|
151 | 150 | end
|
152 | 151 |
|
153 |
| - context 'signed in with password' do |
| 152 | + context "signed in with password" do |
154 | 153 | let(:user) { {} }
|
155 | 154 |
|
156 |
| - it 'return issue url' do |
| 155 | + it "return issue url" do |
157 | 156 | expect(Octokit::Client).to receive(:new)
|
158 |
| - .with(login: options['username'], password: options['password']) |
| 157 | + .with(login: options["username"], password: options["password"]) |
159 | 158 | .and_return(fake_github_client)
|
160 | 159 |
|
161 | 160 | expect(subject).to eq fake_issue.html_url
|
162 | 161 | end
|
163 | 162 | end
|
164 | 163 |
|
165 |
| - context 'when unauthentication error' do |
| 164 | + context "when unauthentication error" do |
166 | 165 | let(:user) do
|
167 |
| - { 'github_login' => 'alice', 'github_oauth_token' => 'invalid_token' } |
| 166 | + {"github_login" => "alice", "github_oauth_token" => "invalid_token"} |
168 | 167 | end
|
169 | 168 |
|
170 |
| - it 'raise AuthenticationError' do |
| 169 | + it "raise AuthenticationError" do |
171 | 170 | expect(Octokit::Client).to receive(:new)
|
172 |
| - .with(login: user['github_login'], access_token: user['github_oauth_token']) |
| 171 | + .with(login: user["github_login"], access_token: user["github_oauth_token"]) |
173 | 172 | .and_raise(Octokit::Unauthorized)
|
174 | 173 |
|
175 | 174 | expect { subject }.to raise_error
|
|
0 commit comments