File: jruby_spec.rb

package info (click to toggle)
ruby-aruba 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,972 kB
  • sloc: ruby: 7,151; javascript: 6,850; makefile: 5
file content (79 lines) | stat: -rw-r--r-- 2,340 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require "spec_helper"
require "aruba/api"

describe "Aruba JRuby Startup Helper" do
  include Aruba::Api

  let(:rb_config) { instance_double(Hash) }
  let(:command) do
    instance_double(Aruba::Processes::BasicProcess, environment: command_environment)
  end
  let(:command_environment) { { "JRUBY_OPTS" => "--1.9", "JAVA_OPTS" => "-Xdebug" } }

  before do
    Aruba.config.reset

    # Define before :command hook
    load "aruba/config/jruby.rb"
  end

  context "when running under some MRI Ruby" do
    before do
      stub_const("RUBY_PLATFORM", "x86_64-chocolate")
    end

    it "keeps the existing JRUBY_OPTS and JAVA_OPTS environment values" do
      # Run defined before :command hook
      Aruba.config.run_before_hook :command, self, command

      aggregate_failures do
        expect(command_environment["JRUBY_OPTS"]).to eq "--1.9"
        expect(command_environment["JAVA_OPTS"]).to eq "-Xdebug"
      end
    end
  end

  context "when running under JRuby but not on Solaris" do
    before do
      unless RUBY_PLATFORM == "java"
        stub_const "RUBY_PLATFORM", "java"
        stub_const "JRUBY_VERSION", "9.2.0.0"
      end
      stub_const "RbConfig::CONFIG", rb_config

      allow(rb_config).to receive(:[]).with("host_os").and_return("foo-os")
    end

    it "updates the existing JRuby but not Java option values" do
      # Run defined before :command hook
      Aruba.config.run_before_hook :command, self, command

      aggregate_failures do
        expect(command_environment["JRUBY_OPTS"]).to eq "--dev -X-C --1.9"
        expect(command_environment["JAVA_OPTS"]).to eq "-Xdebug"
      end
    end
  end

  context "when running under JRuby on Solaris" do
    before do
      unless RUBY_PLATFORM == "java"
        stub_const "RUBY_PLATFORM", "java"
        stub_const "JRUBY_VERSION", "9.2.0.0"
      end
      stub_const "RbConfig::CONFIG", rb_config

      allow(rb_config).to receive(:[]).with("host_os").and_return("solaris")
    end

    it "keeps the existing JRuby and Java option values" do
      # Run defined before :command hook
      Aruba.config.run_before_hook :command, self, command

      aggregate_failures do
        expect(command_environment["JRUBY_OPTS"]).to eq "--dev -X-C --1.9"
        expect(command_environment["JAVA_OPTS"]).to eq "-d32 -Xdebug"
      end
    end
  end
end