Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

For now, skip saikuro, so Ruby 1.9.3 doesn't fail

  • Loading branch information...
commit 4d7a70aa31791bbc2a74fccdb0e11b51c7556206 1 parent b6d4406
@iain authored
View
8 lib/metrical.rb
@@ -15,6 +15,7 @@ module Metrical
def run(argv)
options = Options.parse(argv)
load_settings(RUBY_VERSION)
+ change_metrics(options)
load_user_configuration
run_metric_fu
open_in_browser if options[:open]
@@ -31,6 +32,13 @@ def load_settings(ruby_version)
private
+ def change_metrics(options)
+ unless options[:saikuro]
+ MetricFu.configuration.metrics -= [ :saikuro ]
+ MetricFu.configuration.graphs -= [ :saikuro ]
+ end
+ end
+
def disable_rcov
MetricFu.configuration.metrics -= [ :rcov ]
MetricFu.configuration.graphs -= [ :rcov ]
View
14 lib/metrical/options.rb
@@ -4,18 +4,28 @@ module Metrical
module Options
def self.parse(argv)
- options = { :open => true }
+ options = { :open => true, :saikuro => true }
opts = OptionParser.new do |opts|
opts.version = Metrical::VERSION
+ opts.on "--[no-]saikuro", "Run Saikuro (default: true)" do |saikuro|
+ options[:saikuro] = saikuro
+ end
+
opts.on "--[no-]open", "Automatically open report in browser (default: true)" do |open|
options[:open] = open
end
end
- opts.parse!(argv)
+ begin
+ opts.parse!(argv)
+ rescue OptionParser::InvalidOption => error
+ puts error.message
+ puts opts
+ exit 1
+ end
options
end
View
19 spec/running_spec.rb
@@ -7,11 +7,11 @@
end
it "has a clean start" do
- File.exist?("tmp/metric_fu").should be_false
+ File.should_not exist("tmp/metric_fu")
end
it "loads the .metrics file" do
- out, err = metrical
+ out = metrical
out.should include "Metrics config loaded"
end
@@ -24,18 +24,23 @@
end
it "displays help" do
- out, err = metrical("bundle exec metrical --help")
+ out = metrical("bundle exec metrical --help")
out.should include "Usage: metrical [options]"
end
it "displays version" do
- out, err = metrical("bundle exec metrical --version")
+ out = metrical("bundle exec metrical --version")
out.should == "metrical #{Metrical::VERSION}"
end
- def metrical(command = "--no-open")
- stdin, stdout, stderr = Open3.popen3("metrical #{command}")
- [ stdout.read.strip, stderr.read.strip ]
+ it "errors on unknown flags" do
+ expect { metrical "--asdasdasda" }.to raise_error
+ end
+
+ def metrical(command = "--no-open --no-saikuro")
+ results = `metrical #{command} 2>&1`
+ $?.to_i.should eq(0), "The command 'metrical #{command}' failed!\n\n#{results}"
+ results.strip
end
end
View
26 spec/spec_helper.rb
@@ -4,13 +4,29 @@
RSpec::Matchers.define :create_file do |expected|
match do |block|
- fail "The file #{expected} was already present before the block" if File.exist?(expected)
+ @before = File.exist?(expected)
block.call
- if File.exist?(expected)
- true
+ @after = File.exist?(expected)
+ !@before && @after
+ end
+
+ failure_message_for_should do |block|
+ existed_before_message expected do
+ "The file #{expected.inspect} was not created"
+ end
+ end
+
+ failure_message_for_should_not do |block|
+ existed_before_message expected do
+ "The file #{expected.inspect} was created"
+ end
+ end
+
+ def existed_before_message(expected)
+ if @before
+ "The file #{expected.inspect} existed before, so this test doesn't work"
else
- system "ls #{File.dirname(expected)}"
- false
+ yield
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.