From 4b38b8e7b8943c91c72fa1b5f74c64f9ca94f6d1 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 5 Dec 2007 01:49:33 +0100 Subject: Implement -n and -t for filtering on context/specification names darcs-hash:20071205004933-4fc50-bf25adcb3aa94bded121b452ad17a15a1c38c1f5.gz --- bin/bacon | 5 +++-- lib/bacon.rb | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/bacon b/bin/bacon index 60997d8..dd01064 100755 --- a/bin/bacon +++ b/bin/bacon @@ -2,6 +2,7 @@ # -*- ruby -*- require 'optparse' +module Bacon; end automatic = false output = 'SpecDoxOutput' @@ -56,12 +57,12 @@ opts = OptionParser.new("", 24, ' ') { |opts| opts.on('-n', '--name NAME', String, "runs tests matching regexp NAME") { |n| - # TODO + Bacon.const_set :RestrictName, Regexp.new(n) } opts.on('-t', '--testcase TESTCASE', String, "runs tests in TestCases matching regexp TESTCASE") { |t| - # TODO + Bacon.const_set :RestrictContext, Regexp.new(t) } opts.separator "" diff --git a/lib/bacon.rb b/lib/bacon.rb index 627f79d..0261c88 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -10,6 +10,9 @@ module Bacon raise NameError, "no such context: #{name.inspect}" } + RestrictName = // unless defined? RestrictName + RestrictContext = // unless defined? RestrictContext + module SpecDoxOutput def handle_specification(name) puts name @@ -102,7 +105,8 @@ module Bacon @before = [] @after = [] @name = name - + + return unless name =~ RestrictContext Bacon.handle_specification(name) do instance_eval(&block) end @@ -116,6 +120,7 @@ module Bacon end def it(description, &block) + return unless description =~ RestrictName Bacon::Counter[:specifications] += 1 run_requirement description, block end -- cgit 1.4.1