errbit_plugin 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,517 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe ErrbitPlugin::IssueTrackerValidator do
6
+ describe "#valid?" do
7
+ context "with a complete class" do
8
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
9
+ def self.label
10
+ "foo"
11
+ end
12
+
13
+ def self.note
14
+ "foo"
15
+ end
16
+
17
+ def self.fields
18
+ ["foo"]
19
+ end
20
+
21
+ def self.icons
22
+ {}
23
+ end
24
+
25
+ def configured?
26
+ true
27
+ end
28
+
29
+ def errors
30
+ true
31
+ end
32
+
33
+ def create_issue
34
+ "http"
35
+ end
36
+
37
+ def close_issue
38
+ "http"
39
+ end
40
+
41
+ def url
42
+ "http"
43
+ end
44
+ end
45
+
46
+ it "valid" do
47
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be true
48
+ end
49
+ end
50
+
51
+ context "with class not inherit from ErrbitPlugin::IssueTracker" do
52
+ klass = Class.new do
53
+ def self.label
54
+ "foo"
55
+ end
56
+
57
+ def self.note
58
+ "foo"
59
+ end
60
+
61
+ def self.fields
62
+ ["foo"]
63
+ end
64
+
65
+ def self.icons
66
+ {}
67
+ end
68
+
69
+ def initialize(params)
70
+ end
71
+
72
+ def configured?
73
+ true
74
+ end
75
+
76
+ def errors
77
+ true
78
+ end
79
+
80
+ def create_issue
81
+ "http"
82
+ end
83
+
84
+ def close_issue
85
+ "http"
86
+ end
87
+
88
+ def url
89
+ "http"
90
+ end
91
+ end
92
+
93
+ it "not valid" do
94
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
95
+ end
96
+
97
+ it "says :not_inherited" do
98
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
99
+ is.valid?
100
+ expect(is.errors).to eql [[:not_inherited]]
101
+ end
102
+ end
103
+
104
+ context "with no label method" do
105
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
106
+ def self.note
107
+ "foo"
108
+ end
109
+
110
+ def self.fields
111
+ ["foo"]
112
+ end
113
+
114
+ def self.icons
115
+ {}
116
+ end
117
+
118
+ def configured?
119
+ true
120
+ end
121
+
122
+ def errors
123
+ true
124
+ end
125
+
126
+ def create_issue
127
+ "http"
128
+ end
129
+
130
+ def close_issue
131
+ "http"
132
+ end
133
+
134
+ def url
135
+ "http"
136
+ end
137
+ end
138
+
139
+ it "not valid" do
140
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
141
+ end
142
+
143
+ it "say not implement label method" do
144
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
145
+ is.valid?
146
+ expect(is.errors).to eql [[:class_method_missing, :label]]
147
+ end
148
+ end
149
+
150
+ context "with no icons method" do
151
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
152
+ def self.note
153
+ "foo"
154
+ end
155
+
156
+ def self.fields
157
+ ["foo"]
158
+ end
159
+
160
+ def self.label
161
+ "alabel"
162
+ end
163
+
164
+ def configured?
165
+ true
166
+ end
167
+
168
+ def errors
169
+ true
170
+ end
171
+
172
+ def create_issue
173
+ "http"
174
+ end
175
+
176
+ def close_issue
177
+ "http"
178
+ end
179
+
180
+ def url
181
+ "http"
182
+ end
183
+ end
184
+
185
+ it "not valid" do
186
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
187
+ end
188
+
189
+ it "say not implement icons method" do
190
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
191
+ is.valid?
192
+ expect(is.errors).to eql [[:class_method_missing, :icons]]
193
+ end
194
+ end
195
+
196
+ context "without fields method" do
197
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
198
+ def self.label
199
+ "foo"
200
+ end
201
+
202
+ def self.note
203
+ "foo"
204
+ end
205
+
206
+ def self.icons
207
+ {}
208
+ end
209
+
210
+ def configured?
211
+ true
212
+ end
213
+
214
+ def errors
215
+ true
216
+ end
217
+
218
+ def create_issue
219
+ "http"
220
+ end
221
+
222
+ def close_issue
223
+ "http"
224
+ end
225
+
226
+ def url
227
+ "http"
228
+ end
229
+ end
230
+
231
+ it "not valid" do
232
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
233
+ end
234
+
235
+ it "say not implement fields method" do
236
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
237
+ is.valid?
238
+ expect(is.errors).to eql [[:class_method_missing, :fields]]
239
+ end
240
+ end
241
+
242
+ context "without configured? method" do
243
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
244
+ def self.label
245
+ "foo"
246
+ end
247
+
248
+ def self.note
249
+ "foo"
250
+ end
251
+
252
+ def self.fields
253
+ ["foo"]
254
+ end
255
+
256
+ def self.icons
257
+ {}
258
+ end
259
+
260
+ def errors
261
+ true
262
+ end
263
+
264
+ def create_issue
265
+ "http"
266
+ end
267
+
268
+ def close_issue
269
+ "http"
270
+ end
271
+
272
+ def url
273
+ "http"
274
+ end
275
+ end
276
+
277
+ it "not valid" do
278
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
279
+ end
280
+
281
+ it "say not implement configured? method" do
282
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
283
+ is.valid?
284
+ expect(is.errors).to eql [[:instance_method_missing, :configured?]]
285
+ end
286
+ end
287
+
288
+ context "without errors method" do
289
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
290
+ def self.label
291
+ "foo"
292
+ end
293
+
294
+ def self.note
295
+ "foo"
296
+ end
297
+
298
+ def self.fields
299
+ ["foo"]
300
+ end
301
+
302
+ def self.icons
303
+ {}
304
+ end
305
+
306
+ def configured?
307
+ true
308
+ end
309
+
310
+ def create_issue
311
+ "http"
312
+ end
313
+
314
+ def close_issue
315
+ "http"
316
+ end
317
+
318
+ def url
319
+ "http"
320
+ end
321
+ end
322
+
323
+ it "not valid" do
324
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
325
+ end
326
+
327
+ it "say not implement errors method" do
328
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
329
+ is.valid?
330
+ expect(is.errors).to eql [[:instance_method_missing, :errors]]
331
+ end
332
+ end
333
+
334
+ context "without create_issue method" do
335
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
336
+ def self.label
337
+ "foo"
338
+ end
339
+
340
+ def self.note
341
+ "foo"
342
+ end
343
+
344
+ def self.fields
345
+ ["foo"]
346
+ end
347
+
348
+ def self.icons
349
+ {}
350
+ end
351
+
352
+ def configured?
353
+ true
354
+ end
355
+
356
+ def errors
357
+ true
358
+ end
359
+
360
+ def close_issue
361
+ "http"
362
+ end
363
+
364
+ def url
365
+ "http"
366
+ end
367
+ end
368
+
369
+ it "not valid" do
370
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
371
+ end
372
+ it "say not implement create_issue method" do
373
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
374
+ is.valid?
375
+ expect(is.errors).to eql [[:instance_method_missing, :create_issue]]
376
+ end
377
+ end
378
+
379
+ context "without close_issue method" do
380
+ # this is an optional method
381
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
382
+ def self.label
383
+ "foo"
384
+ end
385
+
386
+ def self.note
387
+ "foo"
388
+ end
389
+
390
+ def self.fields
391
+ ["foo"]
392
+ end
393
+
394
+ def self.icons
395
+ {}
396
+ end
397
+
398
+ def configured?
399
+ true
400
+ end
401
+
402
+ def errors
403
+ true
404
+ end
405
+
406
+ def create_issue
407
+ "http"
408
+ end
409
+
410
+ def url
411
+ "http"
412
+ end
413
+ end
414
+
415
+ it "is valid" do
416
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be true
417
+ end
418
+ it "not say not implement close_issue method" do
419
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
420
+ is.valid?
421
+ expect(is.errors).not_to eql [[:instance_method_missing, :close_issue]]
422
+ end
423
+ end
424
+
425
+ context "without url method" do
426
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
427
+ def self.label
428
+ "foo"
429
+ end
430
+
431
+ def self.note
432
+ "foo"
433
+ end
434
+
435
+ def self.fields
436
+ ["foo"]
437
+ end
438
+
439
+ def self.icons
440
+ {}
441
+ end
442
+
443
+ def configured?
444
+ true
445
+ end
446
+
447
+ def errors
448
+ true
449
+ end
450
+
451
+ def create_issue
452
+ "http"
453
+ end
454
+
455
+ def close_issue
456
+ "http"
457
+ end
458
+ end
459
+
460
+ it "not valid" do
461
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
462
+ end
463
+
464
+ it "say not implement url method" do
465
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
466
+ is.valid?
467
+ expect(is.errors).to eql [[:instance_method_missing, :url]]
468
+ end
469
+ end
470
+
471
+ context "without note method" do
472
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
473
+ def self.label
474
+ "foo"
475
+ end
476
+
477
+ def self.fields
478
+ ["foo"]
479
+ end
480
+
481
+ def self.icons
482
+ {}
483
+ end
484
+
485
+ def configured?
486
+ true
487
+ end
488
+
489
+ def errors
490
+ true
491
+ end
492
+
493
+ def create_issue
494
+ "http"
495
+ end
496
+
497
+ def close_issue
498
+ "http"
499
+ end
500
+
501
+ def url
502
+ "foo"
503
+ end
504
+ end
505
+
506
+ it "not valid" do
507
+ expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
508
+ end
509
+
510
+ it "say not implement note method" do
511
+ is = ErrbitPlugin::IssueTrackerValidator.new(klass)
512
+ is.valid?
513
+ expect(is.errors).to eql [[:class_method_missing, :note]]
514
+ end
515
+ end
516
+ end
517
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe ErrbitPlugin::NoneIssueTracker do
6
+ let(:options) { {} }
7
+
8
+ subject { described_class.new(options) }
9
+
10
+ it { expect(subject).to be_an(ErrbitPlugin::IssueTracker) }
11
+
12
+ it { expect(subject.configured?).to eq(false) }
13
+
14
+ it { expect(subject.errors).to eq({}) }
15
+
16
+ it { expect(subject.url).to eq("") }
17
+
18
+ it { expect(subject.create_issue).to eq(false) }
19
+
20
+ it { expect(subject.close_issue).to eq(false) }
21
+
22
+ it { expect(described_class.label).to eq("none") }
23
+
24
+ it { expect(described_class.note).to start_with("When no issue tracker") }
25
+
26
+ it { expect(described_class.fields).to eq({}) }
27
+
28
+ it { expect(described_class.icons).not_to be_empty }
29
+
30
+ # TODO: .read_static_file
31
+ end
@@ -1,6 +1,8 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe ErrbitPlugin::Registry do
3
+ require "spec_helper"
4
+
5
+ RSpec.describe ErrbitPlugin::Registry do
4
6
  before do
