git_statistics 0.7.0 → 0.8.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,7 +1,6 @@
1
1
  module GitStatistics
2
2
  module Formatters
3
3
  class Console
4
-
5
4
  attr_reader :output
6
5
  attr_accessor :commits, :config
7
6
 
@@ -17,15 +16,15 @@ module GitStatistics
17
16
 
18
17
  # Acquire data based on sort type and top # to show
19
18
  data = @commits.author_top_n_type(sort.to_sym, top_n)
20
- raise "Parameter for --sort is not valid" if data.nil?
19
+ raise 'Parameter for --sort is not valid' if data.nil?
21
20
 
22
21
  # Create config
23
- @config = {:data => data,
24
- :author_length => Utilities.max_length_in_list(data.keys, 17),
25
- :language_length => Utilities.max_length_in_list(@commits.totals[:languages].keys, 8),
26
- :sort => sort,
27
- :email => email,
28
- :top_n => top_n}
22
+ @config = { data: data,
23
+ author_length: Utilities.max_length_in_list(data.keys, 17),
24
+ language_length: Utilities.max_length_in_list(@commits.totals[:languages].keys, 8),
25
+ sort: sort,
26
+ email: email,
27
+ top_n: top_n }
29
28
 
30
29
  # Acquire formatting pattern for output
31
30
  @pattern = "| %-#{config[:author_length]}s | %-#{config[:language_length]}s | %7s | %9s | %9s | %7s | %7s | %7s | %6s | %6s |"
@@ -39,14 +38,19 @@ module GitStatistics
39
38
 
40
39
  # Print query/header information
41
40
  print_header
41
+
42
42
  # Print per author information
43
43
  config[:data].each do |name, commit_data|
44
44
  print_row(name, commit_data)
45
45
  print_language_data(commit_data)
46
46
  end
47
+
47
48
  add_row separator
48
- print_row("Repository Totals", commit_totals)
49
+
50
+ print_row('Repository Totals', commit_totals)
49
51
  print_language_data(commit_totals)
52
+ add_row separator
53
+
50
54
  display!
51
55
  end
52
56
 
@@ -56,24 +60,24 @@ module GitStatistics
56
60
 
57
61
  def print_language_data(data)
58
62
  # Print information of each language for the data
59
- data[:languages].each do |language, commit_data|
60
- print_row("", commit_data, language)
63
+ data[:languages].sort.each do |language, commit_data|
64
+ print_row('', commit_data, language)
61
65
  end
62
66
  output
63
67
  end
64
68
 
65
69
  def print_row(name, commit_info, language = '')
66
70
  add_row format_for_row(name, language, commit_info[:commits],
67
- commit_info[:additions], commit_info[:deletions], commit_info[:added_files],
68
- commit_info[:deleted_files], commit_info[:renamed_files], commit_info[:copied_files], commit_info[:merges])
71
+ commit_info[:additions], commit_info[:deletions], commit_info[:added_files],
72
+ commit_info[:deleted_files], commit_info[:renamed_files], commit_info[:copied_files], commit_info[:merges])
69
73
  end
70
74
 
71
75
  def print_header
72
- get_author_info(@commits.stats.size)
73
- get_header_info
76
+ author_info(@commits.stats.size)
77
+ header_info
74
78
  end
75
79
 
76
- def get_header_info
80
+ def header_info
77
81
  add_row separator
78
82
  add_row format_for_row('Name/Email', 'Language', 'Commits', 'Additions', 'Deletions', 'Creates', 'Deletes', 'Renames', 'Copies', 'Merges')
79
83
  add_row separator
@@ -84,10 +88,10 @@ module GitStatistics
84
88
  end
85
89
 
86
90
  def separator
87
- ("-" * 89) + ("-" * config[:author_length]) + ("-" * config[:language_length])
91
+ ('-' * 89) + ('-' * config[:author_length]) + ('-' * config[:language_length])
88
92
  end
89
93
 
90
- def get_author_info(total_authors)
94
+ def author_info(total_authors)
91
95
  if config[:top_n] > 0 && config[:top_n] < total_authors
92
96
  add_row "Top #{config[:top_n]} authors(#{total_authors}) sorted by #{config[:sort]}"
93
97
  else
@@ -8,7 +8,7 @@ module GitStatistics
8
8
  attr_accessor :logger, :base_directory, :debugging
