forked from michaelfeathers/repodepot-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod_spec.rb
31 lines (25 loc) · 934 Bytes
/
method_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rspec'
require_relative 'code_event.rb'
require_relative 'method.rb'
describe "RepoDepot::Method" do
it "should generate a life line" do
events = [CodeEvent.new(complexity: 1.2),
CodeEvent.new(complexity: 3.4)]
RepoDepot::Method.new('', events).life_line.should == [1.2, 3.4]
end
it "should generate deltas" do
events = [CodeEvent.new(complexity: 1),
CodeEvent.new(complexity: 2),
CodeEvent.new(complexity: 1)]
RepoDepot::Method.new('', events).deltas.should == [1, -1]
end
it "should report its current complexity" do
events = [CodeEvent.new(complexity: 1.2),
CodeEvent.new(complexity: 2),
CodeEvent.new(complexity: 11.4)]
RepoDepot::Method.new('', events).complexity.should == 11.4
end
it "reports zero complexity when it has no events" do
RepoDepot::Method.new('', []).complexity.should == 0.0
end
end