### Question:
JRubyRackApplication implements RackApplication { @Override public RackResponse call(RackEnvironment environment) { RubyHash environmentHash = convertToRubyHash(environment.entrySet()); RubyArray response = callRackApplication(environmentHash); return convertToJavaRackResponse(response); } JRubyRackApplication(IRubyObject application); @Override RackResponse call(RackEnvironment environment);  }### Answer:
@Test public void callSetsTheResponseHeaders() { RackResponse response = app.call(env); assertThat(response.getHeaders()).contains(entry("Content-Type", "text/plain")); }
@Test public void callSetsTheResponseBody() { RackResponse response = app.call(env); ImmutableList.Builder<String> strings = ImmutableList.builder(); Iterator<byte[]> bytes = response.getBody(); while (bytes.hasNext()) { strings.add(new String(bytes.next())); } assertThat(SPACE.join(strings.build())).isEqualTo(SPACE.join(env.keySet())); }
@Test public void callParsesTheResponseStatusFromAString() { IRubyObject callable = Ruby.getGlobalRuntime() .evalScriptlet("proc { |env| ['201', {'Content-Type' => 'text/plain'}, env.keys] }"); app = new JRubyRackApplication(callable); RackResponse response = app.call(env); assertThat(response.getStatus()).isEqualTo(201); }
@Test public void callSetsTheResponseStatus() { RackResponse response = app.call(env); assertThat(response.getStatus()).isEqualTo(200); }