|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | 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: '' } } |
51 | | - it 'return false' do |
| 47 | + describe "#configured?" do |
| 48 | + context "with errors" do |
| 49 | + let(:options) { {invalid_key: ""} } |
| 50 | + it "return false" do |
52 | 51 | expect(tracker.configured?).to eq false |
53 | 52 | end |
54 | 53 | end |
55 | | - context 'without errors' do |
| 54 | + context "without errors" do |
56 | 55 | let(:options) do |
57 | | - { username: 'foo', password: 'bar', github_repo: 'user/repos' } |
| 56 | + {username: "foo", password: "bar", github_repo: "user/repos"} |
58 | 57 | end |
59 | | - it 'return true' do |
| 58 | + it "return true" do |
60 | 59 | expect(tracker.configured?).to eq true |
61 | 60 | end |
62 | 61 | end |
63 | 62 | end |
64 | 63 |
|
65 | | - describe '#url' do |
66 | | - let(:options) { { github_repo: 'repo' } } |
67 | | - it 'returns issues url' do |
68 | | - expect(tracker.url).to eq 'https://github.com/repo/issues' |
| 64 | + describe "#url" do |
| 65 | + let(:options) { {github_repo: "repo"} } |
| 66 | + it "returns issues url" do |
| 67 | + expect(tracker.url).to eq "https://github.com/repo/issues" |
69 | 68 | end |
70 | 69 | end |
71 | 70 |
|
72 | | - describe '#errors' do |
| 71 | + describe "#errors" do |
73 | 72 | subject { tracker.errors } |
74 | | - context 'without username' do |
75 | | - let(:options) { { username: '', password: 'bar', github_repo: 'repo' } } |
| 73 | + context "without username" do |
| 74 | + let(:options) { {username: "", password: "bar", github_repo: "repo"} } |
76 | 75 | it { is_expected.not_to be_empty } |
77 | 76 | end |
78 | | - context 'without password' do |
| 77 | + context "without password" do |
79 | 78 | let(:options) do |
80 | | - { username: '', password: 'bar', github_repo: 'repo' } |
| 79 | + {username: "", password: "bar", github_repo: "repo"} |
81 | 80 | end |
82 | 81 | it { is_expected.not_to be_empty } |
83 | 82 | end |
84 | | - context 'without github_repo' do |
| 83 | + context "without github_repo" do |
85 | 84 | let(:options) do |
86 | | - { username: 'foo', password: 'bar', github_repo: '' } |
| 85 | + {username: "foo", password: "bar", github_repo: ""} |
87 | 86 | end |
88 | 87 | it { is_expected.not_to be_empty } |
89 | 88 | end |
90 | | - context 'with completed options' do |
| 89 | + context "with completed options" do |
91 | 90 | let(:options) do |
92 | | - { username: 'foo', password: 'bar', github_repo: 'repo' } |
| 91 | + {username: "foo", password: "bar", github_repo: "repo"} |
93 | 92 | end |
94 | 93 | it { is_expected.to be_empty } |
95 | 94 | end |
96 | 95 | end |
97 | 96 |
|
98 | | - describe '#repo' do |
99 | | - let(:options) { { github_repo: 'baz' } } |
100 | | - it 'returns github repo' do |
101 | | - expect(tracker.repo).to eq 'baz' |
| 97 | + describe "#repo" do |
| 98 | + let(:options) { {github_repo: "baz"} } |
| 99 | + it "returns github repo" do |
| 100 | + expect(tracker.repo).to eq "baz" |
102 | 101 | end |
103 | 102 | end |
104 | 103 |
|
105 | | - describe '#create_issue' do |
106 | | - subject { tracker.create_issue('title', 'body', user: user) } |
| 104 | + describe "#create_issue" do |
| 105 | + subject { tracker.create_issue("title", "body", user: user) } |
107 | 106 | let(:options) do |
108 | | - { username: 'foo', password: 'bar', github_repo: 'user/repos' } |
| 107 | + {username: "foo", password: "bar", github_repo: "user/repos"} |
109 | 108 | end |
110 | 109 | let(:fake_github_client) do |
111 | | - double('Fake GitHub Client').tap do |github_client| |
| 110 | + double("Fake GitHub Client").tap do |github_client| |
112 | 111 | github_client.stub(:create_issue).and_return(fake_issue) |
113 | 112 | end |
114 | 113 | end |
115 | 114 | let(:fake_issue) do |
116 | | - double('Fake Issue').tap do |issue| |
117 | | - issue.stub(:html_url).and_return('http://github.com/user/repos/issues/878') |
| 115 | + double("Fake Issue").tap do |issue| |
| 116 | + issue.stub(:html_url).and_return("http://github.com/user/repos/issues/878") |
118 | 117 | end |
119 | 118 | end |
120 | 119 |
|
121 | | - context 'signed in with token' do |
| 120 | + context "signed in with token" do |
122 | 121 | let(:user) do |
123 | 122 | { |
124 | | - 'github_login' => 'bob', |
125 | | - 'github_oauth_token' => 'valid_token' |
| 123 | + "github_login" => "bob", |
| 124 | + "github_oauth_token" => "valid_token" |
126 | 125 | } |
127 | 126 | end |
128 | | - it 'return issue url' do |
| 127 | + it "return issue url" do |
129 | 128 | Octokit::Client.stub(:new).with( |
130 | | - login: user['github_login'], access_token: user['github_oauth_token'] |
| 129 | + login: user["github_login"], access_token: user["github_oauth_token"] |
131 | 130 | ).and_return(fake_github_client) |
132 | 131 | expect(subject).to eq fake_issue.html_url |
133 | 132 | end |
134 | 133 | end |
135 | 134 |
|
136 | | - context 'signed in with password' do |
| 135 | + context "signed in with password" do |
137 | 136 | let(:user) { {} } |
138 | | - it 'return issue url' do |
139 | | - (Octokit::Client).stub(:new).with( |
140 | | - login: options['username'], password: options['password'] |
| 137 | + it "return issue url" do |
| 138 | + Octokit::Client.stub(:new).with( |
| 139 | + login: options["username"], password: options["password"] |
141 | 140 | ).and_return(fake_github_client) |
142 | 141 | expect(subject).to eq fake_issue.html_url |
143 | 142 | end |
144 | 143 | end |
145 | 144 |
|
146 | | - context 'when unauthentication error' do |
| 145 | + context "when unauthentication error" do |
147 | 146 | let(:user) do |
148 | | - { 'github_login' => 'alice', 'github_oauth_token' => 'invalid_token' } |
| 147 | + {"github_login" => "alice", "github_oauth_token" => "invalid_token"} |
149 | 148 | end |
150 | | - it 'raise AuthenticationError' do |
151 | | - (Octokit::Client).stub(:new).with( |
152 | | - login: user['github_login'], access_token: user['github_oauth_token'] |
| 149 | + it "raise AuthenticationError" do |
| 150 | + Octokit::Client.stub(:new).with( |
| 151 | + login: user["github_login"], access_token: user["github_oauth_token"] |
153 | 152 | ).and_raise(Octokit::Unauthorized) |
154 | 153 | expect { subject }.to raise_error |
155 | 154 | end |
|
0 commit comments