git_fame 2.5.3 → 3.0.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.
@@ -1,488 +0,0 @@
1
- describe GitFame::Base do
2
- let(:subject) { GitFame::Base.new({ repository: repository }) }
3
-
4
- describe "#authors" do
5
- it "should have a list of authors" do
6
- subject.should have(3).authors
7
- end
8
-
9
- describe "author" do
10
- let(:author) do
11
- subject.authors.find do |author|
12
- author.name.include?("Magnus Holm")
13
- end
14
- end
15
-
16
- it "should have a bunch of commits" do
17
- author.raw(:commits).should eq(41)
18
- end
19
-
20
- it "should respond to name" do
21
- author.name.should eq("Magnus Holm")
22
- end
23
-
24
- it "should have a number of locs" do
25
- author.raw(:loc).should eq(575)
26
- end
27
-
28
- it "should have a number of files" do
29
- author.raw(:files).should eq(4)
30
- end
31
-
32
- it "should have a distribution" do
33
- author.distribution.should eq("53.7 / 58.6 / 25.0")
34
- end
35
- end
36
-
37
- describe "format" do
38
- let(:author) do
39
- GitFame::Author.new({
40
- raw_commits: 12345,
41
- raw_files: 6789,
42
- raw_loc: 1234
43
- })
44
- end
45
-
46
- it "should format #commits" do
47
- author.commits.should eq("12,345")
48
- end
49
-
50
- it "should format #files" do
51
- author.files.should eq("6,789")
52
- end
53
-
54
- it "should format #loc" do
55
- author.loc.should eq("1,234")
56
- end
57
- end
58
- end
59
-
60
- describe "total" do
61
- it "should respond to #loc, #commits and #files" do
62
- subject.files.should eq(16)
63
- subject.commits.should eq(70)
64
- subject.loc.should eq(1071)
65
- end
66
- end
67
-
68
- describe "sort" do
69
- it "should be able to sort #authors by name" do
70
- authors = GitFame::Base.new({
71
- repository: repository,
72
- sort: "name"
73
- }).authors
74
- authors.map(&:name).
75
- should eq(["7rans", "Linus Oleander", "Magnus Holm"])
76
- end
77
-
78
- it "should be able to sort #authors by commits" do
79
- authors = GitFame::Base.new({
80
- repository: repository,
81
- sort: "commits"
82
- }).authors
83
-
84
- authors.map(&:name).
85
- should eq(["Magnus Holm", "Linus Oleander", "7rans"])
86
- end
87
-
88
- it "should be able to sort #authors by files" do
89
- authors = GitFame::Base.new({
90
- repository: repository,
91
- sort: "files"
92
- }).authors
93
- authors.map(&:name).
94
- should eq(["7rans", "Linus Oleander", "Magnus Holm"])
95
- end
96
-
97
- it "should be able to sort #authors by loc" do
98
- authors = GitFame::Base.new({
99
- repository: repository,
100
- sort: "loc"
101
- }).authors
102
- authors.map(&:name).
103
- should eq(["Magnus Holm", "7rans", "Linus Oleander"])
104
- end
105
- end
106
-
107
- describe "exclude" do
108
- let(:subject) do
109
- GitFame::Base.new({
110
- repository: repository,
111
- exclude: "lib/*"
112
- })
113
- end
114
-
115
- it "should exclude the lib folder" do
116
- subject.file_list.map(&:path).should_not include("lib/gash.rb")
117
- end
118
-
119
- it "should exclude non rb or rdoc files" do
120
- subject.file_list.map(&:path).should include("HISTORY")
121
- end
122
-
123
- it "should exclude non matching paths" do
124
- subject.file_list.map(&:path).should include("spec/gash_spec.rb")
125
- end
126
- end
127
-
128
- describe "types" do
129
- let(:subject) do
130
- GitFame::Base.new({
131
- repository: repository,
132
- by_type: true,
133
- extensions: "rb,rdoc"
134
- })
135
- end
136
-
137
- let(:author) do
138
- subject.authors.find do |author|
139
- author.name == "7rans"
140
- end
141
- end
142
-
143
- it "should break out counts by file type" do
144
- author.file_type_counts["rdoc"].should eq(1)
145
- end
146
-
147
- it "should output zero for file types the author hasn't touched" do
148
- author.file_type_counts["derp"].should eq(0)
149
- end
150
- end
151
-
152
- describe "include" do
153
- let(:subject) do
154
- GitFame::Base.new({
155
- repository: repository,
156
- include: "lib/*,spec/*"
157
- })
158
- end
159
-
160
- it "should exclude the lib folder" do
161
- subject.file_list.map(&:path).should include("lib/gash.rb")
162
- end
163
-
164
- it "should exclude non rb or rdoc files" do
165
- subject.file_list.map(&:path).should_not include("HISTORY")
166
- end
167
-
168
- it "should exclude non matching paths" do
169
- subject.file_list.map(&:path).should include("spec/gash_spec.rb")
170
- end
171
- end
172
-
173
- context "glob" do
174
- it "should exclude" do
175
- GitFame::Base.new({
176
- repository: repository,
177
- exclude: "lib/*.rb"
178
- }).file_list.map(&:path).should_not include("lib/gash.rb")
179
- end
180
-
181
- it "should include" do
182
- GitFame::Base.new({
183
- repository: repository,
184
- include: "lib/*.rb"
185
- }).file_list.map(&:path).should include("lib/gash.rb")
186
- end
187
- end
188
-
189
- describe "#pretty_print" do
190
- it "should print" do
191
- lambda {
192
- 2.times { subject.pretty_puts }
193
- }.should_not raise_error
194
- end
195
- end
196
-
197
- describe "#csv_print" do
198
- it "should print" do
199
- lambda {
200
- subject.csv_puts
201
- }.should_not raise_error
202
- end
203
-
204
- it "should be equal to" do
205
- subject.to_csv.should eq([
206
- "name,loc,commits,files,distribution\n",
207
- "Magnus Holm,575,41,4,53.7 / 58.6 / 25.0\n",
208
- "7rans,360,6,10,33.6 / 8.6 / 62.5\n",
209
- "Linus Oleander,136,23,7,12.7 / 32.9 / 43.8\n",
210
- ].join)
211
- end
212
- end
213
-
214
- describe "branches", :this do
215
- it "should handle existing branches" do
216
- GitFame::Base.new({
217
- repository: repository,
218
- branch: "master"
219
- }).authors
220
- end
221
-
222
- it "should raise an error if branch doesn't exist" do
223
- expect {
224
- GitFame::Base.new({
225
- repository: repository,
226
- branch: "-----"
227
- }).authors
228
- }.to raise_error(GitFame::Error)
229
- end
230
-
231
- it "should not raise on empty branch (use fallback)" do
232
- GitFame::Base.new({
233
- repository: repository,
234
- branch: ""
235
- }).authors.should_not be_empty
236
-
237
- GitFame::Base.new({
238
- repository: repository,
239
- branch: nil
240
- }).authors.should_not be_empty
241
- end
242
- end
243
-
244
- describe "after", :this do
245
- it "should raise error if 'after' is to far in the future" do
246
- lambda do
247
- GitFame::Base.new({
248
- repository: repository,
249
- after: "2020-01-01"
250
- }).commits
251
- end.should raise_error(GitFame::Error)
252
- end
253
-
254
- it "should handle same day as HEAD" do
255
- GitFame::Base.new({
256
- repository: repository,
257
- after: "2012-05-23"
258
- }).commits.should eq(1)
259
- end
260
-
261
- it "should handle an out of scope 'after' date" do
262
- GitFame::Base.new({
263
- repository: repository,
264
- after: "2000-01-01"
265
- }).commits.should eq(70)
266
- end
267
- end
268
-
269
- describe "before", :this do
270
- it "should raise error if 'before' is to far back in history" do
271
- lambda do
272
- GitFame::Base.new({
273
- repository: repository,
274
- before: "1972-01-01"
275
- }).commits
276
- end.should raise_error(GitFame::Error)
277
- end
278
-
279
- it "should handle same day as last commit" do
280
- GitFame::Base.new({
281
- repository: repository,
282
- before: "2008-08-31"
283
- }).commits.should eq(1)
284
- end
285
-
286
- it "should handle an out of scope 'before' date" do
287
- GitFame::Base.new({
288
- repository: repository,
289
- before: "2050-01-01"
290
- }).commits.should eq(70)
291
- end
292
-
293
- it "should handle same day as last commit" do
294
- GitFame::Base.new({
295
- repository: repository,
296
- before: "2008-08-31"
297
- }).commits.should eq(1)
298
- end
299
-
300
- it "should validate before date" do
301
- lambda do
302
- GitFame::Base.new({
303
- repository: repository,
304
- before: "----"
305
- })
306
- end.should raise_error(GitFame::Error)
307
- end
308
-
309
- it "should validate before date" do
310
- lambda do
311
- GitFame::Base.new({
312
- repository: repository,
313
- after: "----"
314
- })
315
- end.should raise_error(GitFame::Error)
316
- end
317
- end
318
-
319
- describe "span", :this do
320
- it "should handle spans as inclusive" do
321
- GitFame::Base.new({
322
- repository: repository,
323
- after: "2008-09-01",
324
- before: "2008-09-03"
325
- }).commits.should eq(4)
326
- end
327
-
328
- it "should should possible a wide date span (include all)" do
329
- GitFame::Base.new({
330
- repository: repository,
331
- after: "2000-01-01",
332
- before: "2020-01-01"
333
- }).commits.should eq(70)
334
- end
335
-
336
- it "should handle a too early 'after'" do
337
- GitFame::Base.new({
338
- repository: repository,
339
- after: "2000-01-01",
340
- before: "2008-08-31"
341
- }).commits.should eq(1)
342
- end
343
-
344
- it "should catch empty commit span" do
345
- lambda do
346
- GitFame::Base.new({
347
- repository: repository,
348
- after: "2010-04-10",
349
- before: "2010-04-11"
350
- }).commits
351
- end.should raise_error(GitFame::Error)
352
- end
353
-
354
- it "should handle a too late 'before'" do
355
- GitFame::Base.new({
356
- repository: repository,
357
- after: "2012-02-29",
358
- before: "2030-01-01"
359
- }).commits.should eq(4)
360
- end
361
-
362
- it "should handle the after date same date as init commit" do
363
- GitFame::Base.new({
364
- repository: repository,
365
- after: "2008-08-31",
366
- before: "2008-09-03"
367
- }).commits.should eq(5)
368
- end
369
-
370
- it "should handle an existing before with an old after" do
371
- GitFame::Base.new({
372
- repository: repository,
373
- after: "2000-08-31",
374
- before: "2008-09-03"
375
- }).commits.should eq(5)
376
- end
377
-
378
- it "should handle an existing after with an old before" do
379
- GitFame::Base.new({
380
- repository: repository,
381
- after: "2012-05-23",
382
- before: "2020-01-01"
383
- }).commits.should eq(1)
384
- end
385
-
386
- it "should raise an error if after > before" do
387
- lambda do
388
- GitFame::Base.new({
389
- repository: repository,
390
- after: "2020-01-01",
391
- before: "2000-01-01"
392
- }).commits
393
- end.should raise_error(GitFame::Error)
394
- end
395
-
396
- it "should raise error if set too high" do
397
- lambda do
398
- GitFame::Base.new({
399
- repository: repository,
400
- after: "2030-01-01",
401
- before: "2050-01-01"
402
- }).commits
403
- end.should raise_error(GitFame::Error)
404
- end
405
-
406
- it "should raise error if set too low" do
407
- lambda do
408
- GitFame::Base.new({
409
- repository: repository,
410
- after: "1990-01-01",
411
- before: "2000-01-01"
412
- }).commits
413
- end.should raise_error(GitFame::Error)
414
- end
415
-
416
- it "should handle same day" do
417
- GitFame::Base.new({
418
- repository: repository,
419
- after: "2012-02-29",
420
- before: "2012-02-29"
421
- }).commits.should eq(3)
422
- end
423
-
424
- it "should handle same day (HEAD)" do
425
- GitFame::Base.new({
426
- repository: repository,
427
- after: "2012-05-23",
428
- before: "2012-05-23"
429
- }).commits.should eq(1)
430
- end
431
-
432
- it "should handle same day (last commit)" do
433
- GitFame::Base.new({
434
- repository: repository,
435
- after: "2008-08-31",
436
- before: "2008-08-31"
437
- }).commits.should eq(1)
438
- end
439
-
440
- it "should handle a non existent 'after' date" do
441
- GitFame::Base.new({
442
- repository: repository,
443
- after: "2008-09-02",
444
- before: "2008-09-04"
445
- }).commits.should eq(4)
446
- end
447
-
448
- it "should handle a non existent 'before' date" do
449
- GitFame::Base.new({
450
- repository: repository,
451
- after: "2008-09-04",
452
- before: "2008-09-05"
453
- }).commits.should eq(3)
454
- end
455
-
456
- it "should handle both non existent 'before' and 'after'" do
457
- GitFame::Base.new({
458
- repository: repository,
459
- after: "2008-09-02",
460
- before: "2008-09-05"
461
- }).commits.should eq(4)
462
- end
463
- end
464
-
465
- describe "sub modules" do
466
- it "should ignore any sub modules" do
467
- before = GitFame::Base.new({repository: repository})
468
- Dir.chdir(repository) do
469
- `git submodule deinit levenshteinish 2>&1`
470
- `git rm levenshteinish 2>&1`
471
- `git submodule add https://github.com/oleander/levenshteinish.git`
472
- `git submodule init`
473
- `git add . && git commit -m "Add submodule"`
474
- end
475
- after = GitFame::Base.new({repository: repository})
476
-
477
- before.authors.count.should eq(after.authors.count)
478
- before.authors.zip(after.authors).each do |authors|
479
- [:name, :raw_files, :raw_commits,
480
- :raw_loc, :files_list,
481
- :file_type_counts
482
- ].each do |field|
483
- authors[0].send(field).should eq(authors[1].send(field))
484
- end
485
- end
486
- end
487
- end
488
- end
data/spec/spec_helper.rb DELETED
@@ -1,65 +0,0 @@
1
- require "rspec"
2
- require "git_fame"
3
- require "coveralls"
4
- require "rspec/collection_matchers"
5
- require "rspec/expectations"
6
- require "pp"
7
- require "colorize"
8
- require_relative "./support/startup"
9
-
10
- Coveralls.wear!
11
-
12
- RSpec::Matchers.define :be_a_succees do
13
- match do |actual|
14
- actual.last
15
- end
16
-
17
- failure_message do |actual|
18
- "expected command to be a success, but failed"
19
- end
20
- end
21
-
22
- RSpec::Matchers.define :include_output do |expected|
23
- match do |actual|
24
- actual.first.include?(expected)
25
- end
26
-
27
- failure_message do |actual|
28
- "expected #{actual} to include #{expected}, but didn't"
29
- end
30
- end
31
-
32
- RSpec.configure do |config|
33
- # Set to false to allow Kernel#puts
34
- suppress_stdout = true
35
-
36
- config.include GitFame::Startup
37
- config.mock_with :rspec
38
- config.expect_with(:rspec) do |c|
39
- c.syntax = [:should, :expect]
40
- end
41
- config.mock_with :rspec do |mocks|
42
- mocks.syntax = :should
43
- end
44
- config.fail_fast = false
45
- config.before(:each) do
46
- Dir.chdir(repository) { system "git checkout 7ab01bc5a720 > /dev/null 2>&1" }
47
- end
48
- config.before(:suite) do
49
- ENV["TZ"] = "GMT-2"
50
- warn "-----------"
51
- warn "Current environment:".yellow
52
- warn "\t#{`git --version`.strip}"
53
- warn "\t#{`grep --version`.strip}"
54
- warn "Spec notes:".yellow
55
- if suppress_stdout
56
- warn "\tMessages to STDOUT has been suppressed. See spec/spec_helper.rb".red
57
- end
58
- warn "\tRequires git 2.x for specs to pass"
59
- warn "\tTime zone during testing is set to #{ENV["TZ"]}"
60
- warn "-----------"
61
- end
62
- config.before(:each) do
63
- $stdout.stub(:puts) if suppress_stdout
64
- end
65
- end
@@ -1,21 +0,0 @@
1
- require "open3"
2
-
3
- module GitFame
4
- module Startup
5
- def repository
6
- File.join(File.dirname(File.dirname(__FILE__)), "fixtures/gash")
7
- end
8
-
9
- def binary
10
- File.join(File.dirname(File.dirname(__FILE__)), "../bin/git-fame")
11
- end
12
-
13
- def run(*args)
14
- Open3.popen2e(*([binary] + args), chdir: repository) do |_, out, thread|
15
- return [out.read, thread.value.success?]
16
- end
17
- rescue Errno::ENOENT
18
- [$!.message, false]
19
- end
20
- end
21
- end