9
9
 
10
10
  def initialize
11
- @base_directory = File.expand_path("../..", __FILE__) + "/"
11
+ @base_directory = File.expand_path('../..', __FILE__) + '/'
12
12
  @debugging = false
13
13
  @logger = Logger.new(STDOUT)
14
14
  @logger.level = Logger::ERROR
@@ -29,8 +29,7 @@ module GitStatistics
29
29
  if /^(?<file>.+?):(?<line>\d+)(?::in `(?<method>.*)')?/ =~ message
30
30
  file = Regexp.last_match[:file]
31
31
  line = Regexp.last_match[:line]
32
- method = Regexp.last_match[:method]
33
- "#{file.sub(instance.base_directory, "")}:#{line}"
32
+ "#{file.sub(instance.base_directory, '')}:#{line}"
34
33
  end
35
34
  end
36
35
 
@@ -43,7 +42,7 @@ module GitStatistics
43
42
  end
44
43
  end
45
44
 
46
- def self.respond_to_missing?(method, include_all=false)
45
+ def self.respond_to_missing?(method, include_all = false)
47
46
  if valid_method? method
48
47
  true
49
48
  else
@@ -54,6 +53,5 @@ module GitStatistics
54
53
  def self.valid_method?(method)
55
54
  instance.logger.respond_to? method
56
55
  end
57
-
58
56
  end
59
57
  end
@@ -19,7 +19,7 @@ module GitStatistics
19
19
  end
20
20
 
21
21
  def lines
22
- io.map { |line| line.strip.force_encoding("iso-8859-1").encode("utf-8") }
22
+ io.map { |line| line.strip.force_encoding('iso-8859-1').encode('utf-8') }
23
23
  end
24
24
 
25
25
  def io
@@ -2,22 +2,21 @@ require 'rbconfig'
2
2
 
3
3
  module GitStatistics
4
4
  module Utilities
5
-
6
5
  def self.max_length_in_list(list, min_length = nil)
7
6
  list ||= []
8
7
  min_length = min_length.to_i
9
- list_max = list.map { |k,_| k.length }.max || 0
8
+ list_max = list.map { |k, _| k.length }.max || 0
10
9
  list_max >= min_length ? list_max : min_length
11
10
  end
12
11
 
13
12
  COMMANDS = {
14
- :windows => ->{ raise "`stat` is not supported on Windows" },
15
- :mac => ->{ "-f %m" }
13
+ windows: -> { raise '`stat` is not supported on Windows' },
14
+ mac: -> { '-f %m' }
16
15
  }
17
- COMMANDS.default = ->{ "-c %Y" }
16
+ COMMANDS.default = -> { '-c %Y' }
18
17
 
19
18
  def self.get_modified_time(file)
20
- flags = COMMANDS[os].()
19
+ flags = COMMANDS[os].call
21
20
  time_at("stat #{flags} #{file}")
22
21
  end
23
22
 
@@ -31,12 +30,12 @@ module GitStatistics
31
30
  OPERATING_SYSTEMS.default = :unknown
32
31
 
33
32
  def self.determine(os_name)
34
- OPERATING_SYSTEMS.select { |k,_| k =~ os_name }.first
33
+ OPERATING_SYSTEMS.find { |k, _| k =~ os_name }
35
34
  end
36
35
  end
37
36
 
38
37
  def self.time_at(cmd)
39
- Time.at(%x{#{cmd}}.to_i)
38
+ Time.at(`#{cmd}`.to_i)
40
39
  end
41
40
 
42
41
  def self.os
@@ -49,6 +48,5 @@ module GitStatistics
49
48
  Log.error "No such directory #{File.expand_path(directory)}"
50
49
  0
51
50
  end
52
-
53
51
  end
54
52
  end
@@ -1,3 +1,3 @@
1
1
  module GitStatistics
2
- VERSION = "0.7.0"
2
+ VERSION = '0.8.0'
3
3
  end
@@ -2,124 +2,127 @@ require 'spec_helper'
2
2
  include GitStatistics
3
3
 
4
4
  describe Collector do
5
- let(:limit) {100}
6
- let(:fresh) {true}
7
- let(:pretty) {false}
5
+ let(:limit) { 100 }
6
+ let(:fresh) { true }
7
+ let(:pretty) { false }
8
8
  let(:repo) { GIT_REPO }
9
- let(:collector) {Collector.new(repo, limit, fresh, pretty)}
10
-
11
- describe "#collect" do
12
- let(:branch) {CLI::DEFAULT_BRANCH}
13
- let(:email) {false}
14
- let(:merge) {true}
15
- let(:time_since) {"Tue Sep 24 14:15:44 2012 -0400"}
16
- let(:time_until) {"Tue Sep 26 14:45:05 2012 -0400"}
17
- let(:author) {"Kevin Jalbert"}
18
-
19
- let(:setup) {
20
- collector.collect({:branch => branch, :time_since => time_since, :time_until => time_until})
9
+ let(:collector) { Collector.new(repo, limit, fresh, pretty) }
10
+
11
+ describe '#collect' do
12
+ let(:branch) { CLI::DEFAULT_BRANCH }
13
+ let(:email) { false }
14
+ let(:merge) { true }
15
+ let(:time_since) { 'Tue Sep 24 14:15:44 2012 -0400' }
16
+ let(:time_until) { 'Tue Sep 26 14:45:05 2012 -0400' }
17
+ let(:author) { 'Kevin Jalbert' }
18
+
19
+ subject do
20
+ collector.collect(branch: branch, time_since: time_since, time_until: time_until)
21
21
  collector.commits.calculate_statistics(email, merge)
22
- @subject = collector.commits.stats[author]
23
- }
24
-
25
- context "with no merge commits" do
26
- let(:merge) {false}
27
- let(:time_since) {"Tue Sep 10 14:15:44 2012 -0400"}
28
- let(:time_until) {"Tue Sep 11 14:45:05 2012 -0400"}
29
-
30
- before(:all) { setup }
31
-
32
- it{@subject[:additions].should == 276}
33
- it{@subject[:deletions].should == 99}
34
- it{@subject[:commits].should == 4}
35
- it{@subject[:merges].should == 0}
36
-
37
- it{@subject[:languages][:Ruby][:additions].should == 270}
38
- it{@subject[:languages][:Ruby][:deletions].should == 99}
39
- it{@subject[:languages][:Ruby][:added_files].should == 2}
40
- it{@subject[:languages][:Text][:additions].should == 6}
41
- it{@subject[:languages][:Text][:deletions].should == 0}
42
- it{@subject[:languages][:Text][:added_files].should == 1}
22
+ collector.commits.stats[author]
43
23
  end
44
24
 
45
- context "with merge commits and merge option" do
46
- before(:all) { setup }
47
-
48
- it{@subject[:additions].should == 1240}
49
- it{@subject[:deletions].should == 934}
50
- it{@subject[:commits].should == 9}
51
- it{@subject[:merges].should == 1}
25
+ context 'with no merge commits' do
26
+ let(:merge) { false }
27
+ let(:time_since) { 'Tue Sep 10 14:15:44 2012 -0400' }
28
+ let(:time_until) { 'Tue Sep 11 14:45:05 2012 -0400' }
29
+
30
+ it do
31
+ expect(subject[:additions]).to eq(276)
32
+ expect(subject[:deletions]).to eq(99)
33
+ expect(subject[:commits]).to eq(4)
34
+ expect(subject[:merges]).to eq(0)
35
+
36
+ expect(subject[:languages][:Ruby][:additions]).to eq(270)
37
+ expect(subject[:languages][:Ruby][:deletions]).to eq(99)
38
+ expect(subject[:languages][:Ruby][:added_files]).to eq(2)
39
+ expect(subject[:languages][:Text][:additions]).to eq(6)
40
+ expect(subject[:languages][:Text][:deletions]).to eq(0)
41
+ expect(subject[:languages][:Text][:added_files]).to eq(1)
42
+ end
43
+ end
52
44
 
53
- it{@subject[:languages][:Markdown][:additions].should == 1}
54
- it{@subject[:languages][:Markdown][:deletions].should == 0}
55
- it{@subject[:languages][:Ruby][:additions].should == 1227}
56
- it{@subject[:languages][:Ruby][:deletions].should == 934}
57
- it{@subject[:languages][:Unknown][:additions].should == 12}
58
- it{@subject[:languages][:Unknown][:deletions].should == 0}
45
+ context 'with merge commits and merge option' do
46
+ it do
47
+ expect(subject[:additions]).to eq(1240)
48
+ expect(subject[:deletions]).to eq(934)
49
+ expect(subject[:commits]).to eq(9)
50
+ expect(subject[:merges]).to eq(1)
51
+
52
+ expect(subject[:languages][:Markdown][:additions]).to eq(1)
53
+ expect(subject[:languages][:Markdown][:deletions]).to eq(0)
54
+ expect(subject[:languages][:Ruby][:additions]).to eq(1227)
55
+ expect(subject[:languages][:Ruby][:deletions]).to eq(934)
56
+ expect(subject[:languages][:Unknown][:additions]).to eq(12)
57
+ expect(subject[:languages][:Unknown][:deletions]).to eq(0)
58
+ end
59
59
  end
60
60
 
61
- context "with merge commits and no merge option" do
62
- let(:merge) {false}
63
- before(:all) { setup }
64
-
65
- it{@subject[:additions].should == 581}
66
- it{@subject[:deletions].should == 452}
67
- it{@subject[:commits].should == 8}
68
- it{@subject[:merges].should == 0}
69
-
70
- it{@subject[:languages][:Markdown][:additions].should == 1}
71
- it{@subject[:languages][:Markdown][:deletions].should == 0}
72
- it{@subject[:languages][:Ruby][:additions].should == 574}
73
- it{@subject[:languages][:Ruby][:deletions].should == 452}
74
- it{@subject[:languages][:Unknown][:additions].should == 6}
75
- it{@subject[:languages][:Unknown][:deletions].should == 0}
61
+ context 'with merge commits and no merge option' do
62
+ let(:merge) { false }
63
+
64
+ it do
65
+ expect(subject[:additions]).to eq(581)
66
+ expect(subject[:deletions]).to eq(452)
67
+ expect(subject[:commits]).to eq(8)
68
+ expect(subject[:merges]).to eq(0)
69
+
70
+ expect(subject[:languages][:Markdown][:additions]).to eq(1)
71
+ expect(subject[:languages][:Markdown][:deletions]).to eq(0)
72
+ expect(subject[:languages][:Ruby][:additions]).to eq(574)
73
+ expect(subject[:languages][:Ruby][:deletions]).to eq(452)
74
+ expect(subject[:languages][:Unknown][:additions]).to eq(6)
75
+ expect(subject[:languages][:Unknown][:deletions]).to eq(0)
76
+ end
76
77
  end
77
78
  end
78
79
 
79
- describe "#extract_commit" do
80
- let(:commit) {repo.lookup(sha)}
81
- let(:data) {collector.extract_commit(commit, nil)}
82
-
83
- context "with valid commit" do
84
- let(:sha) {"260bc61e2c42930d91f3503c5849b0a2351275cf"}
85
- it {data[:author].should == "Kevin Jalbert"}
86
- it {data[:author_email].should == "kevin.j.jalbert@gmail.com"}
87
- it {data[:time].should match /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-|+]\d{4}/}
88
-
89
- it {data[:merge].should == false}
90
- it {data[:additions].should == 30}
91
- it {data[:deletions].should == 2}
92
- it {data[:added_files].should == 1}
93
- it {data[:deleted_files].should == 0}
94
-
95
- it {data[:files][0][:filename].should == "Gemfile"}
96
- it {data[:files][0][:additions].should == 0}
97
- it {data[:files][0][:deletions].should == 1}
98
- it {data[:files][0][:status].should.nil?}
99
- it {data[:files][0][:language].should == "Ruby"}
100
-
101
- it {data[:files][1][:filename].should == "Gemfile.lock"}
102
- it {data[:files][1][:additions].should == 30}
103
- it {data[:files][1][:deletions].should == 0}
104
- it {data[:files][1][:status].should eq(:added)}
105
- it {data[:files][1][:language].should == "Unknown"}
106
-
107
- it {data[:files][2][:filename].should == "lib/git_statistics/initialize.rb"}
108
- it {data[:files][2][:additions].should == 0}
109
- it {data[:files][2][:deletions].should == 1}
110
- it {data[:files][2][:status].should.nil?}
111
- it {data[:files][2][:language].should == "Ruby"}
80
+ describe '#extract_commit' do
81
+ let(:commit) { repo.lookup(sha) }
82
+ let(:data) { collector.extract_commit(commit, nil) }
83
+
84
+ context 'with valid commit' do
85
+ let(:sha) { '260bc61e2c42930d91f3503c5849b0a2351275cf' }
86
+
87
+ it do
88
+ expect(data[:author]).to eq('Kevin Jalbert')
89
+ expect(data[:author_email]).to eq('kevin.j.jalbert@gmail.com')
90
+ expect(data[:time]).to match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-|+]\d{4}/)
91
+
92
+ expect(data[:merge]).to eq(false)
93
+ expect(data[:additions]).to eq(30)
94
+ expect(data[:deletions]).to eq(2)
95
+ expect(data[:added_files]).to eq(1)
96
+ expect(data[:deleted_files]).to eq(0)
97
+
98
+ expect(data[:files][0][:filename]).to eq('Gemfile')
99
+ expect(data[:files][0][:additions]).to eq(0)
100
+ expect(data[:files][0][:deletions]).to eq(1)
101
+ expect(data[:files][0][:status]).to eq(:modified)
102
+ expect(data[:files][0][:language]).to eq('Ruby')
103
+
104
+ expect(data[:files][1][:filename]).to eq('Gemfile.lock')
105
+ expect(data[:files][1][:additions]).to eq(30)
106
+ expect(data[:files][1][:deletions]).to eq(0)
107
+ expect(data[:files][1][:status]).to eq(:added)
108
+ expect(data[:files][1][:language]).to eq('Unknown')
109
+
110
+ expect(data[:files][2][:filename]).to eq('lib/git_statistics/initialize.rb')
111
+ expect(data[:files][2][:additions]).to eq(0)
112
+ expect(data[:files][2][:deletions]).to eq(1)
113
+ expect(data[:files][2][:status]).to eq(:modified)
114
+ expect(data[:files][2][:language]).to eq('Ruby')
115
+ end
112
116
  end
