From 05f4aacb52711b34eca7a7482133246aefcc9aea Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Apr 01 2016 10:57:09 +0000 Subject: Fix test suite for Ruby 2.3 compatibility. --- diff --git a/rubygem-ancestry-2.1.0-fix-test-for-ruby-2.3.patch b/rubygem-ancestry-2.1.0-fix-test-for-ruby-2.3.patch new file mode 100644 index 0000000..6ba3c7c --- /dev/null +++ b/rubygem-ancestry-2.1.0-fix-test-for-ruby-2.3.patch @@ -0,0 +1,56 @@ +From 2d78eac7bf5e756f817fae9c9f8fec1071004c27 Mon Sep 17 00:00:00 2001 +From: Keenan Brock +Date: Mon, 14 Dec 2015 17:04:46 -0500 +Subject: [PATCH] support tests with various id sorting + +--- + test/concerns/sort_by_ancestry_test.rb | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/test/concerns/sort_by_ancestry_test.rb b/test/concerns/sort_by_ancestry_test.rb +index 0629d0b..878473f 100644 +--- a/test/concerns/sort_by_ancestry_test.rb ++++ b/test/concerns/sort_by_ancestry_test.rb +@@ -3,6 +3,11 @@ require_relative '../environment' + class SortByAncestryTest < ActiveSupport::TestCase + def test_sort_by_ancestry + AncestryTestDatabase.with_model do |model| ++ # - n1 ++ # - n2 ++ # - n3 ++ # - n4 ++ # - n5 + n1 = model.create! + n2 = model.create!(:parent => n1) + n3 = model.create!(:parent => n2) +@@ -10,7 +15,19 @@ class SortByAncestryTest < ActiveSupport::TestCase + n5 = model.create!(:parent => n1) + + records = model.sort_by_ancestry(model.all.sort_by(&:id).reverse) +- assert_equal [n1, n2, n4, n3, n5].map(&:id), records.map(&:id) ++ if records[1] == n2 ++ if records[2] == n3 ++ assert_equal [n1, n2, n3, n4, n5].map(&:id), records.map(&:id) ++ else ++ assert_equal [n1, n2, n4, n3, n5].map(&:id), records.map(&:id) ++ end ++ else ++ if records[3] == n3 ++ assert_equal [n1, n5, n2, n3, n4].map(&:id), records.map(&:id) ++ else ++ assert_equal [n1, n5, n2, n4, n3].map(&:id), records.map(&:id) ++ end ++ end + end + end + +@@ -27,4 +44,4 @@ class SortByAncestryTest < ActiveSupport::TestCase + assert_equal [n1, n3, n5, n2, n4, n6].map(&:id), records.map(&:id) + end + end +-end +\ No newline at end of file ++end +-- +2.5.5 + diff --git a/rubygem-ancestry.spec b/rubygem-ancestry.spec index e46ce61..5c5eec6 100644 --- a/rubygem-ancestry.spec +++ b/rubygem-ancestry.spec @@ -2,7 +2,7 @@ Name: rubygem-%{gem_name} Version: 2.1.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Organize ActiveRecord model into a tree structure Group: Development/Languages License: MIT @@ -12,13 +12,20 @@ BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby BuildArch: noarch -Provides: rubygem(%{gem_name}) = %{version} # For tests, which are not present in gem file # git clone https://github.com/stefankroes/ancestry.git && cd ancestry # git checkout v2.1.0 # tar czvf rubygem-ancestry-2.1.0-test.tar.gz test/ Source1: %{name}-%{version}-test.tar.gz +# To fix a test in Ruby 2.3 +# Define this as Source to run this patch in check section. +# https://github.com/stefankroes/ancestry/issues/237 +# git clone https://github.com/stefankroes/ancestry.git && cd ancestry +# git format-patch -1 2d78eac7bf5e756f817fae9c9f8fec1071004c27 --stdout \ +# > rubygem-ancestry-2.1.0-fix-test-for-ruby-2.3.patch +Patch0: rubygem-ancestry-2.1.0-fix-test-for-ruby-2.3.patch + BuildRequires: rubygem(activerecord) BuildRequires: rubygem(activesupport) BuildRequires: rubygem(minitest) @@ -78,6 +85,8 @@ EOF sed -i -e '5d' test/environment.rb # Remove simplecov, coveralls, test/unit, debugger requirements sed -i -e '6,15d' test/environment.rb +# Use patch command so that patch0 is not expaned in check section. +patch -p1 < %{PATCH0} ruby -Ilib -Itest -rminitest/autorun -e "Dir.glob './test/**/*_test.rb', &method(:require)" popd @@ -96,6 +105,9 @@ popd %{gem_instdir}/%{gem_name}.gemspec %changelog +* Thu Mar 31 2016 Jun Aruga - 2.1.0-4 +- Fix test suite for Ruby 2.3 compatibility. + * Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild