Use rspec-2 wrapper for the rspec recipe.
authorHans de Graaff <graaff@gentoo.org>
Sun, 28 Dec 2014 07:23:56 +0000 (07:23 +0000)
committerHans de Graaff <graaff@gentoo.org>
Sun, 28 Dec 2014 07:23:56 +0000 (07:23 +0000)
eclass/ChangeLog
eclass/ruby-fakegem.eclass
eclass/ruby-ng.eclass

index 4e75d981ae20c7e209e64a76f8c75d6eff00c340..79589f7ef0773dc18de08169aac6e31daeb5dc8d 100644 (file)
@@ -1,6 +1,12 @@
 # ChangeLog for eclass directory
 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1481 2014/12/27 23:52:24 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1482 2014/12/28 07:23:56 graaff Exp $
+
+  28 Dec 2014; Hans de Graaff <graaff@gentoo.org> ruby-fakegem.eclass,
+  ruby-ng.eclass:
+  Use rspec-2 wrapper for the rspec recipe. This enables us to add rspec 3.x to
+  the tree while still being able to run rspec 2 specs. The changes have been
+  made in a way that is backwards compatible with the current situation.
 
   27 Dec 2014; Michał Górny <mgorny@gentoo.org> python-utils-r1.eclass:
   Update banned var docs.
index 3ed591e681fd8b6f849c3139876400033632ee6f..50da8876e31483fa3b74f4dc86b3a7c43293909e 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.42 2014/12/07 07:23:12 graaff Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.43 2014/12/28 07:23:56 graaff Exp $
 
 # @ECLASS: ruby-fakegem.eclass
 # @MAINTAINER:
@@ -141,7 +141,9 @@ case ${RUBY_FAKEGEM_RECIPE_TEST} in
                ;;
        rspec)
                IUSE+=" test"
-               ruby_add_bdepend "test? ( dev-ruby/rspec:2 )"
+               # Also require a new enough rspec-core version that installs the
+               # rspec-2 wrapper.
+               ruby_add_bdepend "test? ( dev-ruby/rspec:2 >=dev-ruby/rspec-core-2.14.8-r2 )"
                ;;
        cucumber)
                IUSE+=" test"
@@ -287,7 +289,7 @@ ruby_fakegem_genspec() {
        # so better taking this into consideration.
        local quoted_description=${DESCRIPTION//\"/\\\"}
        cat - > $1 <<EOF
-# generated by ruby-fakegem.eclass $Revision: 1.42 $
+# generated by ruby-fakegem.eclass $Revision: 1.43 $
 Gem::Specification.new do |s|
   s.name = "${RUBY_FAKEGEM_NAME}"
   s.version = "${RUBY_FAKEGEM_VERSION}"
@@ -340,7 +342,7 @@ ruby_fakegem_binwrapper() {
 #!${rubycmd}
 # This is a simplified version of the RubyGems wrapper
 #
-# Generated by ruby-fakegem.eclass $Revision: 1.42 $
+# Generated by ruby-fakegem.eclass $Revision: 1.43 $
 
 require 'rubygems'
 
@@ -436,7 +438,7 @@ each_fakegem_test() {
                        ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
                        ;;
                rspec)
-                       ruby-ng_rspec
+                       RSPEC_VERSION=2 ruby-ng_rspec
                        ;;
                cucumber)
                        ruby-ng_cucumber
index 56b6ebb4937d77c721479dc1e82db412ae778493..700d9e3de3c1ea3053f01a890e59c33b1a239ade 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.55 2014/12/27 20:04:21 graaff Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.56 2014/12/28 07:23:56 graaff Exp $
 
 # @ECLASS: ruby-ng.eclass
 # @MAINTAINER:
@@ -647,11 +647,24 @@ ruby_get_implementation() {
        esac
 }
 
-# @FUNCTION: ruby-ng_rspec
+# @FUNCTION: ruby-ng_rspec <arguments>
 # @DESCRIPTION:
 # This is simply a wrapper around the rspec command (executed by $RUBY})
 # which also respects TEST_VERBOSE and NOCOLOR environment variables.
+# Optionally takes arguments to pass on to the rspec invocation.  The
+# environment variable RSPEC_VERSION can be used to control the specific
+# rspec version that must be executed. It defaults to 2 for historical
+# compatibility.
 ruby-ng_rspec() {
+       local version=${RSPEC_VERSION-2}
+       local files="$@"
+
+       # Explicitly pass the expected spec directory since the versioned
+       # rspec wrappers don't handle this automatically.
+       if [ ${#@} -eq 0 ]; then
+               files="spec"
+       fi
+
        if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
                ewarn "Missing dev-ruby/rspec in \${DEPEND}"
        fi
@@ -675,7 +688,7 @@ ruby-ng_rspec() {
                        ;;
        esac
 
-       ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed"
+       ${RUBY} -S rspec-${version} ${rspec_params} ${files} || die "rspec failed"
 }
 
 # @FUNCTION: ruby-ng_cucumber