113
117
 
114
- context "with invalid commit" do
115
- let(:sha) {"111111aa111a11111a11aa11aaaa11a111111a11"}
116
- it { expect {data}.to raise_error(Rugged::OdbError) }
118
+ context 'with invalid commit' do
119
+ let(:sha) { '111111aa111a11111a11aa11aaaa11a111111a11' }
120
+ it { expect { data }.to raise_error(Rugged::OdbError) }
117
121
  end
118
122
 
119
- context "with invalid sha" do
120
- let(:sha) {"invalid input"}
121
- it { expect {data}.to raise_error(Rugged::InvalidError) }
123
+ context 'with invalid sha' do
124
+ let(:sha) { 'invalid input' }
125
+ it { expect { data }.to raise_error(Rugged::InvalidError) }
122
126
  end
123
127
  end
124
-
125
128
  end
@@ -2,125 +2,151 @@ require 'spec_helper'
2
2
  include GitStatistics
3
3
 
4
4
  describe CommitSummary do
5
-
6
- let(:sha) { "bf09a64b0e0f801d3e7fe4e002cbd1bf517340a7" }
5
+ let(:sha) { 'bf09a64b0e0f801d3e7fe4e002cbd1bf517340a7' }
7
6
  let(:repo) { GIT_REPO }
