Skip to content

Instantly share code, notes, and snippets.

@pvalena
Created March 21, 2022 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvalena/f8452aac96d060611e8d662a4458e9c2 to your computer and use it in GitHub Desktop.
Save pvalena/f8452aac96d060611e8d662a4458e9c2 to your computer and use it in GitHub Desktop.
--- rubygem-importmap-rails/.generated.spec 2022-03-21 14:47:24.295515791 +0100
+++ rubygem-importmap-rails/rubygem-importmap-rails.spec 2022-03-21 14:17:00.416819470 +0100
@@ -1,18 +1,29 @@
-Downloaded importmap-rails-1.0.3
# Generated from importmap-rails-1.0.3.gem by gem2rpm -*- rpm-spec -*-
%global gem_name importmap-rails
Name: rubygem-%{gem_name}
Version: 1.0.3
Release: 1%{?dist}
-Summary: Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling
+Summary: Manage modern JavaScript in Rails without transpiling or bundling
License: MIT
URL: https://github.com/rails/importmap-rails
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
+# To get the test suite:
+# git clone https://github.com/rails/importmap-rails.git --no-checkout
+# git -C importmap-rails archive -v -o importmap-rails-1.0.3-tests.txz v1.0.3 test/
+Source1: %{gem_name}-%{version}%{?prerelease}-tests.txz
+
+BuildRequires: ruby
BuildRequires: ruby(release)
+# Used for sample app
+BuildRequires: rubygem(bundler)
+BuildRequires: rubygem(rails)
+BuildRequires: rubygem(sqlite3)
BuildRequires: rubygems-devel
-BuildRequires: ruby >= 2.7.0
BuildArch: noarch
+# Bundles ES Module Shims
+# app/assets/javascripts/es-module-shims.js
+Provides: bundled(es-module-shims) = 1.4.1
%description
Use ESM with importmap to manage modern JavaScript in Rails without
@@ -28,14 +39,10 @@
Documentation for %{name}.
%prep
-%setup -q -n %{gem_name}-%{version}
+%setup -q -n %{gem_name}-%{version} -b1
%build
-# Create the gem as gem install only works on a gem file
gem build ../%{gem_name}-%{version}.gemspec
-
-# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
-# by default, so that we can move it into the buildroot in %%install
%gem_install
%install
@@ -43,11 +50,24 @@
cp -a .%{gem_dir}/* \
%{buildroot}%{gem_dir}/
-
-
%check
pushd .%{gem_instdir}
-# Run the test suite.
+ln -s %{_builddir}/test
+
+echo 'gem "rails"' >> Gemfile
+echo 'gem "sqlite3"' >> Gemfile
+
+# Test requires network access
+mv test/packager_integration_test.rb{,.disable}
+
+export BUNDLE_GEMFILE="$(pwd)/Gemfile"
+
+# Tests require building rails app (currently fails)
+# Probably requires newer Rails (7.0.1)
+echo > test/dummy/config/initializers/assets.rb
+mv test/importmap_test.rb{,.disable}
+
+ruby -Ilib:test -rbundler -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'
popd
%files
@@ -64,5 +84,5 @@
%{gem_instdir}/Rakefile
%changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment