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.6'
Class Method Summary collapse
-
.applies_to?(project) ⇒ Boolean
:nodoc:.
- .artifact ⇒ Object
- .dependencies ⇒ Object
- .version ⇒ Object
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:
69 70 71 72 73 74 75 76 77 |
# File 'lib/buildr/scala/bdd.rb', line 69 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:
57 58 59 |
# File 'lib/buildr/scala/bdd.rb', line 57 def applies_to?(project) #:nodoc: !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty? end |
.artifact ⇒ Object
42 43 44 |
# File 'lib/buildr/scala/bdd.rb', line 42 def artifact Buildr.settings.build['scala.specs.artifact'] || "specs_#{Buildr::Scala.version}" end |
.dependencies ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/buildr/scala/bdd.rb', line 46 def dependencies unless @dependencies super specs = (version =~ /:/) ? [version] : ["org.scala-tools.testing:#{artifact}:jar:#{version}"] # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies @dependencies |= [ File.join(File.dirname(__FILE__)) ] + specs + Check.dependencies + JUnit.dependencies + Scalac.dependencies end @dependencies end |
Instance Method Details
#run(specs, dependencies) ⇒ Object
:nodoc:
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/buildr/scala/bdd.rb', line 89 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
79 80 81 82 83 84 85 86 87 |
# File 'lib/buildr/scala/bdd.rb', line 79 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 |