Skip to content
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
28 changes: 13 additions & 15 deletions active_remote-cached.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'active_remote/cached/version'

HOMEPAGE = 'https://github.com/mxenabled/active_remote-cached'
# Locals, not a constant or a def: `gem build` evals this file inside
# Gem::Specification, so top-level definitions land on that class.
homepage = 'https://github.com/mxenabled/active_remote-cached'

# git ls-files returns nothing outside a checkout, so a build from a released
# tarball needs the glob.
def gem_files
files = if File.directory?(File.join(__dir__, '.git'))
`git ls-files`.split($INPUT_RECORD_SEPARATOR)
else
Dir.glob('{lib,spec}/**/*', File::FNM_DOTMATCH) +
%w[LICENSE.txt README.md Rakefile Appraisals active_remote-cached.gemspec]
end

files.reject { |file| File.directory?(file) }
end
gem_files = if File.directory?(File.join(__dir__, '.git'))
`git ls-files`.split($INPUT_RECORD_SEPARATOR)
else
Dir.glob('{lib,spec}/**/*', File::FNM_DOTMATCH) +
%w[LICENSE.txt README.md Rakefile Appraisals active_remote-cached.gemspec]
end

Gem::Specification.new do |gem|
gem.name = 'active_remote-cached'
Expand All @@ -28,17 +26,17 @@ Gem::Specification.new do |gem|
gem.email = ['brandonsdewitt@gmail.com', 'devexperience@mx.com']
gem.description = ' Provides "cached" finders and a DSL to enumerate which finders should have cached versions '
gem.summary = ' Provides a configuration for caching mechanisms and finders on ActiveRemote models'
gem.homepage = HOMEPAGE
gem.homepage = homepage
gem.license = 'MIT'

gem.metadata = {
'homepage_uri' => HOMEPAGE,
'source_code_uri' => HOMEPAGE,
'homepage_uri' => homepage,
'source_code_uri' => homepage,
'rubygems_mfa_required' => 'true'
}

gem.required_ruby_version = '>= 3.1'
gem.files = gem_files
gem.files = gem_files.reject { |file| File.directory?(file) }
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.require_paths = ['lib']

Expand Down
29 changes: 29 additions & 0 deletions spec/gemspec_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'spec_helper'
require 'open3'

# `gem build` evals the gemspec inside Gem::Specification, but Bundler evals it
# at the top level. Bundler has already loaded the gemspec in this process, so
# a top-level def or constant from that load would hide the bug here. Load it
# in a fresh ruby without Bundler instead.
describe 'active_remote-cached.gemspec' do
let(:root) { File.expand_path('..', __dir__) }
let(:script) do
<<~RUBY
spec = Gem::Specification.load('active_remote-cached.gemspec')
abort 'Gem::Specification.load returned nil' unless spec
spec.validate
puts spec.full_name
RUBY
end

it 'loads and validates with Rubygems alone' do
stdout, stderr, status = ::Bundler.with_unbundled_env do
::Open3.capture3(::RbConfig.ruby, '-e', script, :chdir => root)
end

expect(status).to be_success, stderr
expect(stdout).to eq("active_remote-cached-#{::ActiveRemote::Cached::VERSION}\n")
end
end
Loading