1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
describe Java::OrgJruby::Ruby do
before do
@config = Java::OrgJruby::Ruby.get_global_runtime.instance_config
end
context "runtime with rspec" do
before do
@runtime = new_runtime(Java::OrgJruby::RubyInstanceConfig.new(@config))
@runtime.evalScriptlet("require 'rubygems'")
# setup rspec but disable autorun - we'll run ourselves :
@runtime.evalScriptlet("require 'rspec/core'")
@runtime.evalScriptlet("RSpec::Core::Runner.disable_autorun!")
# helper OUT/ERR streams to use when running specs :
@runtime.evalScriptlet("require 'stringio'")
@runtime.evalScriptlet("ERR_IO = StringIO.new")
@runtime.evalScriptlet("OUT_IO = StringIO.new")
end
after do
@runtime.tear_down
end
it "should pass profile_data_spec" do
check_passed_spec @runtime.evalScriptlet("RSpec::Core::Runner.run([ 'spec/profiler/profile_data_spec.rb' ], ERR_IO, OUT_IO)")
end
it "should pass profiler_basics_spec" do
check_passed_spec @runtime.evalScriptlet("RSpec::Core::Runner.run([ 'spec/profiler/profiler_basics_spec.rb' ], ERR_IO, OUT_IO)")
end
it "should pass graph_profile_printer_spec" do
check_passed_spec @runtime.evalScriptlet("RSpec::Core::Runner.run([ 'spec/profiler/graph_profile_printer_spec.rb' ], ERR_IO, OUT_IO)")
end
def check_passed_spec(exit_status)
# print any errors if occured :
@runtime.evalScriptlet("puts ERR_IO.string unless ERR_IO.string.empty?")
expect( passed = (exit_status == 0) ).to be true
ensure
unless passed
puts "spec not passed, output: \n"
@runtime.evalScriptlet("puts OUT_IO.string")
end
end
end
def new_runtime(config = Java::OrgJruby::RubyInstanceConfig.new)
config.processArguments(['-I.', '--profile.api'])
Java::OrgJruby::Ruby.newInstance(config)
end
end
|