%global gem_name shoulda-matchers
Name: rubygem-%{gem_name}
Version: 5.3.0
Release: 2
Summary: Making tests easy on the fingers and eyes
License: MIT
URL: https://github.com/thoughtbot/shoulda-matchers
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# git clone https://github.com/thoughtbot/shoulda-matchers.git && cd shoulda-matchers
# git archive -v -o shoulda-matchers-5.3.0-specs.tar.gz v5.3.0 spec/
Source1: %{gem_name}-%{version}-specs.tar.gz
# https://github.com/rspec/rspec-rails/commit/efca5295a196d74c187ebd0349abd10903c68928
Patch0:  Support-rspec-rails-7_1.patch

BuildRequires: ruby(release) rubygems-devel ruby rubygem(bcrypt) rubygem(jbuilder)
BuildRequires: rubygem(puma) rubygem(rails) rubygem(rails-controller-testing) rubygem(rspec) rubygem(rspec-rails)
BuildRequires: rubygem(shoulda-context) rubygem(spring) rubygem(sqlite3)
BuildArch: noarch

%description
shoulda-matchers provides Test::Unit- and RSpec-compatible one-liners that
test common Rails functionality. These tests would otherwise be much longer,
more complex, and error-prone.

%package doc
Summary:             Documentation for %{name}
Requires:            %{name} = %{version}-%{release}
BuildArch:           noarch
%description doc
Documentation for %{name}.

%prep
%setup -q -n %{gem_name}-%{version} -b 1

pushd %{_builddir}
%patch 0 -p1
popd

%build
gem build ../%{gem_name}-%{version}.gemspec
%gem_install

%install
mkdir -p %{buildroot}%{gem_dir}
cp -a .%{gem_dir}/* \
        %{buildroot}%{gem_dir}/



%check
pushd .%{gem_instdir}
ln -s %{_builddir}/spec spec
cat << GF > Gemfile
source 'https://rubygems.org'
gem 'actiontext'
gem 'bcrypt'
gem 'rails'
gem 'rails-controller-testing'
gem 'rspec'
gem 'rspec-rails'
gem 'sqlite3'
gem 'spring'
GF
sed -i "/require 'pry/ s/^/#/" spec/spec_helper.rb
sed -i "/current_bundle/ s/^/#/" \
  spec/acceptance_spec_helper.rb \
  spec/support/unit/load_environment.rb
sed -i "/CurrentBundle/ s/^/#/" \
  spec/acceptance_spec_helper.rb \
  spec/support/unit/load_environment.rb
sed -i '/def rails_new_command/,/^    end$/ {
  /rails new/ s/"$/ --skip-git --skip-asset-pipeline&/
}' \
  spec/support/unit/rails_application.rb
sed -i '/def rails_new_command/,/^    end$/ {
  /rails new/ s/"$/ --skip-git --skip-asset-pipeline&/
}' \
  spec/support/acceptance/helpers/step_helpers.rb
sed -i '/def load_file/,/end/ s/::load_file/::unsafe_load_file/' spec/support/tests/database_configuration.rb

bundle exec rspec spec/unit

sed -i "/add_gem 'spring-commands-rspec'/ s/^/#/" spec/support/acceptance/helpers/step_helpers.rb
sed -i "/updating_bundle do |bundle|/a \\
        bundle.add_gem 'spring'" spec/support/acceptance/helpers/step_helpers.rb
sed -i "/updating_bundle do |bundle|/a \\
        bundle.remove_gem 'capybara'" spec/support/acceptance/helpers/step_helpers.rb
sed -i "/updating_bundle do |bundle|/a \\
        bundle.remove_gem 'selenium-webdriver'" spec/support/acceptance/helpers/step_helpers.rb
sed -i "/updating_bundle do |bundle|/a \\
        bundle.remove_gem 'debug'" spec/support/acceptance/helpers/step_helpers.rb

bundle exec rspec spec/acceptance

popd


%files
%dir %{gem_instdir}
%license %{gem_instdir}/LICENSE
%{gem_libdir}
%exclude %{gem_cache}
%{gem_spec}

%files doc
%doc %{gem_docdir}
%doc %{gem_instdir}/README.md
%doc %{gem_instdir}/docs
%{gem_instdir}/shoulda-matchers.gemspec

%changelog
* Fri Nov 21 2025 yaoxin <1024769339@qq.com> - 5.3.0-2
- Support rspec-rails 7.1

* Thu Nov 16 2023 Ge Wang <wang__ge@126.com> - 5.3.0-1
- update to 5.3.0

* Tue Jan 17 2023 wulei <wulei80@h-partners.com> - 5.1.0-1
- update to 5.1.0

* Wed Jun 29 2022 liyanan <liyanan32@h-partners.com> - 4.5.1-1
- Upgrade to version 4.5.1

* Thu Mar 3 2022 liyanan <liyanan32@huawei.com> - 3.1.2-2
- fix build error

* Mon Aug 10 2020 yanan li <liyanan032@huawei.com> - 3.1.2-1
- Package init