Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 182 lines (125 sloc) 4.107 kb
d321e61 @iain Switches for every metric
authored
1 require 'spec_helper'
2
3 describe Metrical::Options do
4
5 describe ".defaults" do
6
7 let(:defaults) { Metrical::Options.defaults }
8
9 context "on every Ruby version" do
10
11 it "opens the report in a browser" do
12 defaults[:open].should be_true
13 end
14
15 it "enables Flog" do
16 defaults[:metrics][:flog].should be_true
17 end
18
19 it "enables Flay" do
20 defaults[:metrics][:flay].should be_true
21 end
22
23 it "enables Reek" do
24 defaults[:metrics][:reek].should be_true
25 end
26
27 it "enables Hotspots" do
28 defaults[:metrics][:hotspots].should be_true
29 end
30
31 it "enables Rails Best Practices" do
32 defaults[:metrics][:rails_best_practices].should be_true
33 end
34
35 it "enables Churn" do
36 defaults[:metrics][:churn].should be_true
37 end
38
39 end
40
41 context "on Ruby 1.8.6" do
42
43 before { subject.stub(:ruby).and_return("1.8.6") }
44
45 it "enables Saikuro" do
46 defaults[:metrics][:saikuro].should be_true
47 end
48
49 it "enables RCov" do
50 defaults[:metrics][:rcov].should be_true
51 end
52
53 end
54
55 context "on Ruby 1.8.7" do
56
57 before { subject.stub(:ruby).and_return("1.8.7") }
58
59 it "enables Saikuro" do
60 defaults[:metrics][:saikuro].should be_true
61 end
62
63 it "enables RCov" do
64 defaults[:metrics][:rcov].should be_true
65 end
66
67 end
68
69 context "on Ruby 1.9.2" do
70
71 before { subject.stub(:ruby).and_return("1.9.2") }
72
73 it "enables Saikuro" do
126eb4f @iain Turn off Saikuro for every Ruby 1.9 version
authored
74 defaults[:metrics][:saikuro].should be_false
d321e61 @iain Switches for every metric
authored
75 end
76
77 it "disables RCov" do
78 defaults[:metrics][:rcov].should be_false
79 end
80
81 end
82
83 context "on Ruby 1.9.3" do
84
85 before { subject.stub(:ruby).and_return("1.9.3") }
86
87 it "disables Saikuro" do
88 defaults[:metrics][:saikuro].should be_false
89 end
90
91 it "disables RCov" do
92 defaults[:metrics][:rcov].should be_false
93 end
94
95 end
96
97 end
98
99 describe ".parse" do
100
101 it "turns open in browser off" do
102 subject.parse(["--no-open"])[:open].should be_false
103 end
104
105 it "turns open in browser on" do
106 subject.parse(["--open"])[:open].should be_true
107 end
108
126eb4f @iain Turn off Saikuro for every Ruby 1.9 version
authored
109 # MetricFu doesn't include Saikuro on 1.9.2 (it is broken on 1.9 anyway)
110 # https://github.com/jscruggs/metric_fu/blob/master/lib/base/configuration.rb#L12
111 unless RUBY_VERSION == "1.9.2"
112
113 it "turns saikuro off" do
114 subject.parse(["--no-saikuro"])[:metrics][:saikuro].should be_false
115 end
116
117 it "turns saikuro on" do
118 subject.parse(["--saikuro"])[:metrics][:saikuro].should be_true
119 end
d321e61 @iain Switches for every metric
authored
120
121 end
122
123 it "turns churn off" do
124 subject.parse(["--no-churn"])[:metrics][:churn].should be_false
125 end
126
127 it "turns churn on" do
128 subject.parse(["--churn"])[:metrics][:churn].should be_true
129 end
130
131 it "turns flay off" do
132 subject.parse(["--no-flay"])[:metrics][:flay].should be_false
133 end
134
135 it "turns flay on" do
136 subject.parse(["--flay"])[:metrics][:flay].should be_true
137 end
138
139 it "turns flog off" do
140 subject.parse(["--no-flog"])[:metrics][:flog].should be_false
141 end
142
143 it "turns flog on" do
144 subject.parse(["--flog"])[:metrics][:flog].should be_true
145 end
146
147 it "turns hotspots off" do
148 subject.parse(["--no-hotspots"])[:metrics][:hotspots].should be_false
149 end
150
151 it "turns hotspots on" do
152 subject.parse(["--hotspots"])[:metrics][:hotspots].should be_true
153 end
154
155 it "turns rcov off" do
156 subject.parse(["--no-rcov"])[:metrics][:rcov].should be_false
157 end
158
159 it "turns rcov on" do
160 subject.parse(["--rcov"])[:metrics][:rcov].should be_true
161 end
162
163 it "turns reek off" do
164 subject.parse(["--no-reek"])[:metrics][:reek].should be_false
165 end
166
167 it "turns reek on" do
168 subject.parse(["--reek"])[:metrics][:reek].should be_true
169 end
170
171 it "turns roodi off" do
172 subject.parse(["--no-roodi"])[:metrics][:roodi].should be_false
173 end
174
175 it "turns roodi on" do
176 subject.parse(["--roodi"])[:metrics][:roodi].should be_true
177 end
178
179 end
180
181 end
Something went wrong with that request. Please try again.