Resolve dependable_spec violation

This commit is contained in:
Douglas Eichelberger 2023-01-22 17:03:27 -08:00
parent ea832538f7
commit 89c7117b30
5 changed files with 12 additions and 10 deletions

View File

@ -11,6 +11,8 @@ module Dependable
# misuse in future. # misuse in future.
RESERVED_TAGS = [:build, :optional, :recommended, :run, :test, :linked].freeze RESERVED_TAGS = [:build, :optional, :recommended, :run, :test, :linked].freeze
attr_reader :tags
def build? def build?
tags.include? :build tags.include? :build
end end

View File

@ -1,5 +0,0 @@
# typed: strict
module Dependable
def tags; end
end

View File

@ -13,7 +13,7 @@ class Dependency
include Dependable include Dependable
extend Cachable extend Cachable
attr_reader :name, :tags, :env_proc, :option_names attr_reader :name, :env_proc, :option_names
DEFAULT_ENV_PROC = proc {}.freeze DEFAULT_ENV_PROC = proc {}.freeze
private_constant :DEFAULT_ENV_PROC private_constant :DEFAULT_ENV_PROC

View File

@ -17,7 +17,7 @@ class Requirement
include Dependable include Dependable
extend Cachable extend Cachable
attr_reader :tags, :name, :cask, :download attr_reader :name, :cask, :download
def initialize(tags = []) def initialize(tags = [])
# Only allow instances of subclasses. This base class enforces no constraints on its own. # Only allow instances of subclasses. This base class enforces no constraints on its own.

View File

@ -6,9 +6,14 @@ require "dependable"
describe Dependable do describe Dependable do
alias_matcher :be_a_build_dependency, :be_build alias_matcher :be_a_build_dependency, :be_build
subject(:dependable) { double(tags: tags).extend(described_class) } subject(:dependable) {
Class.new {
let(:tags) { ["foo", "bar", :build] } include Dependable
def initialize
@tags = ["foo", "bar", :build]
end
}.new
}
specify "#options" do specify "#options" do
expect(dependable.options.as_flags.sort).to eq(%w[--foo --bar].sort) expect(dependable.options.as_flags.sort).to eq(%w[--foo --bar].sort)