@Test @Issue("JENKINS-39414") public void shouldProperlyHandleFieldsInRubyModules() throws Exception { final ScriptingContainer ruby = createRubyInstance(); final RubyKlassNavigator navigator = new RubyKlassNavigator(ruby.getProvider().getRuntime(), ClassLoader.getSystemClassLoader()); final MyRubyModule myModule = new MyRubyModule(ruby.getRuntime(), new MyRubyClass(ruby.getRuntime()), true); final Klass<RubyModule> classInstance = new Klass<RubyModule>(myModule, navigator); final List<FieldRef> declaredFields = classInstance.getDeclaredFields(); assumeThat("Access to fields in Ruby Modules has not been implemented yet", declaredFields, not(IsEmptyCollection.<FieldRef>empty())); for (FieldRef ref : declaredFields) { if ("fooField".equals(ref.getName())) { return; } } Assert.fail("Have not found 'fooField' in the returned field list"); }
@Override public List<FieldRef> getDeclaredFields(RubyModule clazz) { return Collections.emptyList(); }
RubyKlassNavigator extends KlassNavigator<RubyModule> { @Override public List<FieldRef> getDeclaredFields(RubyModule clazz) { return Collections.emptyList(); } }
RubyKlassNavigator extends KlassNavigator<RubyModule> { @Override public List<FieldRef> getDeclaredFields(RubyModule clazz) { return Collections.emptyList(); } RubyKlassNavigator(Ruby ruby, ClassLoader cl); }
RubyKlassNavigator extends KlassNavigator<RubyModule> { @Override public List<FieldRef> getDeclaredFields(RubyModule clazz) { return Collections.emptyList(); } RubyKlassNavigator(Ruby ruby, ClassLoader cl); @Override URL getResource(RubyModule clazz, String resourceName); @Override Iterable<Klass<?>> getAncestors(RubyModule clazz); @Override Klass<?> getSuperClass(RubyModule clazz); @Override List<MethodRef> getDeclaredMethods(RubyModule clazz); @Override List<FieldRef> getDeclaredFields(RubyModule clazz); @Override List<Function> getFunctions(RubyModule clazz); @Override Class toJavaClass(RubyModule clazz); Klass<RubyModule> wrap(RubyModule m); }
RubyKlassNavigator extends KlassNavigator<RubyModule> { @Override public List<FieldRef> getDeclaredFields(RubyModule clazz) { return Collections.emptyList(); } RubyKlassNavigator(Ruby ruby, ClassLoader cl); @Override URL getResource(RubyModule clazz, String resourceName); @Override Iterable<Klass<?>> getAncestors(RubyModule clazz); @Override Klass<?> getSuperClass(RubyModule clazz); @Override List<MethodRef> getDeclaredMethods(RubyModule clazz); @Override List<FieldRef> getDeclaredFields(RubyModule clazz); @Override List<Function> getFunctions(RubyModule clazz); @Override Class toJavaClass(RubyModule clazz); Klass<RubyModule> wrap(RubyModule m);  }