Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Generating graphs too

  • Loading branch information...
commit 283f769143e614f1575691b664731f7c2b787e3c 1 parent 7f0f50c
Nick Quaranto authored July 07, 2009
9  lib/pythagoras/runner.rb
@@ -33,8 +33,9 @@ def configure
33 33
       ENV['CC_BUILD_ARTIFACTS'] = self.output_path
34 34
       MetricFu::Configuration.run do |config|
35 35
         config.reset
  36
+        config.data_directory = self.archive_path
36 37
         config.template_class = AwesomeTemplate
37  
-        config.metrics  = [:flog, :flay, :rcov, :reek, :roodi]
  38
+        config.metrics = config.graphs = [:flog, :flay, :rcov, :reek, :roodi]
38 39
         config.rcov     = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
39 40
                             :rcov_opts  => ["--sort coverage",
40 41
                             "--no-html",
@@ -51,8 +52,14 @@ def configure
51 52
     def generate
52 53
       begin
53 54
         MetricFu.metrics.each { |metric| MetricFu.report.add(metric) }
  55
+        MetricFu.graphs.each  { |graph| MetricFu.graph.add(graph) }
  56
+
54 57
         MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, 'report.yml')
  58
+        MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
55 59
         MetricFu.report.save_templatized_report
  60
+
  61
+        MetricFu.graph.generate
  62
+
56 63
         @success = true
57 64
       rescue Exception => e
58 65
         STDERR.puts "Problem generating the reports: #{e}"
39  test/runner_test.rb
@@ -118,8 +118,9 @@ class RunnerTest < Test::Unit::TestCase
118 118
       config = "config"
119 119
       mock(config).reset
120 120
       mock(config).template_class = AwesomeTemplate
121  
-      mock(config).metrics = [:flog, :flay, :rcov, :reek, :roodi]
  121
+      mock(config).metrics = mock(config).graphs = [:flog, :flay, :rcov, :reek, :roodi]
122 122
       mock(config).rcov = anything
  123
+      mock(config).data_directory = @runner.archive_path
123 124
 
124 125
       mock.proxy(MetricFu::Configuration).run.yields(config)
125 126
       @runner.configure
@@ -132,19 +133,29 @@ class RunnerTest < Test::Unit::TestCase
132 133
       end
133 134
 
134 135
       should "successfully generate output" do
135  
-        metric = "metric"
136  
-        report = "report"
137  
-
138  
-        mock(report).add(metric)
139  
-        mock(report).save_templatized_report
140  
-        mock(report).to_yaml { "yaml" }
141  
-        mock(report).save_output("yaml", MetricFu.base_directory, "report.yml")
142  
-
143  
-        stub(MetricFu).report { report }
144  
-        mock(MetricFu).metrics.stub!.each.yields(metric)
145  
-
146  
-        @runner.generate
147  
-        assert @runner.success?
  136
+        Timecop.freeze(Date.today) do
  137
+          metric = "metric"
  138
+          report = "report"
  139
+          graph  = "graph"
  140
+          one_graph = "one_graph"
  141
+
  142
+          mock(report).add(metric)
  143
+          mock(report).save_templatized_report
  144
+          mock(report).to_yaml { "yaml" }.twice
  145
+          mock(report).save_output("yaml", MetricFu.base_directory, "report.yml")
  146
+          mock(report).save_output("yaml", MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
  147
+
  148
+          stub(MetricFu).report { report }
  149
+          mock(MetricFu).metrics.stub!.each.yields(metric)
  150
+
  151
+          mock(graph).add(one_graph)
  152
+          mock(graph).generate
  153
+          stub(MetricFu).graph  { graph }
  154
+          mock(MetricFu).graphs.stub!.each.yields(one_graph)
  155
+
  156
+          @runner.generate
  157
+          assert @runner.success?
  158
+        end
148 159
       end
149 160
 
150 161
       should "be unsuccessful if some problem arises" do

0 notes on commit 283f769

Please sign in to comment.
Something went wrong with that request. Please try again.