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.
@@ -3,174 +3,188 @@ include GitStatistics
3
3
  include GitStatistics::Formatters
4
4
 
5
5
  describe Console do
6
- let(:limit) {100}
7
- let(:fresh) {true}
8
- let(:pretty) {false}
6
+ let(:limit) { 100 }
7
+ let(:fresh) { true }
8
+ let(:pretty) { false }
9
9
  let(:repo) { GIT_REPO }
10
- let(:collector) {Collector.new(repo, limit, fresh, pretty)}
10
+ let(:collector) { Collector.new(repo, limit, fresh, pretty) }
11
11
 
12
- let(:commits) {collector.commits}
12
+ let(:commits) { collector.commits }
13
13
 
14
- let(:fixture_file) {"multiple_authors.json"}
15
- let(:save_file) { File.join(collector.commits_path, "0.json") }
16
- let(:email) {false}
17
- let(:merge) {false}
18
- let(:sort) {:commits}
19
- let(:top_n) {0}
14
+ let(:fixture_file) { 'multiple_authors.json' }
15
+ let(:save_file) { File.join(collector.commits_path, '0.json') }
16
+ let(:email) { false }
17
+ let(:merge) { false }
18
+ let(:sort) { :commits }
19
+ let(:top_n) { 0 }
20
20
 
21
- let(:results) {
21
+ let(:results) do
22
22
  setup_commits(commits, fixture_file, save_file, pretty)
23
23
  commits.calculate_statistics(email, merge)
24
24
  commits.author_top_n_type(sort)
25
- results = Console.new(commits)
26
- }
25
+ Console.new(commits)
26
+ end
27
27
 
28
- let(:config) {
28
+ let(:config) do
29
29
  results.prepare_result_summary(sort, email, top_n)
30
- }
30
+ end
31
31
 
32
32
  before { config }
33
33
 
34
- describe "#prepare_result_summary" do
35
- context "with email and sorting" do
36
- context "on first author" do
37
- let(:data) {config[:data]}
38
- author = "Kevin Jalbert"
39
- subject {data[author]}
40
-
41
- it {data.should have_key author}
42
-
43
- it {subject[:commits].should == 1}
44
- it {subject[:additions].should == 73}
45
- it {subject[:deletions].should == 0}
46
- it {subject[:added_files].should == 2}
47
-
48
- it {subject[:languages][:Ruby][:additions].should == 62}
49
- it {subject[:languages][:Ruby][:deletions].should == 0}
50
- it {subject[:languages][:Ruby][:added_files].should == 1}
51
- it {subject[:languages][:Markdown][:additions].should == 11}
52
- it {subject[:languages][:Markdown][:deletions].should == 0}
53
- it {subject[:languages][:Markdown][:added_files].should == 1}
34
+ describe '#prepare_result_summary' do
35
+ context 'with email and sorting' do
36
+ context 'on first author' do
37
+ let(:data) { config[:data] }
38
+ author = 'Kevin Jalbert'
39
+ subject { data[author] }
40
+
41
+ it do
42
+ expect(data.key?(author)).to be true
43
+
44
+ expect(subject[:commits]).to eq(1)
45
+ expect(subject[:additions]).to eq(73)
46
+ expect(subject[:deletions]).to eq(0)
47
+ expect(subject[:added_files]).to eq(2)
48
+
49
+ expect(subject[:languages][:Ruby][:additions]).to eq(62)
50
+ expect(subject[:languages][:Ruby][:deletions]).to eq(0)
51
+ expect(subject[:languages][:Ruby][:added_files]).to eq(1)
52
+ expect(subject[:languages][:Markdown][:additions]).to eq(11)
53
+ expect(subject[:languages][:Markdown][:deletions]).to eq(0)
54
+ expect(subject[:languages][:Markdown][:added_files]).to eq(1)
55
+ end
54
56
  end
55
57
 
56
- context "on second author" do
57
- let(:data) {config[:data]}
58
- author = "John Smith"
59
- subject {data[author]}
58
+ context 'on second author' do
59
+ let(:data) { config[:data] }
60
+ author = 'John Smith'
61
+ subject { data[author] }
60
62
 
61
- it {data.has_key?(author).should be_true}
62
- it {subject[:commits].should == 1}
63
- it {subject[:additions].should == 64}
64
- it {subject[:deletions].should == 16}
63
+ it do
64
+ expect(data.key?(author)).to be true
65
+ expect(subject[:commits]).to eq(1)
66
+ expect(subject[:additions]).to eq(64)
67
+ expect(subject[:deletions]).to eq(16)
65
68
 
66
- it {subject[:languages][:Ruby][:additions].should == 64}
67
- it {subject[:languages][:Ruby][:deletions].should == 16}
69
+ expect(subject[:languages][:Ruby][:additions]).to eq(64)
70
+ expect(subject[:languages][:Ruby][:deletions]).to eq(16)
71
+ end
68
72
  end
