spec/config_spec.rb in p8-metric_fu-0.9.0.2 vs spec/config_spec.rb in p8-metric_fu-0.9.0.3
- old
+ new
@@ -17,18 +17,44 @@
end
end
describe "metrics" do
it "should be configurable" do
- MetricFu.metrics.should == [:coverage, :churn, :flog, :flay, :reek, :roodi, :saikuro]
+ MetricFu.metrics.should == [:churn, :coverage, :flay, :flog, :reek, :roodi, :saikuro]
MetricFu::Configuration.run do |config|
config.metrics = [:coverage, :flog]
end
MetricFu.metrics.should == [:coverage, :flog]
end
+ end
+
+ describe "default metrics" do
+ it "should have :stats for rails projects" do
+ MetricFu.should_receive(:is_rails?).and_return(true)
+ MetricFu.should_receive(:can_churn?).and_return(false)
+ MetricFu.default_metrics.should == [:coverage, :flay, :flog, :reek, :roodi, :saikuro, :stats]
+ end
+
+ it "should have exclude :churn for projects whcih can churn" do
+ MetricFu.should_receive(:is_rails?).and_return(false)
+ MetricFu.should_receive(:can_churn?).and_return(true)
+ MetricFu.default_metrics.should == [:churn, :coverage, :flay, :flog, :reek, :roodi, :saikuro]
+ end
end
+ describe "code dirs" do
+ it "should return code dirs" do
+ MetricFu.should_receive(:is_rails?).and_return(false)
+ MetricFu.code_dirs.should == ['lib']
+ end
+
+ it "should have 'app' for rails projects" do
+ MetricFu.should_receive(:is_rails?).and_return(true)
+ MetricFu.code_dirs.should == ['app', 'lib']
+ end
+ end
+
describe "churn" do
it "should be configurable" do
now = Time.now
MetricFu.churn.should == {}
MetricFu::Configuration.run do |config|
@@ -44,9 +70,23 @@
MetricFu::Configuration.run do |config|
config.coverage[:test_files] = ['test/**/test_*.rb']
end
MetricFu.coverage[:test_files].should == ['test/**/test_*.rb']
end
+
+ it "should have configurable rcov_opts" do
+ MetricFu.coverage[:rcov_opts].should == ["--sort coverage", "--html", "--exclude /gems/,/Library/,spec"]
+ MetricFu::Configuration.run do |config|
+ config.coverage[:rcov_opts] = ["--sort coverage", "--html"]
+ end
+ MetricFu.coverage[:rcov_opts].should == ["--sort coverage", "--html"]
+ end
+
+ it "should have --rails in rcov_opts if it's a rails project" do
+ MetricFu.should_receive(:is_rails?).at_least(1).and_return(true)
+ MetricFu.configuration.reset
+ MetricFu.coverage[:rcov_opts].should == ["--sort coverage", "--html", "--exclude /gems/,/Library/,spec", "--rails"]
+ end
end
describe "flay" do
it "should be configurable" do
now = Time.now
\ No newline at end of file