Class: Buildr::Scala::Specs
- Defined in:
- lib/buildr/scala/bdd.rb
Overview
Specs is a Scala based BDD framework. To use in your project:
test.using :specs
This framework will search in your project for:
src/spec/scala/**/*.scala
Constant Summary collapse
- VERSION =
'1.6.0'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(task, options) ⇒ Specs
constructor
:nodoc:.
-
#run(specs, dependencies) ⇒ Object
:nodoc:.
- #tests(dependencies) ⇒ Object
Constructor Details
#initialize(task, options) ⇒ Specs
:nodoc:
65 66 67 68 69 70 71 72 73 |
# File 'lib/buildr/scala/bdd.rb', line 65 def initialize(task, ) #:nodoc: super specs = task.project.path_to(:source, :spec, :scala) task.compile.from specs if File.directory?(specs) resources = task.project.path_to(:source, :spec, :resources) task.resources.from resources if File.directory?(resources) end |
Class Method Details
.applies_to?(project) ⇒ Boolean
:nodoc:
53 54 55 |
# File 'lib/buildr/scala/bdd.rb', line 53 def applies_to?(project) #:nodoc: !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty? end |
.dependencies ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/buildr/scala/bdd.rb', line 42 def dependencies unless @dependencies super # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies @dependencies |= [ File.join(File.dirname(__FILE__)) ] + ["org.scala-tools.testing:specs:jar:#{version}"] + Check.dependencies + JUnit.dependencies + Scalac.dependencies end @dependencies end |
Instance Method Details
#run(specs, dependencies) ⇒ Object
:nodoc:
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/buildr/scala/bdd.rb', line 85 def run(specs, dependencies) #:nodoc: = { :properties => [:properties], :java_args => [:java_args], :classpath => dependencies, :name => false } runner = 'org.apache.buildr.SpecsSingletonRunner' specs.inject [] do |passed, spec| begin unless Util.win_os? Java::Commands.java(runner, task.compile.target.to_s, '-c', spec + '$', ) else Java::Commands.java(runner, task.compile.target.to_s, spec + '$', ) end rescue => e passed else passed << spec end end end |
#tests(dependencies) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/buildr/scala/bdd.rb', line 75 def tests(dependencies) candidates = filter_classes(dependencies, :interfaces => ['org.specs.Specification']) Java.load # Java is already loaded, but just in case filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String)) filter.add_fields ['MODULE$'].to_java(Java.java.lang.String) filter.filter(candidates.to_java(Java.java.lang.String)).map { |s| s[0..(s.size - 2)] } end |