Debian Codegraph @

tests/inputs/issues/365/RSpecTests.java

raw
1 /*
2 * https://raw.githubusercontent.com/elastic/logstash/master/x-pack/src/test/java/org/logstash/xpack/test/RSpecTests.java
3 */
4 package org.logstash.xpack.test;
5
6 import java.nio.charset.StandardCharsets;
7 import java.nio.file.Files;
8 import java.nio.file.Path;
9 import java.nio.file.Paths;
10 import java.util.Arrays;
11 import org.jruby.runtime.builtin.IRubyObject;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.logstash.RubyUtil;
15 import org.logstash.Rubyfier;
16
17 public final class RSpecTests {
18 @Test
19 public void rspecTests() throws Exception {
20 RubyUtil.RUBY.getENV().put("IS_JUNIT_RUN", "true");
21 RubyUtil.RUBY.getGlobalVariables().set(
22 "$JUNIT_ARGV", Rubyfier.deep(RubyUtil.RUBY, Arrays.asList(
23 "-fd", "--pattern", "spec/**/*_spec.rb"
24 ))
25 );
26 final Path rspec = Paths.get(
27 org.assertj.core.util.Files.currentFolder().getParent(), "lib/bootstrap/rspec.rb"
28 );
29 final IRubyObject result = RubyUtil.RUBY.executeScript(
30 new String(Files.readAllBytes(rspec), StandardCharsets.UTF_8),
31 rspec.toFile().getAbsolutePath()
32 );
33 if (!result.toJava(Long.class).equals(0L)) {
34 Assert.fail("RSpec test suit saw at least one failure.");
35 }
36 }
37 }