Convert Hardware test to spec.

This commit is contained in:
Markus Reiter 2017-02-14 19:26:29 +01:00
parent e116ba196e
commit 8d7d41dc85
2 changed files with 40 additions and 15 deletions

View File

@ -0,0 +1,40 @@
require "hardware"
module Hardware
describe CPU do
describe "::type" do
it "returns the current CPU's type as a symbol, or :dunno if it cannot be detected" do
expect(
[
:intel,
:ppc,
:dunno,
],
).to include(described_class.type)
end
end
describe "::family" do
it "returns the current CPU's family name as a symbol, or :dunno if it cannot be detected" do
skip "Needs an Intel CPU." unless described_class.intel?
expect(
[
:core,
:core2,
:penryn,
:nehalem,
:arrandale,
:sandybridge,
:ivybridge,
:haswell,
:broadwell,
:skylake,
:kabylake,
:dunno,
],
).to include(described_class.family)
end
end
end
end

View File

@ -1,15 +0,0 @@
require "testing_env"
require "hardware"
class HardwareTests < Homebrew::TestCase
def test_hardware_cpu_type
assert_includes [:intel, :ppc, :dunno], Hardware::CPU.type
end
if Hardware::CPU.intel?
def test_hardware_intel_family
families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :kabylake, :dunno]
assert_includes families, Hardware::CPU.family
end
end
end