Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ gem "rubocop", "~> 1.21"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "tty-table"

# Optional dependencies — loaded lazily by the feature that needs them.
group :optional do
Expand Down
1 change: 1 addition & 0 deletions dcc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "mml", "~> 2.4.0"
spec.add_dependency "moxml", "~> 0.1.26"
spec.add_dependency "thor"
spec.add_dependency "tty-table"
end
1 change: 0 additions & 1 deletion lib/dcc/cli/cli.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "thor"
require "tty-table"

# `Dcc::Cli::Cli` is the Thor-based command-line interface. Each subcommand
# (validate, convert, extract, signature, transform, inspect, diff, issue)
Expand Down
37 changes: 37 additions & 0 deletions spec/dcc/cli/dependencies_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require "spec_helper"

# The CLI ships as `exe/dcc`. Every gem it requires at load time must be a
# declared runtime dependency, or `gem install dcc` yields a binary that
# crashes on every command.
# rubocop:disable RSpec/DescribeClass -- packaging invariant, not a class
RSpec.describe "dcc CLI runtime dependencies" do
let(:root) { File.expand_path("../../..", __dir__) }
Comment thread
HassanAkbar marked this conversation as resolved.
let(:gemspec) { Gem::Specification.load(File.join(root, "dcc.gemspec")) }
let(:declared) { gemspec.runtime_dependencies.map(&:name) }
let(:stdlib) do
%w[base64 bigdecimal csv date digest json open3 openssl set stringio yaml]
end

# Matches indented requires (inside a method or conditional) and both quote
# styles. Does not match parenthesized, multiline, or interpolated requires
# -- add one of those and this guard will not see it.
let(:required) do
pattern = /^\s*require ["']([^"']+)["']/
Dir[File.join(root, "lib", "dcc", "cli", "**", "*.rb")]
.flat_map { |f| File.read(f).scan(pattern).flatten }
.reject { |name| name.start_with?("dcc/") }
.map { |name| name.split("/").first }
.uniq - stdlib
end

it "finds the gems the CLI requires" do
expect(required).to include("thor", "tty-table")
end

it "declares every third-party gem the CLI requires" do
expect(required - declared).to be_empty
end
end
# rubocop:enable RSpec/DescribeClass
Loading