5
7
  ErrbitPlugin::Registry.clear_issue_trackers
6
8
  end
@@ -8,7 +10,7 @@ describe ErrbitPlugin::Registry do
8
10
  let(:tracker) {
9
11
  tracker = Class.new(ErrbitPlugin::IssueTracker) do
10
12
  def self.label
11
- 'something'
13
+ "something"
12
14
  end
13
15
  end
14
16
  tracker
@@ -17,19 +19,19 @@ describe ErrbitPlugin::Registry do
17
19
  describe ".add_issue_tracker" do
18
20
  context "with issue_tracker class valid" do
19
21
  before do
20
- allow(ErrbitPlugin::ValidateIssueTracker)
22
+ allow(ErrbitPlugin::IssueTrackerValidator)
21
23
  .to receive(:new)
22
24
  .with(tracker)
23
- .and_return(double(:valid? => true, :message => ''))
25
+ .and_return(double(valid?: true, message: ""))
24
26
  end
25
- it 'add new issue_tracker plugin' do
27
+ it "add new issue_tracker plugin" do
26
28
  ErrbitPlugin::Registry.add_issue_tracker(tracker)
27
29
  expect(ErrbitPlugin::Registry.issue_trackers).to eq({
28
- 'something' => tracker
30
+ "something" => tracker
29
31
  })
30
32
  end
31
33
  context "with already issue_tracker with this key" do
32
- it 'raise ErrbitPlugin::AlreadyRegisteredError' do
34
+ it "raise ErrbitPlugin::AlreadyRegisteredError" do
33
35
  ErrbitPlugin::Registry.add_issue_tracker(tracker)
34
36
  expect {
35
37
  ErrbitPlugin::Registry.add_issue_tracker(tracker)
@@ -39,26 +41,26 @@ describe ErrbitPlugin::Registry do
39
41
  end
40
42
 
41
43
  context "with an IssueTracker not valid" do
42
- it 'raise an IncompatibilityError' do
43
- allow(ErrbitPlugin::ValidateIssueTracker)
44
+ it "raise an IncompatibilityError" do
45
+ allow(ErrbitPlugin::IssueTrackerValidator)
44
46
  .to receive(:new)
45
47
  .with(tracker)
46
- .and_return(double(:valid? => false, :message => 'foo', :errors => []))
48
+ .and_return(double(valid?: false, message: "foo", errors: []))
47
49
  expect {
48
50
  ErrbitPlugin::Registry.add_issue_tracker(tracker)
49
51
  }.to raise_error(ErrbitPlugin::IncompatibilityError)
50
52
  end
51
53
 
52
- it 'puts the errors in the exception message' do
53
- allow(ErrbitPlugin::ValidateIssueTracker)
54
+ it "puts the errors in the exception message" do
55
+ allow(ErrbitPlugin::IssueTrackerValidator)
54
56
  .to receive(:new)
55
57
  .with(tracker)
56
- .and_return(double(:valid? => false, :message => 'foo', :errors => ['one', 'two']))
58
+ .and_return(double(valid?: false, message: "foo", errors: ["one", "two"]))
57
59
 
58
60
  begin
59
61
  ErrbitPlugin::Registry.add_issue_tracker(tracker)
60
62
  rescue ErrbitPlugin::IncompatibilityError => e
61
- expect(e.message).to eq('one; two')
63
+ expect(e.message).to eq("one; two")
62
64
  end
63
65
  end
64
66
  end
data/spec/spec_helper.rb CHANGED
@@ -1,26 +1,25 @@
1
- if ENV['COVERAGE']
2
- require 'simplecov'
3
- if ENV['CI']
4
- require 'coveralls'
5
- Coveralls.wear!
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
- SimpleCov::Formatter::HTMLFormatter,
8
- Coveralls::SimpleCov::Formatter
9
- ]
10
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+
5
+ SimpleCov.start do
6
+ enable_coverage :branch
7
+
8
+ primary_coverage :branch
11
9
 
12
- SimpleCov.start
10
+ add_filter "spec/"
13
11
  end
14
12
 
15
- require 'errbit_plugin'
13
+ require "errbit_plugin"
16
14
 
17
15
  RSpec.configure do |config|
18
- config.run_all_when_everything_filtered = true
19
- config.filter_run :focus
20
-
21
- # Run specs in random order to surface order dependencies. If you find an
22
- # order dependency and want to debug it, you can fix the order by providing
23
- # the seed, which is printed after each run.
24
- # --seed 1234
25
- config.order = 'random'
16
+ # Enable flags like --only-failures and --next-failure
17
+ config.example_status_persistence_file_path = ".rspec_status"
18
+
19
+ # Disable RSpec exposing methods globally on `Module` and `main`
20
+ config.disable_monkey_patching!
21
+
22
+ config.expect_with :rspec do |c|
23
+ c.syntax = :expect
24
+ end
26
25
  end