8
7
  subject(:commit) { CommitSummary.new(repo, repo.lookup(sha)) }
9
8
 
10
- its(:__getobj__) { should be_a Rugged::Commit }
9
+ it { expect(subject.__getobj__).to be_a(Rugged::Commit) }
11
10
 
12
- context "understands its files and languages" do
13
- its(:filenames) { should have(3).items }
14
- its(:languages) { should have(1).items }
11
+ context 'understands its files and languages' do
12
+ it do
13
+ expect(subject.filenames.size).to eq(3)
14
+ expect(subject.languages.size).to eq(1)
15
+ end
15
16
  end
16
17
 
17
- context "language-specific changes" do
18
- let(:name) { "Ruby" }
19
- subject(:language) { commit.languages.detect { |lang| lang.name == name } }
20
- context "for commit 2aa45e4ff23c1a558b127c06e95d313a56cc6890" do
21
- let(:sha) { "2aa45e4ff23c1a558b127c06e95d313a56cc6890" }
22
- context "language count" do
23
- subject { commit }
24
- its(:languages) { should have(2).items }
18
+ context 'language-specific changes' do
19
+ let(:name) { 'Ruby' }
20
+ subject(:language) { commit.languages.find { |lang| lang.name == name } }
21
+
22
+ context 'for commit 2aa45e4ff23c1a558b127c06e95d313a56cc6890' do
23
+ let(:sha) { '2aa45e4ff23c1a558b127c06e95d313a56cc6890' }
24
+
25
+ context 'language count' do
26
+ it { expect(commit.languages.size).to eq(2) }
25
27
  end
