Merge pull request #2158 from reitermarkus/spec---env

Convert `brew --env` test to spec.
This commit is contained in:
Markus Reiter 2017-02-24 17:03:56 +01:00 committed by GitHub
commit b7d3c6df62
2 changed files with 44 additions and 27 deletions

View File

@ -2,33 +2,6 @@ require "testing_env"
require "extend/ENV"
require "testing_env"
class IntegrationCommandTestEnv < IntegrationCommandTestCase
def test_env
assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/,
cmd("--env"))
end
def test_env_fish
assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
cmd("--env", "--shell=fish"))
end
def test_env_csh
assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/,
cmd("--env", "--shell=tcsh"))
end
def test_env_bash
assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
cmd("--env", "--shell=bash"))
end
def test_env_plain
assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/,
cmd("--env", "--plain"))
end
end
module SharedEnvTests
def setup
super

View File

@ -0,0 +1,44 @@
describe "brew --env", :integration_test do
it "prints the Homebrew build environment variables" do
expect { brew "--env" }
.to output(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
describe "--shell=bash" do
it "prints the Homebrew build environment variables in Bash syntax" do
expect { brew "--env", "--shell=bash" }
.to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
describe "--shell=fish" do
it "prints the Homebrew build environment variables in Fish syntax" do
expect { brew "--env", "--shell=fish" }
.to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
describe "--shell=tcsh" do
it "prints the Homebrew build environment variables in Tcsh syntax" do
expect { brew "--env", "--shell=tcsh" }
.to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
describe "--plain" do
it "prints the Homebrew build environment variables without quotes" do
expect { brew "--env", "--plain" }
.to output(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
end