Class: Buildr::Groovy::EasyB
- Defined in:
- lib/buildr/groovy/bdd.rb
Overview
EasyB is a Groovy based BDD framework. To use in your project:
test.using :easyb
This framework will search in your project for:
src/spec/groovy/**/*Story.groovy
src/spec/groovy/**/*Specification.groovy
Support the following options:
-
:format – Report format :txt or :xml, default is :txt
-
:properties – Hash of properties passed to the test suite.
-
:java_args – Arguments passed to the JVM.
Constant Summary collapse
- VERSION =
"0.9"
- TESTS_PATTERN =
[ /(Story|Specification).groovy$/ ]
- OPTIONS =
[:format, :properties, :java_args]
Class Method Summary collapse
Instance Method Summary collapse
-
#run(tests, dependencies) ⇒ Object
:nodoc:.
-
#tests(dependencies) ⇒ Object
:nodoc:.
Class Method Details
.applies_to?(project) ⇒ Boolean
:nodoc:
51 52 53 54 55 |
# File 'lib/buildr/groovy/bdd.rb', line 51 def applies_to?(project) #:nodoc: %w{ **/*Specification.groovy **/*Story.groovy }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? } end |
.dependencies ⇒ Object
45 46 47 48 49 |
# File 'lib/buildr/groovy/bdd.rb', line 45 def dependencies @dependencies ||= ["org.easyb:easyb:jar:#{version}", 'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3', 'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7'] end |
Instance Method Details
#run(tests, dependencies) ⇒ Object
:nodoc:
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/buildr/groovy/bdd.rb', line 70 def run(tests, dependencies) #:nodoc: = { :format => :txt }.merge(self.).only(*OPTIONS) if :txt == [:format] easyb_format, ext = 'txtstory', '.txt' elsif :xml == [:format] easyb_format, ext = 'xmlbehavior', '.xml' else raise "Invalid format #{[:format]} expected one of :txt :xml" end cmd_args = [ 'org.disco.easyb.BehaviorRunner' ] = { :properties => [:properties], :java_args => [:java_args], :classpath => dependencies } tests.inject([]) do |passed, test| name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X') report = File.join(task.report_to.to_s, name + ext) mkpath report.pathmap('%d') begin Java::Commands.java cmd_args, "-#{easyb_format}", report, test, .merge(:name => name) rescue => e passed else passed << test end end end |
#tests(dependencies) ⇒ Object
:nodoc:
65 66 67 68 |
# File 'lib/buildr/groovy/bdd.rb', line 65 def tests(dependencies) #:nodoc: Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")]. select { |name| TESTS_PATTERN.any? { |pat| pat === name } } end |