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)


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

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

.dependenciesObject



417
418
419
420
421
422
423
424
# File 'lib/buildr/java/bdd.rb', line 417

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

.versionObject



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

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

Instance Method Details

#run(tests, dependencies) ⇒ Object

:nodoc:



445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/buildr/java/bdd.rb', line 445

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:



440
441
442
443
# File 'lib/buildr/java/bdd.rb', line 440

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