-
-
Notifications
You must be signed in to change notification settings - Fork 938
Expand file tree
/
Copy pathimplements_spec.rb
More file actions
29 lines (22 loc) · 1023 Bytes
/
implements_spec.rb
File metadata and controls
29 lines (22 loc) · 1023 Bytes
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
require_relative '../spec_helper'
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_implements line" do
it "generates a class that implements the given interfaces" do
cls = generate("class Foo; java_implements 'Runnable'; end").classes[0]
expect( cls.interfaces.length ).to be 1
expect( cls.interfaces ).to eql [ 'Runnable' ]
java = cls.to_s
expect( java ).to match /^public class Foo extends RubyObject implements Runnable/
cls = generate("class Foo; java_implements 'Runnable', 'Serializable'; end").classes[0]
expect( cls.interfaces.length ).to be 2
expect( cls.interfaces ).to eql [ 'Runnable', 'Serializable' ]
java = cls.to_s
expect( java ).to match /^public class Foo extends RubyObject implements Runnable, Serializable/
end
end
end