Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic test for .gemspec sanity #13099

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 1 addition & 0 deletions decidim-dev/config/rubocop/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RSpec/ContextWording:
RSpec/DescribeClass:
Exclude:
- spec/gemfiles_spec.rb
- spec/gemspecs_spec.rb
- spec/webpacker_spec.rb
- spec/version_files_spec.rb
- spec/spellcheck_spec.rb
Expand Down
56 changes: 56 additions & 0 deletions spec/gemspecs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

describe "Gemspec sanity" do
let(:root_dir) { File.expand_path("..", __dir__) }
let(:decidim_spec) { gemspec("decidim") }

describe "decidim module specs" do
let(:decidim_module_specs) do
decidim_spec.dependencies.select { |dep| dep.name =~ /^decidim-/ }.map(&:to_spec)
end

it "do not require the `decidim` gem" do
expect(decidim_module_specs).to all(be_decidim_clean)
end
end

describe "decidim-dev spec" do
let(:decidim_dev_spec) { gemspec("decidim-dev") }

it "does not require the `decidim` gem" do
expect(decidim_dev_spec).to be_decidim_clean
end
end

def gemspec(name)
gemspec_file =
if name == "decidim"
"#{root_dir}/decidim.gemspec"
else
"#{root_dir}/#{name}/#{name}.gemspec"
end

Gem::Specification.load(gemspec_file)
end

def be_decidim_clean
BeDecidimClean.new
end

class BeDecidimClean
attr_reader :spec

def matches?(given_spec)
@spec = given_spec
spec.dependencies.all? { |dep| dep.name != "decidim" }
end

def failure_message
"expected '#{spec.name}' gem not to have the 'decidim' gem as its dependency"
end

def failure_message_when_negated
"expected '#{spec.name}' gem to have the 'decidim' gem as its dependency"
end
end
end
Loading