Permalink
Browse files

More specs

  • Loading branch information...
1 parent cad36e7 commit 61758ab5b6c5805574540298654ae0c579025ad1 @iain committed Feb 12, 2012
Showing with 44 additions and 13 deletions.
  1. +0 −4 .metrics
  2. +1 −0 .rspec
  3. +2 −2 lib/metrical.rb
  4. +1 −1 lib/metrical/options.rb
  5. +32 −6 spec/running_spec.rb
  6. +8 −0 spec/spec_helper.rb
View
@@ -2,7 +2,3 @@
# For testing that this file gets loaded
puts "Metrics config loaded"
-
-MetricFu::Configuration.run do |config|
- config.metrics -= [ :rcov ]
-end
View
@@ -1,2 +1,3 @@
--color
--format documentation
+--order rand
View
@@ -14,13 +14,13 @@ module Metrical
def run(argv)
options = Options.parse(argv)
- load_settings
+ load_settings(RUBY_VERSION)
load_user_configuration
run_metric_fu
open_in_browser if options[:open]
end
- def load_settings(ruby_version = RUBY_VERSION)
+ def load_settings(ruby_version)
load_defaults
if ruby_version =~ /^1\.9/
disable_rcov
@@ -9,7 +9,7 @@ def self.parse(argv)
opts.version = Metrical::VERSION
- opts.on "--[no-]open", "Automatically open report in browser" do |open|
+ opts.on "--[no-]open", "Automatically open report in browser (default: true)" do |open|
options[:open] = open
end
View
@@ -2,15 +2,41 @@
describe Metrical, "running" do
- around do |example|
- stdin, stdout, stderr = Open3.popen3("metrical --no-open")
- @stdout = stdout.read
- @stderr = stderr.read
- example.run
+ before do
+ FileUtils.rm_f("tmp/metric_fu")
end
it "loads the .metrics file" do
- @stdout.should include "Metrics config loaded"
+ out, err = metrical
+ out.should include "Metrics config loaded"
+ end
+
+ it "creates a report yaml file" do
+ expect { metrical }.to create_file("tmp/metric_fu/report.yml")
+ end
+
+ it "creates a report html file" do
+ expect { metrical }.to create_file("tmp/metric_fu/output/index.html")
+ end
+
+ it "displays help" do
+ out, err = metrical("bundle exec metrical --help")
+ out.should include "Usage: metrical [options]"
+ end
+
+ it "displays version" do
+ out, err = metrical("bundle exec metrical --version")
+ out.should == "metrical #{Metrical::VERSION}"
+ end
+
+ def metrical(command = "--no-open")
+ $cache ||= {}
+ if $cache[command]
+ $cache[command]
+ else
+ stdin, stdout, stderr = Open3.popen3("metrical #{command}")
+ $cache[command] = [ stdout.read.strip, stderr.read.strip ]
+ end
end
end
View
@@ -1,2 +1,10 @@
require 'bundler/setup'
require 'metrical'
+
+RSpec::Matchers.define :create_file do |expected|
+
+ match do |actual|
+ File.exist?(expected)
+ end
+
+end

0 comments on commit 61758ab

Please sign in to comment.