1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
require File.dirname(__FILE__) + "/../../spec_helper"
require 'jruby'
require 'jruby/compiler'
describe "A Ruby class generating a Java stub" do
def generate(script)
node = JRuby.parse(script)
# we use __FILE__ so there's something for it to read
JRuby::Compiler::JavaGenerator.generate_java node, __FILE__
end
describe "with a java_package line" do
it "generates a package line into the Java source" do
script = generate("java_package 'org.bar'; class Foo; end")
script.package.should == "org.bar"
cls = script.classes[0]
cls.package.should == 'org.bar'
java = cls.to_s
java.should match /package org\.bar;/
end
end
end
|