Skip to content

Commit

Permalink
[test] add explicit Java inherited inspect specs
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Oct 12, 2018
1 parent 51b4249 commit 6bf8026
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/java_integration/fixtures/types/DateLike.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package java_integration.fixtures.types;

public class DateLike extends java.util.Date {

public DateLike() { super(); }

public Object inspect() {
return new StringBuilder("inspect:").append(System.identityHashCode(this));
}

}
14 changes: 14 additions & 0 deletions spec/java_integration/types/inspect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@
expect(java.util.ArrayList.new([1, '2']).inspect).to eql '[1, 2]'
end

class SubDate < java.util.Date; end

it 'inherits (Java) inspect' do
date = SubDate.new(0)
expect(date.inspect).to include '1970'
end

it 'overrides custom (Java) inspect' do
date = Java::java_integration.fixtures.types.DateLike.new
inspect = date.inspect
expect(inspect).to be_a java.lang.StringBuilder
expect(inspect.to_s).to match /inspect:.*/
end

end

0 comments on commit 6bf8026

Please sign in to comment.