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.4.0'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dependenciesObject



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

def dependencies
  unless @dependencies
    @dependencies = [jruby_artifact]
  end
  @dependencies
end

.included(mod) ⇒ Object



69
70
71
72
# File 'lib/buildr/java/bdd.rb', line 69

def included(mod)
  mod.extend ClassMethods
  super
end

.jruby_artifactObject



58
59
60
# File 'lib/buildr/java/bdd.rb', line 58

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

.versionObject



54
55
56
# File 'lib/buildr/java/bdd.rb', line 54

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

Instance Method Details

#jruby_homeObject



120
121
122
123
# File 'lib/buildr/java/bdd.rb', line 120

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

#jruby_installed?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/buildr/java/bdd.rb', line 125

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

#run(tests, dependencies) ⇒ Object



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
112
113
114
115
116
117
118
# File 'lib/buildr/java/bdd.rb', line 87

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
  rm_rf report_dir
  mkdir_p report_dir
  ENV['CI_REPORTS'] = report_dir

  runner = runner_config
  runner.content = runner_content(binding)

  Buildr.write(runner.file, runner.content)
  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
  tests - result.failed
end