From 2afcc53b753b1e895abff6ca31090df985e265a0 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 15 Aug 2012 16:07:55 -0400 Subject: [PATCH] add some tasks --- lib/cuke-pack/tasks.rb | 2 ++ lib/cuke-pack/tasks/any_wip.rb | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/cuke-pack/tasks.rb create mode 100644 lib/cuke-pack/tasks/any_wip.rb diff --git a/lib/cuke-pack/tasks.rb b/lib/cuke-pack/tasks.rb new file mode 100644 index 0000000..a65d859 --- /dev/null +++ b/lib/cuke-pack/tasks.rb @@ -0,0 +1,2 @@ +require 'cuke-pack/tasks/any_wip' + diff --git a/lib/cuke-pack/tasks/any_wip.rb b/lib/cuke-pack/tasks/any_wip.rb new file mode 100644 index 0000000..b3c17ed --- /dev/null +++ b/lib/cuke-pack/tasks/any_wip.rb @@ -0,0 +1,23 @@ +namespace :cuke_pack do + desc "Raise an exception if any tasks are marked @wip" + task :any_wip do + require 'gherkin/parser/parser' + require 'gherkin/formatter/json_formatter' + require 'gherkin/formatter/tag_count_formatter' + + io = StringIO.new + counts = {} + json_formatter = Gherkin::Formatter::JSONFormatter.new(io) + formatter = Gherkin::Formatter::TagCountFormatter.new(json_formatter, counts) + parser = Gherkin::Parser::Parser.new(formatter) + + Dir['features/**/*.feature'].each do |file| + parser.parse(File.read(file), file, 0) + end + + if counts['@wip'] + raise StandardError.new("@wip occurred in the following files:\n#{counts['@wip'].join("\n")}") + end + end +end +