26
- context "Ruby" do
27
- let(:name) { "Ruby" }
28
- its(:additions) { should == 14 }
29
- its(:deletions) { should == 13 }
30
- its(:net) { should == 1 }
28
+
29
+ context 'Ruby' do
30
+ let(:name) { 'Ruby' }
31
+ it do
32
+ expect(subject.additions).to eq(14)
33
+ expect(subject.deletions).to eq(13)
34
+ expect(subject.net).to eq(1)
35
+ end
31
36
  end
32
- context "Text" do
33
- let(:name) { "Text" }
34
- its(:additions) { should == 7 }
35
- its(:deletions) { should == 11 }
36
- its(:net) { should == -4 }
37
+
38
+ context 'Text' do
39
+ let(:name) { 'Text' }
40
+ it do
41
+ expect(subject.additions).to eq(7)
42
+ expect(subject.deletions).to eq(11)
43
+ expect(subject.net).to eq(-4)
44
+ end
37
45
  end
38
46
  end
39
- context "for commit bf09a64b" do
47
+
48
+ context 'for commit bf09a64b' do
40
49
  subject { commit.languages.first }
41
- its(:name) { should == "Ruby" }
42
- its(:additions) { should == 10 }
43
- its(:deletions) { should == 27 }
44
- its(:net) { should == -17 }
50
+ it do
51
+ expect(subject.name).to eq('Ruby')
52
+ expect(subject.additions).to eq(10)
53
+ expect(subject.deletions).to eq(27)
54
+ expect(subject.net).to eq(-17)
55
+ end
45
56
  end