69
73
 
70
- it {config[:sort].should == sort}
71
- it {config[:email].should == email}
72
- it {config[:top_n].should == top_n}
73
- it {config[:author_length].should == 17}
74
- it {config[:language_length].should == 8}
74
+ it do
75
+ expect(config[:sort]).to eq(sort)
76
+ expect(config[:email]).to eq(email)
77
+ expect(config[:top_n]).to eq(top_n)
78
+ expect(config[:author_length]).to eq(17)
79
+ expect(config[:language_length]).to eq(8)
80
+ end
75
81
  end
76
82
 
77
- context "with negative top_n" do
78
- let(:top_n) {-1}
83
+ context 'with negative top_n' do
84
+ let(:top_n) { -1 }
85
+
86
+ context 'on first author' do
87
+ let(:data) { config[:data] }
88
+ author = 'Kevin Jalbert'
89
+ subject { data[author] }
90
+
91
+ it do
92
+ expect(data.key?(author)).to be true
93
+
94
+ expect(subject[:commits]).to eq(1)
95
+ expect(subject[:additions]).to eq(73)
96
+ expect(subject[:deletions]).to eq(0)
97
+ expect(subject[:added_files]).to eq(2)
98
+
99
+ expect(subject[:languages][:Ruby][:additions]).to eq(62)
100
+ expect(subject[:languages][:Ruby][:deletions]).to eq(0)
101
+ expect(subject[:languages][:Ruby][:added_files]).to eq(1)
102
+ expect(subject[:languages][:Markdown][:additions]).to eq(11)
103
+ expect(subject[:languages][:Markdown][:deletions]).to eq(0)
104
+ expect(subject[:languages][:Markdown][:added_files]).to eq(1)
105
+ end
106
+ end
79
107
 
80
- context "on first author" do
81
- let(:data) {config[:data]}
82
- author = "Kevin Jalbert"
83
- subject {data[author]}
108
+ context 'on second author' do
109
+ let(:data) { config[:data] }
110
+ author = 'John Smith'
111
+ subject { data[author] }
84
112
 
85
- it {data.has_key?(author).should be_true}
113
+ it do
114
+ expect(data.key?(author)).to be true
86
115
 
87
- it {subject[:commits].should == 1}
88
- it {subject[:additions].should == 73}
89
- it {subject[:deletions].should == 0}
90
- it {subject[:added_files].should == 2}
116
+ expect(subject[:commits]).to eq(1)
117
+ expect(subject[:additions]).to eq(64)
118
+ expect(subject[:deletions]).to eq(16)
91
119
 
92
- it {subject[:languages][:Ruby][:additions].should == 62}
93
- it {subject[:languages][:Ruby][:deletions].should == 0}
94
- it {subject[:languages][:Ruby][:added_files].should == 1}
95
- it {subject[:languages][:Markdown][:additions].should == 11}
96
- it {subject[:languages][:Markdown][:deletions].should == 0}
97
- it {subject[:languages][:Markdown][:added_files].should == 1}
120
+ expect(subject[:languages][:Ruby][:additions]).to eq(64)
121
+ expect(subject[:languages][:Ruby][:deletions]).to eq(16)
122
+ end
98
123
  end
99
124
 
100
- context "on second author" do
101
- let(:data) {config[:data]}
102
- author = "John Smith"
103
- subject {data[author]}
104
-
105
- it {data.has_key?(author).should be_true}
106
- it {subject[:commits].should == 1}
107
- it {subject[:additions].should == 64}
108
- it {subject[:deletions].should == 16}
109
-
110
- it {subject[:languages][:Ruby][:additions].should == 64}
111
- it {subject[:languages][:Ruby][:deletions].should == 16}
125
+ it do
126
+ expect(config[:sort]).to eq(sort)
127
+ expect(config[:email]).to eq(email)
128
+ expect(config[:top_n]).to eq(0)
129
+ expect(config[:author_length]).to eq(17)
130
+ expect(config[:language_length]).to eq(8)
112
131
  end
113
-
114
- it {config[:sort].should == sort}
115
- it {config[:email].should == email}
116
- it {config[:top_n].should == 0}
117
- it {config[:author_length].should == 17}
118
- it {config[:language_length].should == 8}
119
132
  end
120
133
 
