Class: Buildr::JBehave

Inherits:
TestFramework::JavaBDD
  • Object
show all
Defined in:
lib/buildr/java/bdd.rb

Overview

JBehave is a Java BDD framework. To use in your project:

test.using :jbehave

This framework will search in your project for:

src/spec/java/**/*Behaviour.java

JMock libraries are included on runtime.

Support the following options:

  • :properties – Hash of properties to the test suite

  • :java_args – Arguments passed to the JVM

Constant Summary collapse

VERSION =
'1.0.1'
TESTS_PATTERN =

:nodoc:

[ /Behaviou?r$/ ]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applies_to?(project) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


413
414
415
416
417
# File 'lib/buildr/java/bdd.rb', line 413

def applies_to?(project) #:nodoc:
  %w{
    **/*Behaviour.java **/*Behavior.java
  }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
end

.dependenciesObject



408
409
410
411
# File 'lib/buildr/java/bdd.rb', line 408

def dependencies
  @dependencies ||= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
    JMock.dependencies + JUnit.dependencies
end

.versionObject



404
405
406
# File 'lib/buildr/java/bdd.rb', line 404

def version
  Buildr.settings.build['jbehave'] || VERSION
end

Instance Method Details

#run(tests, dependencies) ⇒ Object

:nodoc:



432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/buildr/java/bdd.rb', line 432

def run(tests, dependencies) #:nodoc:
  cmd_args = ['org.jbehave.core.BehaviourRunner']
  cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
  tests.inject([]) do |passed, test|
    begin
      Java::Commands.java cmd_args, test, cmd_options
      passed << test
    rescue
      passed
    end
  end
end

#tests(dependencies) ⇒ Object

:nodoc:



427
428
429
430
# File 'lib/buildr/java/bdd.rb', line 427

def tests(dependencies) #:nodoc:
  filter_classes(dependencies, :class_names => TESTS_PATTERN,
                 :interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
end