46
57
  end
47
58
 
48
- context "file-specific changes" do
49
- let(:name) { "lib/git_statistics/formatters/console.rb" }
50
- subject(:file) { commit.file_stats.detect { |file| file.filename == name } }
51
- context "for commit ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd" do
52
- let(:sha) { "ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd" }
53
- context "file count" do
54
- subject { commit }
55
- its(:filenames) { should have(12).items }
59
+ context 'file-specific changes' do
60
+ let(:name) { 'lib/git_statistics/formatters/console.rb' }
61
+ subject(:file) { commit.file_stats.find { |file| file.filename == name } }
62
+
63
+ context 'for commit ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd' do
64
+ let(:sha) { 'ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd' }
65
+
66
+ context 'file count' do
67
+ it { expect(commit.filenames.size).to eq(12) }
56
68
  end
57
- context "bin/git_statistics (new)" do
58
- let(:name) { "bin/git_statistics" }
59
- its(:language) { should == "Ruby" }
60
- its(:additions) { should == 5 }
61
- its(:deletions) { should == 0 }
62
- its(:net) { should == 5 }
63
- its(:status) { should == :added }
69
+
70
+ context 'bin/git_statistics (new)' do
71
+ let(:name) { 'bin/git_statistics' }
72
+ it do
73
+ expect(subject.language).to eq('Ruby')
74
+ expect(subject.additions).to eq(5)
75
+ expect(subject.deletions).to eq(0)
76
+ expect(subject.net).to eq(5)
77
+ expect(subject.status).to eq(:added)
78
+ end
64
79
  end
65
- context "lib/initialize.rb (deleted)" do
66
- let(:name) { "lib/initialize.rb" }
67
- its(:language) { should == "Ruby" }
68
- its(:additions) { should == 0 }
69
- its(:deletions) { should == 4 }
70
- its(:net) { should == -4 }
71
- its(:status) { should == :deleted }
80
+
81
+ context 'lib/initialize.rb (deleted)' do
82
+ let(:name) { 'lib/initialize.rb' }
83
+ it do
84
+ expect(subject.language).to eq('Ruby')
85
+ expect(subject.additions).to eq(0)
86
+ expect(subject.deletions).to eq(4)
87
+ expect(subject.net).to eq(-4)
88
+ expect(subject.status).to eq(:deleted)
89
+ end
72
90
  end
