1 require File.dirname(__FILE__) + "/../spec_helper"
3 import "java_integration.fixtures.MethodNames"
5 describe "Java static method names" do
6 it "should present as both camel-case and ruby-case" do
7 methods = MethodNames.methods
9 methods.should include("lowercase1")
10 methods.should include("camelCase1")
11 methods.should include("camel_case1")
12 methods.should include("camelWithUPPER1")
13 methods.should include("camel_with_upper1")
14 methods.should include("camelWITHUpper1")
15 methods.should include("CAMELWithUpper1")
18 methods.should_not include("camel_withupper1")
19 methods.should_not include("camelwith_upper1")
23 it "should present javabean properties as attribute readers and writers" do
24 methods = MethodNames.methods
26 methods.should include("getValue1")
27 methods.should include("get_value1")
28 methods.should include("value1")
30 methods.should include("setValue1")
31 methods.should include("set_value1")
32 methods.should include("value1=")
34 methods.should include("getValues1")
35 methods.should include("get_values1")
36 methods.should_not include("values1")
38 methods.should include("setValues1")
39 methods.should include("set_values1")
40 methods.should_not include("values1=")
43 it "should present boolean javabean property accessors as '?' method" do
44 methods = MethodNames.methods
46 methods.should include("isFirst1")
47 methods.should include("first1")
48 methods.should include("first1?")
50 methods.should include("isSecond1")
51 methods.should include("second1")
52 methods.should include("second1?")
54 methods.should include("hasThird1")
55 methods.should include("has_third1")
56 methods.should include("has_third1?")
58 methods.should include("hasFourth1")
59 methods.should include("has_fourth1");
60 methods.should include("has_fourth1?");
62 pending("not implemented") do
63 methods.should include("third1?")
65 methods.should_not include("fourth1?")
68 it "should not overwrite critical core Ruby methods" do
69 pending("need a better way to separate class and instance methods in the java code")
73 describe "Java instance method names" do
74 it "should present as both camel-case and ruby-case" do
75 methods = MethodNames.instance_methods
77 methods.should include("lowercase2")
78 methods.should include("camelCase2")
79 methods.should include("camel_case2")
80 methods.should include("camelWithUPPER2")
81 methods.should include("camel_with_upper2")
82 methods.should include("camelWITHUpper2")
83 methods.should include("CAMELWithUpper2")
86 methods.should_not include("camel_withupper2")
87 methods.should_not include("camelwith_upper2")
91 it "should present javabean properties as attribute readers and writers" do
92 methods = MethodNames.instance_methods
94 methods.should include("getValue2")
95 methods.should include("get_value2")
96 methods.should include("value2")
98 methods.should include("setValue2")
99 methods.should include("set_value2")
100 methods.should include("value2=")
102 methods.should include("getValues2")
103 methods.should include("get_values2")
104 methods.should_not include("values2")
106 methods.should include("setValues2")
107 methods.should include("set_values2")
108 methods.should_not include("values2=")
111 it "should treat consecutive caps as part of one property name" do
112 methods = MethodNames.instance_methods
114 methods.should include("jconsecutive_caps")
115 methods.should include("jconsecutive_caps=")
118 it "should present boolean javabean property accessors as '?' method" do
119 methods = MethodNames.instance_methods
121 methods.should include("isFirst2")
122 methods.should include("first2")
123 methods.should include("first2?")
125 methods.should include("isSecond2")
126 methods.should include("second2")
127 methods.should include("second2?")
129 methods.should include("hasThird2")
130 methods.should include("has_third2")
131 methods.should include("has_third2?")
133 methods.should include("hasFourth2")
134 methods.should include("has_fourth2")
135 methods.should include("has_fourth2?")
137 pending("not implemented") do
138 methods.should include("third2?")
140 methods.should_not include("fourth2?")
143 it "should not overwrite critical core Ruby methods" do
144 obj = MethodNames.new
146 obj.send(:initialize).should_not == "foo"
147 obj.object_id.should_not == "foo"
148 obj.__id__.should_not == "foo"
149 lambda {obj.__send__}.should raise_error(ArgumentError)