brew/Library/Homebrew/test/rubocops/platform_spec.rb
apainintheneck c7d53a2d9c Add cop to police os checks
The methods `OS.linux?` and `OS.mac?` should only be used
in `extend/os` and this cop makes sure of that.
2022-11-19 22:01:13 -08:00

23 lines
536 B
Ruby

# typed: false
# frozen_string_literal: true
require "rubocops/platform"
describe RuboCop::Cop::Homebrew::MoveToExtendOS do
subject(:cop) { described_class.new }
it "registers an offense when using `OS.linux?`" do
expect_offense(<<~RUBY)
OS.linux?
^^^^^^^^^ Move calls to `OS.linux?` and `OS.mac?` to `extend/os`.
RUBY
end
it "registers an offense when using `OS.mac?`" do
expect_offense(<<~RUBY)
OS.mac?
^^^^^^^ Move calls to `OS.linux?` and `OS.mac?` to `extend/os`.
RUBY
end
end