73
- context "lib/git_statistics.rb (modified)" do
74
- let(:name) { "lib/git_statistics.rb" }
75
- its(:language) { should == "Ruby" }
76
- its(:additions) { should == 37 }
77
- its(:deletions) { should == 30 }
78
- its(:net) { should == 7 }
79
- its(:status) { should == :modified }
91
+
92
+ context 'lib/git_statistics.rb (modified)' do
93
+ let(:name) { 'lib/git_statistics.rb' }
94
+ it do
95
+ expect(subject.language).to eq('Ruby')
96
+ expect(subject.additions).to eq(37)
97
+ expect(subject.deletions).to eq(30)
98
+ expect(subject.net).to eq(7)
99
+ expect(subject.status).to eq(:modified)
100
+ end
80
101
  end
81
102
  end
82
103
  end
83
104
 
84
- context "with a removed file" do
85
- let(:sha) { "4ce86b844458a1fd77c6066c9297576b9520f97e" }
86
- its(:deleted_files) { should == 2 }
105
+ context 'with a removed file' do
106
+ let(:sha) { '4ce86b844458a1fd77c6066c9297576b9520f97e' }
107
+ it { expect(subject.deleted_files).to eq(2) }
87
108
  end
88
109
 
89
- context "without a removed file" do
90
- let(:sha) { "b808b3a9d4ce2d8a1d850f2c24d2d1fb00e67727" }
91
- its(:deleted_files) { should == 0 }
110
+ context 'without a removed file' do
111
+ let(:sha) { 'b808b3a9d4ce2d8a1d850f2c24d2d1fb00e67727' }
112
+ it { expect(subject.deleted_files).to eq(0) }
92
113
  end
93
114
 
94
- context "with a new file" do
95
- let(:sha) { "8b1941437a0ff8cf6a35a46d4f5df8b6587c346f" }
96
- its(:added_files) { should == 19 }
115
+ context 'with a new file' do
116
+ let(:sha) { '8b1941437a0ff8cf6a35a46d4f5df8b6587c346f' }
117
+ it { expect(subject.added_files).to eq(19) }
97
118
  end
98
119
 
99
- context "without a new file" do
100
- let(:sha) { "52f9f38cbe4ba90edd607298cb2f9b1aec26bcf1" }
101
- its(:added_files) { should == 0 }
120
+ context 'without a new file' do
121
+ let(:sha) { '52f9f38cbe4ba90edd607298cb2f9b1aec26bcf1' }
122
+ it { expect(subject.added_files).to eq(0) }
102
123
  end
103
124
 
104
- context "with a merge" do
105
- let(:sha) { "9d31467f6759c92f8535038c470d24a37ae93a9d" }
125
+ context 'with a merge' do
126
+ let(:sha) { '9d31467f6759c92f8535038c470d24a37ae93a9d' }
127
+
106
128
  it { should be_a_merge }
107
- context "statistics" do
108
- its(:filenames) { should have(11).items }
109
- its(:languages) { should have(1).items }
110
- its(:additions) { should == 69 }
111
- its(:deletions) { should == 68 }
112
- its(:net) { should == 1 }
129
+
130
+ context 'statistics' do
131
+ it do
132
+ expect(subject.filenames.size).to eq(11)
133
+ expect(subject.languages.size).to eq(1)
134
+ expect(subject.additions).to eq(69)
135
+ expect(subject.deletions).to eq(68)
136
+ expect(subject.net).to eq(1)
137
+ end
113
138
  end
114
139
  end
115
140
 
116
- context "without a merge" do
141
+ context 'without a merge' do
117
142
  it { should_not be_a_merge }
118
143
  end
119
144
 
120
- context "net, additions, and deletions" do
121
- its(:additions) { should == 10 }
122
- its(:deletions) { should == 27 }
123
- its(:net) { should == -17 }
145
+ context 'net, additions, and deletions' do
146
+ it do
147
+ expect(subject.additions).to eq(10)
148
+ expect(subject.deletions).to eq(27)
149
+ expect(subject.net).to eq(-17)
150
+ end
124
151
  end
125
-
126
152
  end