Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a couple of specs for running metrical

  • Loading branch information...
commit cad36e739b3d624e93a0882c2de8b782a2bca1d8 1 parent 20d6a05
@iain authored
View
4 .metrics
@@ -1,4 +1,8 @@
#!/usr/bin/env ruby
+
+# For testing that this file gets loaded
+puts "Metrics config loaded"
+
MetricFu::Configuration.run do |config|
config.metrics -= [ :rcov ]
end
View
2  bin/metrical
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require "metrical"
-Metrical.run(*ARGV)
+Metrical.run(ARGV.dup)
View
6 lib/metrical.rb
@@ -1,4 +1,5 @@
require "metrical/version"
+require "metrical/options"
require 'rubygems'
require 'json'
@@ -11,11 +12,12 @@
module Metrical
extend self
- def run(*)
+ def run(argv)
+ options = Options.parse(argv)
load_settings
load_user_configuration
run_metric_fu
- open_in_browser
+ open_in_browser if options[:open]
end
def load_settings(ruby_version = RUBY_VERSION)
View
23 lib/metrical/options.rb
@@ -0,0 +1,23 @@
+require 'optparse'
+
+module Metrical
+ module Options
+
+ def self.parse(argv)
+ options = { :open => true }
+ opts = OptionParser.new do |opts|
+
+ opts.version = Metrical::VERSION
+
+ opts.on "--[no-]open", "Automatically open report in browser" do |open|
+ options[:open] = open
+ end
+
+ end
+
+ opts.parse!(argv)
+ options
+ end
+
+ end
+end
View
5 spec/metrical_spec.rb → spec/configuration_spec.rb
@@ -1,7 +1,6 @@
-require 'bundler/setup'
-require 'metrical'
+require 'spec_helper'
-describe Metrical do
+describe Metrical, "configuration" do
it "won't use rcov under ruby 1.9" do
Metrical.load_settings("1.9.3")
View
16 spec/running_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe Metrical, "running" do
+
+ around do |example|
+ stdin, stdout, stderr = Open3.popen3("metrical --no-open")
+ @stdout = stdout.read
+ @stderr = stderr.read
+ example.run
+ end
+
+ it "loads the .metrics file" do
+ @stdout.should include "Metrics config loaded"
+ end
+
+end
View
2  spec/spec_helper.rb
@@ -0,0 +1,2 @@
+require 'bundler/setup'
+require 'metrical'
Please sign in to comment.
Something went wrong with that request. Please try again.