121
- context "with top_n that filters to one author" do
122
- let(:top_n) {1}
123
- let(:data) {config[:data]}
124
- author = "Kevin Jalbert"
125
- subject {data[author]}
126
-
127
- it {data.has_key?(author).should be_true}
128
-
129
- it {subject[:commits].should == 1}
130
- it {subject[:additions].should == 73}
131
- it {subject[:deletions].should == 0}
132
- it {subject[:added_files].should == 2}
133
-
134
- it {subject[:languages][:Ruby][:additions].should == 62}
135
- it {subject[:languages][:Ruby][:deletions].should == 0}
136
- it {subject[:languages][:Ruby][:added_files].should == 1}
137
- it {subject[:languages][:Markdown][:additions].should == 11}
138
- it {subject[:languages][:Markdown][:deletions].should == 0}
139
- it {subject[:languages][:Markdown][:added_files].should == 1}
140
-
141
- it {config[:sort].should == sort}
142
- it {config[:email].should == email}
143
- it {config[:top_n].should == top_n}
144
- it {config[:author_length].should == 17}
145
- it {config[:language_length].should == 8}
134
+ context 'with top_n that filters to one author' do
135
+ let(:top_n) { 1 }
136
+ let(:data) { config[:data] }
137
+ author = 'Kevin Jalbert'
138
+ subject { data[author] }
139
+
140
+ it do
141
+ expect(data.key?(author)).to be true
142
+
143
+ expect(subject[:commits]).to eq(1)
144
+ expect(subject[:additions]).to eq(73)
145
+ expect(subject[:deletions]).to eq(0)
146
+ expect(subject[:added_files]).to eq(2)
147
+
148
+ expect(subject[:languages][:Ruby][:additions]).to eq(62)
149
+ expect(subject[:languages][:Ruby][:deletions]).to eq(0)
150
+ expect(subject[:languages][:Ruby][:added_files]).to eq(1)
151
+ expect(subject[:languages][:Markdown][:additions]).to eq(11)
152
+ expect(subject[:languages][:Markdown][:deletions]).to eq(0)
153
+ expect(subject[:languages][:Markdown][:added_files]).to eq(1)
154
+
155
+ expect(config[:sort]).to eq(sort)
156
+ expect(config[:email]).to eq(email)
157
+ expect(config[:top_n]).to eq(top_n)
158
+ expect(config[:author_length]).to eq(17)
159
+ expect(config[:language_length]).to eq(8)
160
+ end
146
161
  end
147
162
  end
148
163
 
149
- describe "output" do
164
+ describe 'output' do
150
165
  let(:output) { fixture(file).file.read }
151
- describe "#print_summary" do
152
- context "with valid data" do
153
- let(:file) { "summary_output.txt" }
154
- subject {results.print_summary(sort, email)}
155
- it { should == output.chomp }
166
+ describe '#print_summary' do
167
+ context 'with valid data' do
168
+ let(:file) { 'summary_output.txt' }
169
+ subject { results.print_summary(sort, email) }
170
+ it { expect(subject).to eq(output.chomp) }
156
171
  end
157
172
  end
158
173
 
159
- describe "#print_language_data" do
160
- context "with valid data" do
161
- let(:file) { "language_data_output.txt" }
162
- subject {results.print_language_data(config[:data]["Kevin Jalbert"])}
163
- it {should == output.split("\n")}
174
+ describe '#print_language_data' do
175
+ context 'with valid data' do
176
+ let(:file) { 'language_data_output.txt' }
177
+ subject { results.print_language_data(config[:data]['Kevin Jalbert']) }
178
+ it { expect(subject).to eq(output.split("\n")) }
164
179
  end
165
180
  end
166
181
 
167
- describe "#print_header" do
168
- context "with valid data" do
169
- let(:file) { "header_output.txt" }
182
+ describe '#print_header' do
183
+ context 'with valid data' do
184
+ let(:file) { 'header_output.txt' }
170
185
  subject { results.print_header.join("\n") }
171
- it {should == output.chomp}
186
+ it { expect(subject).to eq(output.chomp) }
172
187
  end
173
188
  end
174
189
  end
175
-
176
190
  end
@@ -3,52 +3,50 @@ require 'spec_helper'
3
3
  include GitStatistics
4
4
 
5
5
  describe Log do
6
-
7
6
  let(:log) { Class.new(Log) }
8
7
 
9
- context "initializes instance" do
10
- it "should acts as singleton" do
11
- log.instance.should == log.instance
8
+ context 'initializes instance' do
9
+ it 'acts as singleton' do
10
+ expect(log.instance).to eq(log.instance)
12
11
  end
13
12
 
14
- it "should have a logger" do
15
- log.instance.logger.should be_a Logger
13
+ it 'has a logger' do
14
+ expect(log.instance.logger).to be_a(Logger)
16
15
  end
17
16
 
18
- it "should be a Log (FakeLog)" do
19
- log.class.should eq Log.class
17
+ it 'is a Log (FakeLog)' do
18
+ expect(log.class).to eq(Log.class)
20
19
  end
21
20
 
22
- it "should react to Logger methods" do
21
+ it 'reacts to Logger methods' do
23
22
  Logger.public_instance_methods.each do |method|
