Sha256: 046de16aa601d2f51b135e25bfe8fe74f4640fda8fd7a5b3450839f3153406fe

Contents?: true

Size: 1.65 KB

Versions: 99

Compression:

Stored size: 1.65 KB

Contents

#
# Copyright 2012 Mortar Data Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'spec_helper'
require 'fakefs/spec_helpers'
require 'mortar/local/java'
require 'launchy'


class Mortar::Local::Java
  attr_reader :command
end


module Mortar::Local
  describe Java do

    context("check_install") do

      it "sets java command if JAVA_HOME is present and exists" do
        java_home = "/foo/bar/jvm"
        ENV['JAVA_HOME'] = java_home
        j = Mortar::Local::Java.new
        FakeFS do
          FileUtils.mkdir_p(java_home + "/bin")
          FileUtils.touch(java_home + "/bin/java")
          j.check_install
          expect(j.command).to eq("/foo/bar/jvm/bin/java")
        end
      end

      it "calls java_home if present and no JAVA_HOME" do
        ENV.delete('JAVA_HOME')
        j = Mortar::Local::Java.new
        exec_path = "/usr/libexec/java_home"
        FakeFS do
          FileUtils.mkdir_p(File.dirname(exec_path))
          FileUtils.touch(exec_path)
          mock(j).run_java_home.returns("/foo/bar/other-jvm")
          j.check_install
          expect(j.command).to eq("/foo/bar/other-jvm/bin/java")
        end
      end

    end


  end
end

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
mortar-0.12.5 spec/mortar/local/java_spec.rb
mortar-0.12.4 spec/mortar/local/java_spec.rb
mortar-0.12.3 spec/mortar/local/java_spec.rb
mortar-0.12.2 spec/mortar/local/java_spec.rb
mortar-0.12.1 spec/mortar/local/java_spec.rb
mortar-0.12.0 spec/mortar/local/java_spec.rb
mortar-0.11.1 spec/mortar/local/java_spec.rb
mortar-0.11.0 spec/mortar/local/java_spec.rb
mortar-0.10.1 spec/mortar/local/java_spec.rb
mortar-0.10.0 spec/mortar/local/java_spec.rb
mortar-0.9.10 spec/mortar/local/java_spec.rb
mortar-0.9.8 spec/mortar/local/java_spec.rb
mortar-0.9.7 spec/mortar/local/java_spec.rb
mortar-0.9.6 spec/mortar/local/java_spec.rb
mortar-0.9.5 spec/mortar/local/java_spec.rb
mortar-0.9.4 spec/mortar/local/java_spec.rb
mortar-0.9.3 spec/mortar/local/java_spec.rb
mortar-0.9.2 spec/mortar/local/java_spec.rb
mortar-0.9.1 spec/mortar/local/java_spec.rb
mortar-0.9.0 spec/mortar/local/java_spec.rb