Convert X11Requirement test to spec.
This commit is contained in:
parent
1292a4b219
commit
23767a378b
36
Library/Homebrew/test/x11_requirement_spec.rb
Normal file
36
Library/Homebrew/test/x11_requirement_spec.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
require "requirements/x11_requirement"
|
||||||
|
|
||||||
|
describe X11Requirement do
|
||||||
|
let(:default_name) { "x11" }
|
||||||
|
|
||||||
|
describe "#name" do
|
||||||
|
it "defaults to x11" do
|
||||||
|
expect(subject.name).to eq(default_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#eql?" do
|
||||||
|
it "returns true if the names are equal" do
|
||||||
|
other = described_class.new(default_name)
|
||||||
|
expect(subject).to eql(other)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "and returns false if the names differ" do
|
||||||
|
other = described_class.new("foo")
|
||||||
|
expect(subject).not_to eql(other)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false if the minimum version differs" do
|
||||||
|
other = described_class.new(default_name, ["2.5"])
|
||||||
|
expect(subject).not_to eql(other)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#modify_build_environment" do
|
||||||
|
it "calls ENV#x11" do
|
||||||
|
allow(subject).to receive(:satisfied?).and_return(true)
|
||||||
|
expect(ENV).to receive(:x11)
|
||||||
|
subject.modify_build_environment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,31 +0,0 @@
|
|||||||
require "testing_env"
|
|
||||||
require "requirements/x11_requirement"
|
|
||||||
|
|
||||||
class X11RequirementTests < Homebrew::TestCase
|
|
||||||
def test_eql_instances_are_eql
|
|
||||||
x = X11Requirement.new
|
|
||||||
y = X11Requirement.new
|
|
||||||
assert_eql x, y
|
|
||||||
assert_equal x.hash, y.hash
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_not_eql_when_hashes_differ
|
|
||||||
x = X11Requirement.new("foo")
|
|
||||||
y = X11Requirement.new
|
|
||||||
refute_eql x, y
|
|
||||||
refute_equal x.hash, y.hash
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_different_min_version
|
|
||||||
x = X11Requirement.new
|
|
||||||
y = X11Requirement.new("x11", %w[2.5])
|
|
||||||
refute_eql x, y
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_x_env
|
|
||||||
x = X11Requirement.new
|
|
||||||
x.stubs(:satisfied?).returns(true)
|
|
||||||
ENV.expects(:x11)
|
|
||||||
x.modify_build_environment
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user