Module: Buildr::TestFramework::JRubyBased

Extended by:
JRubyBased
Included in:
JtestR, RSpec, JRubyBased
Defined in:
lib/buildr/java/bdd.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
'1.1.3'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dependenciesObject



60
61
62
# File 'lib/buildr/java/bdd.rb', line 60

def dependencies
  [jruby_artifact]
end

.included(mod) ⇒ Object



64
65
66
67
# File 'lib/buildr/java/bdd.rb', line 64

def included(mod)
  mod.extend ClassMethods
  super
end

.jruby_artifactObject



56
57
58
# File 'lib/buildr/java/bdd.rb', line 56

def jruby_artifact
  "org.jruby:jruby-complete:jar:#{version}"
end

.versionObject



52
53
54
# File 'lib/buildr/java/bdd.rb', line 52

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

Instance Method Details

#jruby_homeObject



113
114
115
116
# File 'lib/buildr/java/bdd.rb', line 113

def jruby_home
  @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : 
    ( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
end

#jruby_installed?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/buildr/java/bdd.rb', line 118

def jruby_installed?
  !Dir.glob(File.join(jruby_home, 'lib', 'jruby*.jar')).empty?
end

#run(tests, dependencies) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/buildr/java/bdd.rb', line 80

def run(tests, dependencies)
  maybe_install_jruby
  dependencies |= [task.compile.target.to_s]
  
  spec_dir = task.project.path_to(:source, :spec, :ruby)
  report_dir = task.report_to.to_s
  FileUtils.rm_rf report_dir
  FileUtils.mkdir_p report_dir
  ENV['CI_REPORTS'] = report_dir

  runner = runner_config
  runner.content = runner_content(binding)
  
  Buildr.write(runner.file, runner.content)
  FileUtils.rm_f runner.result
  
  if RUBY_PLATFORM[/java/] && !options.fork
    runtime = new_runtime
    runtime.getObject.java.lang.System.getProperties().putAll(options[:properties] || {})
    runtime.getLoadService.require runner.file
  else
    cmd_options = task.options.only(:properties, :java_args)
    cmd_options.update(:classpath => dependencies, :project => task.project)
    jruby runner.file, tests, cmd_options
  end
  
  result = YAML.load(File.read(runner.result))
  if Exception === result
    raise [result.message, result.backtrace].flatten.join("\n")
  end
  result.succeeded
end