2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-18 22:17:32 +01:00
|
|
|
require "compilers"
|
|
|
|
|
2017-02-20 22:24:44 +01:00
|
|
|
describe CompilerFailure do
|
2017-05-09 23:00:51 +02:00
|
|
|
alias_matcher :fail_with, :be_fails_with
|
|
|
|
|
2017-02-18 22:17:32 +01:00
|
|
|
describe "::create" do
|
|
|
|
it "creates a failure when given a symbol" do
|
|
|
|
failure = described_class.create(:clang)
|
2023-01-22 17:05:33 -08:00
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 600),
|
|
|
|
)
|
2017-02-18 22:17:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "can be given a build number in a block" do
|
2019-01-26 17:13:14 +00:00
|
|
|
failure = described_class.create(:clang) { build 700 }
|
2023-01-22 17:05:33 -08:00
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 700),
|
|
|
|
)
|
2017-02-18 22:17:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "can be given an empty block" do
|
2023-03-08 23:14:46 +00:00
|
|
|
failure = described_class.create(:clang) do
|
2023-01-26 21:18:24 -08:00
|
|
|
# do nothing
|
2023-03-08 23:14:46 +00:00
|
|
|
end
|
2023-01-22 17:05:33 -08:00
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 600),
|
|
|
|
)
|
2017-02-18 22:17:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a failure when given a hash" do
|
2019-01-08 19:13:46 +00:00
|
|
|
failure = described_class.create(gcc: "7")
|
2023-01-22 17:05:33 -08:00
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-7", version: Version.new("7")),
|
|
|
|
)
|
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(
|
|
|
|
CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-7", version: Version.new("7.1")
|
|
|
|
),
|
|
|
|
)
|
|
|
|
expect(failure).not_to fail_with(
|
|
|
|
instance_double(
|
|
|
|
CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-6", version: Version.new("6.0")
|
|
|
|
),
|
|
|
|
)
|
2017-02-18 22:17:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a failure when given a hash and a block with aversion" do
|
2019-01-08 19:13:46 +00:00
|
|
|
failure = described_class.create(gcc: "7") { version "7.1" }
|
2023-01-22 17:05:33 -08:00
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-7", version: Version.new("7")),
|
|
|
|
)
|
|
|
|
expect(failure).to fail_with(
|
|
|
|
instance_double(
|
|
|
|
CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-7", version: Version.new("7.1")
|
|
|
|
),
|
|
|
|
)
|
|
|
|
expect(failure).not_to fail_with(
|
|
|
|
instance_double(
|
|
|
|
CompilerSelector::Compiler, "Compiler", type: :gcc, name: "gcc-7", version: Version.new("7.2")
|
|
|
|
),
|
|
|
|
)
|
2017-02-18 22:17:32 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|