From 7c37e2e660207d9ea30639a9a869f29c27d9f9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Wed, 21 Jan 2015 15:56:39 +0100 Subject: [PATCH] Use Minitest 5 --- ...gem-test_declarative-0.0.5-minitest5.patch | 81 +++++++++++++++++++ rubygem-test_declarative.spec | 14 +++- 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 rubygem-test_declarative-0.0.5-minitest5.patch diff --git a/rubygem-test_declarative-0.0.5-minitest5.patch b/rubygem-test_declarative-0.0.5-minitest5.patch new file mode 100644 index 0000000..cf1851b --- /dev/null +++ b/rubygem-test_declarative-0.0.5-minitest5.patch @@ -0,0 +1,81 @@ +From e05fcfffb7ccafcae89674460b2b46dd87b62b7b Mon Sep 17 00:00:00 2001 +From: Josef Stribny +Date: Mon, 19 Jan 2015 18:28:42 +0100 +Subject: [PATCH] Add support for Minitest >=5 + +- add Minitest 5 support +- change tests to work with both test/unit (if available) and Minitest 5 +- fix the test suite on Ruby 1.8.7 by explicitely requiring test/unit/testresult +--- + lib/test_declarative.rb | 1 + + test/test_declarative_test.rb | 37 ++++++++++++++++++++++++++++++++----- + test_declarative.gemspec | 1 + + 3 files changed, 34 insertions(+), 5 deletions(-) + +diff --git a/lib/test_declarative.rb b/lib/test_declarative.rb +index 34ae02b..aae5f74 100644 +--- a/lib/test_declarative.rb ++++ b/lib/test_declarative.rb +@@ -1,6 +1,7 @@ + targets = [Module] + targets << Test::Unit::TestCase if defined?(Test::Unit::TestCase) + targets << MiniTest::Unit::TestCase if defined?(MiniTest::Unit::TestCase) ++targets << Minitest::Test if defined?(Minitest::Test) + + targets.each do |target| + target.class_eval do +diff --git a/test/test_declarative_test.rb b/test/test_declarative_test.rb +index abc1278..c18ff6e 100644 +--- a/test/test_declarative_test.rb ++++ b/test/test_declarative_test.rb +@@ -1,17 +1,44 @@ + $: << File.expand_path('../../lib', __FILE__) + +-require 'test/unit' ++# Test with test/unit for older Rubies ++begin ++ require 'test/unit' ++ require 'test/unit/testresult' ++ if RUBY_VERSION < '1.9.1' ++ # test/unit ++ TEST_CASE = Test::Unit::TestCase ++ RUNNER = Test::Unit::TestResult ++ MINITEST_5 = false ++ else ++ # Minitest < 5 ++ TEST_CASE = Test::Unit::TestCase ++ RUNNER = MiniTest::Unit ++ MINITEST_5 = false ++ end ++rescue LoadError ++ # Minitest >= 5 ++ require 'minitest/autorun' ++ TEST_CASE = Minitest::Test ++ RUNNER = Minitest::Unit ++ MINITEST_5 = true ++end ++ + require 'test_declarative' + +-class TestDeclarativeTest < Test::Unit::TestCase ++class TestDeclarativeTest < TEST_CASE + def test_responds_to_test + assert self.class.respond_to?(:test) + end + + def test_adds_a_test_method + called = false +- assert_nothing_raised { Test::Unit::TestCase.test('some test') { called = true } } +- Test::Unit::TestCase.new(:'test_some_test').run((RUBY_VERSION < '1.9.1' ? Test::Unit::TestResult : MiniTest::Unit).new) {} ++ TEST_CASE.test('some test') { called = true } ++ case MINITEST_5 ++ when false ++ TEST_CASE.new(:'test_some_test').run(RUNNER.new) {} ++ when true ++ TEST_CASE.new(:'test_some_test').run() {} ++ end + assert called + end +-end +\ No newline at end of file ++end diff --git a/rubygem-test_declarative.spec b/rubygem-test_declarative.spec index 533395f..6a76f2b 100644 --- a/rubygem-test_declarative.spec +++ b/rubygem-test_declarative.spec @@ -4,14 +4,17 @@ Summary: Simply adds a declarative test method syntax to test/unit Name: rubygem-%{gem_name} Version: 0.0.5 -Release: 7%{?dist} +Release: 8%{?dist} Group: Development/Languages License: MIT URL: http://github.com/svenfuchs/test_declarative Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem +# Minitest 5 support +# https://github.com/svenfuchs/test_declarative/pull/4 +Patch0: rubygem-test_declarative-0.0.5-minitest5.patch BuildRequires: ruby(release) BuildRequires: rubygems-devel -BuildRequires: rubygem(minitest) < 5 +BuildRequires: rubygem(minitest) BuildArch: noarch %description @@ -32,6 +35,10 @@ Documentation for %{name} %setup -q -c -T %gem_install -n %{SOURCE0} +pushd .%{gem_instdir} +%patch0 -p1 +popd + %build %install @@ -58,6 +65,9 @@ popd %changelog +* Mon Jan 19 2015 Josef Stribny - 0.0.5-8 +- Use Minitest 5 + * Thu Jun 19 2014 Vít Ondruch - 0.0.5-7 - Fix FTBFS in Rawhide (rhbz#1107256).