24
- log.valid_method?(method).should be_true
23
+ expect(log.valid_method?(method)).to be true
25
24
  end
26
25
  end
27
26
  end
28
27
 
29
- context "#use_debug" do
28
+ context '#use_debug' do
30
29
  it "logger's progname before" do
31
- log.progname.should be_nil
30
+ expect(log.progname).to be nil
32
31
  end
33
32
 
34
33
  it "logger's progname after" do
35
34
  log.use_debug
36
- log.progname.should_not be_nil
35
+ expect(log.progname).to_not be nil
37
36
  end
38
37
  end
39
38
 
40
- context "#parse_caller" do
41
- context "with nothing" do
42
- it {log.parse_caller(nil).should be_nil}
39
+ context '#parse_caller' do
40
+ context 'with nothing' do
41
+ it { expect(log.parse_caller(nil)).to be nil }
43
42
  end
44
43
 
45
- context "with jumble (random text)" do
46
- it {log.parse_caller("asdaacsdc").should be_nil}
44
+ context 'with jumble (random text)' do
45
+ it { expect(log.parse_caller('asdaacsdc')).to be nil }
47
46
  end
48
47
 
49
- context "with valid caller" do
50
- it {log.parse_caller("git_statistics/lib/git_statistics/log.rb:45:in `respond_to_missing?'").should eq "git_statistics/lib/git_statistics/log.rb:45"}
48
+ context 'with valid caller' do
49
+ it { expect(log.parse_caller("git_statistics/lib/git_statistics/log.rb:45:in `respond_to_missing?'")).to eq('git_statistics/lib/git_statistics/log.rb:45') }
51
50
  end
52
51
  end
53
-
54
52
  end
@@ -4,56 +4,61 @@ include GitStatistics
4
4
 
5
5
  describe Pipe do
6
6
  let(:command) { 'git' }
7
- let(:line) { "" }
7
+ let(:line) { '' }
8
8
  let(:pipe) { Pipe.new(command) }
9
9
 
10
- context "initializes correctly" do
11
- context "with pipe character" do
10
+ context 'initializes correctly' do
11
+ context 'with pipe character' do
12
12
  let(:command) { '|git log --oneline' }
13
- it { expect(pipe.command).to eq 'git log --oneline'}
13
+ it { expect(pipe.command).to eq('git log --oneline') }
14
14
  end
15
- context "without pipe character" do
15
+
16
+ context 'without pipe character' do
16
17
  let(:command) { 'stat something else' }
17
- it { expect(pipe.command).to eq 'stat something else'}
18
+ it { expect(pipe.command).to eq('stat something else') }
18
19
  end
19
20
  end
20
21
 
21
- context "#empty?" do
22
- before { pipe.stub(:lines) { lines } }
23
- context "with empty lines" do
22
+ context '#empty?' do
23
+ before { allow(pipe).to receive(:lines) { lines } }
24
+
25
+ context 'with empty lines' do
24
26
  let(:lines) { [] }
25
- it { pipe.should be_empty }
27
+ it { expect(pipe).to be_empty }
26
28
  end
27
- context "with a single line" do
28
- let(:lines) { [stub] }
29
- it { pipe.should_not be_empty }
29
+
30
+ context 'with a single line' do
31
+ let(:lines) { [double] }
32
+ it { expect(pipe).to_not be_empty }
30
33
  end
31
34
  end
32
35
 
33
- context "#each" do
36
+ context '#each' do
34
37
  before do
35
- pipe.stub(:lines) { [line, line] }
38
+ allow(pipe).to receive(:lines) { [line, line] }
36
39
  end
37
- it "should delegate to the lines" do
38
- line.should_receive(:call).twice
40
+
41
+ it 'should delegate to the lines' do
42
+ expect(line).to receive(:call).twice
39
43
  pipe.each(&:call)
40
44
  end
41
45
  end
42
46
 
43
- context "#lines" do
47
+ context '#lines' do
44
48
  before do
45
- line.should_receive(:strip).twice.and_call_original
46
- pipe.stub(:io) { [line, line] }
49
+ expect(line).to receive(:strip).twice.and_return('')
50
+ allow(pipe).to receive(:io) { [line, line] }
47
51
  end
52
+
48
53
  it { pipe.lines }
49
54
  end
50
55
 
51
- context "#io" do
52
- it "should call #open and pass the command through" do
53
- pipe.should_receive(:open).with(/\A|#{command}/)
56
+ context '#io' do
57
+ it 'should call #open and pass the command through' do
58
+ expect(pipe).to receive(:open).with(/\A|#{command}/)
54
59
  pipe.io
55
60
  end
56
- it { pipe.io.should be_an IO }
57
- end
58
61
 
62
+ it { expect(pipe.io).to be_an(IO) }
63
+ end
59
64
  end