Class: Buildr::Scala::Specs2
- Defined in:
- lib/buildr/scala/bdd.rb
Overview
:nodoc:
Constant Summary collapse
- VERSION =
case when Buildr::Scala.version?('2.8.0'), Buildr::Scala.version?('2.8.1'), Buildr::Scala.version?('2.8.2') '1.5' when Buildr::Scala.version?('2.9') '1.11' when Buildr::Scala.version?('2.10') '1.12.3' else '3.7' # default for Scala 2.11 and beyond end
Class Method Summary collapse
-
.applies_to?(project) ⇒ Boolean
:nodoc:.
- .artifact ⇒ Object
- .dependencies ⇒ Object
- .scalaz_dependencies ⇒ Object
- .specs ⇒ Object
- .type ⇒ Object
- .version ⇒ Object
Instance Method Summary collapse
-
#initialize(task, options) ⇒ Specs2
constructor
:nodoc:.
-
#run(specs, dependencies) ⇒ Object
:nodoc:.
- #tests(dependencies) ⇒ Object
Constructor Details
#initialize(task, options) ⇒ Specs2
:nodoc:
125 126 127 128 129 130 131 132 133 |
# File 'lib/buildr/scala/bdd.rb', line 125 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:
107 108 109 110 111 |
# File 'lib/buildr/scala/bdd.rb', line 107 def applies_to?(project) #:nodoc: scala_files = Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')] return false if scala_files.empty? scala_files.detect { |f| find(f, /\s+(org\.specs2\.)/) } end |
.artifact ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/buildr/scala/bdd.rb', line 44 def artifact case when Buildr.settings.build['scala.specs2.artifact'] Buildr.settings.build['scala.specs2.artifact'] else if Buildr::Scala.version < '2.11' "specs2_#{Buildr::Scala.version_without_build_number}" else "specs2_#{Buildr::Scala.version_major_minor}" end end end |
.dependencies ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/buildr/scala/bdd.rb', line 91 def dependencies unless @dependencies super # Add utility classes and other dependencies = { :scopes => [nil, 'compile', 'runtime', 'provided', 'optional'], :optional => true } @dependencies |= [ File.join(File.dirname(__FILE__)) ] + Buildr.transitive(specs, ) + scalaz_dependencies + Check.dependencies + JUnit.dependencies + Scalac.dependencies end @dependencies end |
.scalaz_dependencies ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/buildr/scala/bdd.rb', line 65 def scalaz_dependencies if Buildr::Scala.version?('2.8') [] elsif Buildr::Scala.version < '2.11' default_version = '6.0.1' custom_version = Buildr.settings.build['scala.specs2-scalaz'] version = (custom_version =~ /:/) ? Buildr.artifact(custom_version).version : default_version artifact = Buildr.settings.build['scala.specs2-scalaz.artifact'] || "specs2-scalaz-core_#{Buildr::Scala.version_without_build}" custom_spec = Buildr.settings.build['scala.specs2-scalaz'] spec = [ (custom_spec =~ /:/) ? custom_spec : "org.specs2:#{artifact}:jar:#{version}" ] Buildr.transitive(spec, :scopes => [nil, 'compile', 'runtime', 'provided', 'optional'], :optional => true) else default_version = '7.2.2' custom_version = Buildr.settings.build['scala.specs2-scalaz'] version = (custom_version =~ /:/) ? Buildr.artifact(custom_version).version : default_version artifact = Buildr.settings.build['scala.specs2-scalaz.artifact'] || "scalaz-core_#{Buildr::Scala.version_major_minor}" custom_spec = Buildr.settings.build['scala.specs2-scalaz'] spec = [ (custom_spec =~ /:/) ? custom_spec : "org.scalaz:#{artifact}:jar:#{version}" ] [Buildr.transitive(spec, :scopes => [nil, 'compile', 'runtime', 'provided', 'optional'], :optional => true), 'org.scala-lang.modules:scala-xml_2.11:jar:1.0.1'] end end |
.specs ⇒ Object
39 40 41 42 |
# File 'lib/buildr/scala/bdd.rb', line 39 def specs custom = Buildr.settings.build['scala.specs2'] [ (custom =~ /:/) ? custom : "org.specs2:#{artifact}:pom:#{version}" ] end |
Instance Method Details
#run(specs, dependencies) ⇒ Object
:nodoc:
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/buildr/scala/bdd.rb', line 139 def run(specs, dependencies) #:nodoc: properties = {'specs2.outDir' => task.compile.target.to_s } = { :properties => [:properties].merge(properties), :java_args => [:java_args], :classpath => dependencies, :name => false } runner = 'org.specs2.runner.ClassRunner' specs.inject [] do |passed, spec| begin Java::Commands.java('io.tmio.scalamain.Main', runner, 'run', spec, ) rescue => e passed else passed << spec end end end |
#tests(dependencies) ⇒ Object
135 136 137 |
# File 'lib/buildr/scala/bdd.rb', line 135 def tests(dependencies) filter_classes(dependencies, :interfaces => %w(org.specs2.Specification org.specs2.mutable.Specification)) end |