This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Generating graphs too

  • Loading branch information...
1 parent 7f0f50c commit 283f769143e614f1575691b664731f7c2b787e3c @qrush qrush committed Jul 8, 2009
Showing with 33 additions and 15 deletions.
  1. +8 −1 lib/pythagoras/runner.rb
  2. +25 −14 test/runner_test.rb
View
@@ -33,8 +33,9 @@ def configure
ENV['CC_BUILD_ARTIFACTS'] = self.output_path
MetricFu::Configuration.run do |config|
config.reset
+ config.data_directory = self.archive_path
config.template_class = AwesomeTemplate
- config.metrics = [:flog, :flay, :rcov, :reek, :roodi]
+ config.metrics = config.graphs = [:flog, :flay, :rcov, :reek, :roodi]
config.rcov = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
:rcov_opts => ["--sort coverage",
"--no-html",
@@ -51,8 +52,14 @@ def configure
def generate
begin
MetricFu.metrics.each { |metric| MetricFu.report.add(metric) }
+ MetricFu.graphs.each { |graph| MetricFu.graph.add(graph) }
+
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, 'report.yml')
+ MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
MetricFu.report.save_templatized_report
+
+ MetricFu.graph.generate
+
@success = true
rescue Exception => e
STDERR.puts "Problem generating the reports: #{e}"
View
@@ -118,8 +118,9 @@ class RunnerTest < Test::Unit::TestCase
config = "config"
mock(config).reset
mock(config).template_class = AwesomeTemplate
- mock(config).metrics = [:flog, :flay, :rcov, :reek, :roodi]
+ mock(config).metrics = mock(config).graphs = [:flog, :flay, :rcov, :reek, :roodi]
mock(config).rcov = anything
+ mock(config).data_directory = @runner.archive_path
mock.proxy(MetricFu::Configuration).run.yields(config)
@runner.configure
@@ -132,19 +133,29 @@ class RunnerTest < Test::Unit::TestCase
end
should "successfully generate output" do
- metric = "metric"
- report = "report"
-
- mock(report).add(metric)
- mock(report).save_templatized_report
- mock(report).to_yaml { "yaml" }
- mock(report).save_output("yaml", MetricFu.base_directory, "report.yml")
-
- stub(MetricFu).report { report }
- mock(MetricFu).metrics.stub!.each.yields(metric)
-
- @runner.generate
- assert @runner.success?
+ Timecop.freeze(Date.today) do
+ metric = "metric"
+ report = "report"
+ graph = "graph"
+ one_graph = "one_graph"
+
+ mock(report).add(metric)
+ mock(report).save_templatized_report
+ mock(report).to_yaml { "yaml" }.twice
+ mock(report).save_output("yaml", MetricFu.base_directory, "report.yml")
+ mock(report).save_output("yaml", MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
+
+ stub(MetricFu).report { report }
+ mock(MetricFu).metrics.stub!.each.yields(metric)
+
+ mock(graph).add(one_graph)
+ mock(graph).generate
+ stub(MetricFu).graph { graph }
+ mock(MetricFu).graphs.stub!.each.yields(one_graph)
+
+ @runner.generate
+ assert @runner.success?
+ end
end
should "be unsuccessful if some problem arises" do

0 comments on commit 283f769

Please sign in to comment.