Skip to content

Instantly share code, notes, and snippets.

@pvalena
Created January 25, 2022 22:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvalena/1f547051a0c5e790961d8d935cfdd9c3 to your computer and use it in GitHub Desktop.
Save pvalena/1f547051a0c5e790961d8d935cfdd9c3 to your computer and use it in GitHub Desktop.
--- rubygem-i18n/.generated.spec 2022-01-25 23:39:19.573230382 +0100
+++ rubygem-i18n/rubygem-i18n.spec 2022-01-25 23:27:59.134790655 +0100
@@ -1,21 +1,33 @@
-Downloaded i18n-1.8.11
-# Generated from i18n-1.8.7.gem by gem2rpm -*- rpm-spec -*-
%global gem_name i18n
+%bcond_without tests
+
Name: rubygem-%{gem_name}
-Version: 1.8.7
+Version: 1.8.11
Release: 1%{?dist}
Summary: New wave Internationalization support for Ruby
-License: MIT
+# `BSD or Ruby` due to header of lib/i18n/gettext/po_parser.rb
+License: MIT and (BSD or Ruby)
URL: https://github.com/ruby-i18n/i18n
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
+# Since 1.8.2 tests are not shipped with the gem, but can be checked like
+# git clone --no-checkout https://github.com/ruby-i18n/i18n
+# cd i18n && git archive -v -o i18n-1.8.11-tests.txz v1.8.11 test
+Source1: %{gem_name}-%{version}-tests.txz
+BuildRequires: ruby
BuildRequires: ruby(release)
-BuildRequires: rubygems-devel >= 1.3.5
-BuildRequires: ruby >= 2.3.0
+BuildRequires: rubygems-devel
+%if %{with tests}
+BuildRequires: rubygem(minitest)
+BuildRequires: rubygem(mocha)
+BuildRequires: rubygem(test_declarative)
+BuildRequires: rubygem(concurrent-ruby)
+BuildRequires: rubygem(activesupport)
+%endif
BuildArch: noarch
%description
-New wave Internationalization support for Ruby.
+Ruby Internationalization and localization solution.
%package doc
@@ -27,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
@@ -42,12 +50,25 @@
cp -a .%{gem_dir}/* \
%{buildroot}%{gem_dir}/
-
-
+%if %{with tests}
%check
pushd .%{gem_instdir}
-# Run the test suite.
+ln -s %{_builddir}/test .
+
+# Bundler just complicates everything in our case, remove it.
+sed -i -e "/require 'bundler\/setup'/ s/^/#/" test/test_helper.rb
+
+# Mocha needs to be required differently
+# TODO: PR @ https://github.com/ruby-i18n/i18n/edit/master/test/test_helper.rb#L16
+sed -i 's/\(require .mocha\/\)setup/\1minitest/' test/test_helper.rb
+
+# Tests are failing without LANG environment is set.
+# https://github.com/svenfuchs/i18n/issues/115
+LANG=C.utf8 \
+find ./test/ -type f -name '*_test.rb' -exec \
+ ruby -Ilib:test '{}' \;
popd
+%endif
%files
%dir %{gem_instdir}
@@ -61,5 +82,132 @@
%doc %{gem_instdir}/README.md
%changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment