[DRE-commits] [gem2deb] 02/05: gem2deb/rake/spectask: add a utility task for running tests with rspec
Antonio Terceiro
terceiro at moszumanska.debian.org
Tue Jul 21 23:43:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository gem2deb.
commit f1986323cc4037b8c7880972f74c84abaa631806
Author: Antonio Terceiro <terceiro at debian.org>
Date: Tue Jul 21 20:09:12 2015 -0300
gem2deb/rake/spectask: add a utility task for running tests with rspec
---
bin/dh_ruby | 9 ++++++++-
debian/changelog | 2 ++
debian/gem2deb-test-runner.install | 3 ++-
debian/rules | 2 +-
lib/gem2deb/dh_make_ruby.rb | 6 ++----
lib/gem2deb/rake/spectask.rb | 16 ++++++++++++++++
lib/gem2deb/rake/testtask.rb | 2 +-
7 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/bin/dh_ruby b/bin/dh_ruby
index a0d09ed..d7d8fce 100755
--- a/bin/dh_ruby
+++ b/bin/dh_ruby
@@ -285,7 +285,7 @@ ruby-mime-types:
debian/I<ruby-tests.rake> can be used to run the tests with rake(1). If you use
this file, your package must Build-Depend on the I<rake> package. You can use
anything you would use in a regular Rakefile, but you must define a default
-task. gem2deb includes utility test task that makes it easier for you by
+task. gem2deb includes a utility test task that makes it easier for you by
creating a default task automatically. Example:
require 'gem2deb/rake/testtask'
@@ -293,6 +293,13 @@ creating a default task automatically. Example:
t.test_files = FileList['test/*_test.rb']
end
+You can also use the equivalent RSpec task:
+
+ require 'gem2deb/rake/spectask'
+ Gem2Deb::Rake::RSpecTask.new do |spec|
+ spec.pattern = './spec/**/*_spec.rb'
+ end
+
If debian/I<ruby-tests.rb> exists, it will be run with each supported Ruby
version, and must finish with a exit status of I<0>, otherwise dh_ruby assumes
the tests failed. A simple example:
diff --git a/debian/changelog b/debian/changelog
index 829a281..4009cdc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ gem2deb (0.20) UNRELEASED; urgency=medium
rubygems-integration paths from different Ruby versions to GEM_PATH.
* gem2deb/rake/testtask: Use options to make all test runs verbose by
default
+ * gem2deb/rake/spectask: add a utility task for running tests with rspec
+ * dh-make-ruby: generate debian/ruby-tests.rake using gem2deb/rake/spectask
-- Antonio Terceiro <terceiro at debian.org> Mon, 20 Jul 2015 23:12:27 -0300
diff --git a/debian/gem2deb-test-runner.install b/debian/gem2deb-test-runner.install
index 1ba52d8..9457d61 100644
--- a/debian/gem2deb-test-runner.install
+++ b/debian/gem2deb-test-runner.install
@@ -1,4 +1,5 @@
bin/gem2deb-test-runner /usr/bin/
-lib/gem2deb/rake/testtask.rb /usr/lib/ruby/vendor_ruby/gem2deb/rake
lib/gem2deb/metadata.rb /usr/lib/ruby/vendor_ruby/gem2deb
+lib/gem2deb/rake/spectask.rb /usr/lib/ruby/vendor_ruby/gem2deb/rake
+lib/gem2deb/rake/testtask.rb /usr/lib/ruby/vendor_ruby/gem2deb/rake
lib/gem2deb/test_runner.rb /usr/lib/ruby/vendor_ruby/gem2deb
diff --git a/debian/rules b/debian/rules
index f10e622..0f2af45 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,7 +11,7 @@ override_dh_auto_build: $(ruby_versions)
mv man/gem2deb/gem2deb-test-runner.1 man/gem2deb-test-runner
override_dh_install:
- dh_install -pgem2deb -Xgem2deb-test-runner -Xtest_runner.rb -Xmetadata.rb -Xtesttask.rb
+ dh_install -pgem2deb -Xgem2deb-test-runner -Xtest_runner.rb -Xmetadata.rb -Xtesttask.rb -Xspectask.rb
dh_install -pgem2deb-test-runner
.PHONY: $(ruby_versions)
diff --git a/lib/gem2deb/dh_make_ruby.rb b/lib/gem2deb/dh_make_ruby.rb
index 6c04fbc..60cb811 100644
--- a/lib/gem2deb/dh_make_ruby.rb
+++ b/lib/gem2deb/dh_make_ruby.rb
@@ -389,13 +389,11 @@ module Gem2Deb
extra_build_dependencies << 'ruby-rspec' << 'rake'
maybe_create("debian/ruby-tests.rake") do |f|
f.puts <<-EOF
-require 'rspec/core/rake_task'
+require 'gem2deb/rake/spectask'
-RSpec::Core::RakeTask.new(:spec) do |spec|
+Gem2Deb::Rake::RSpecTask.new do |spec|
spec.pattern = './spec/**/*_spec.rb'
end
-
-task :default => :spec
EOF
end
true
diff --git a/lib/gem2deb/rake/spectask.rb b/lib/gem2deb/rake/spectask.rb
new file mode 100644
index 0000000..220d209
--- /dev/null
+++ b/lib/gem2deb/rake/spectask.rb
@@ -0,0 +1,16 @@
+require 'rspec/core/rake_task'
+
+module Gem2Deb
+ module Rake
+ class RSpecTask < :: RSpec::Core::RakeTask
+ def initialize(name=:default, &task_block)
+ super(name, &task_block)
+ end
+ def define(*args, &task_block)
+ self.verbose = true
+ self.rspec_opts = '--format documentation'
+ super
+ end
+ end
+ end
+end
diff --git a/lib/gem2deb/rake/testtask.rb b/lib/gem2deb/rake/testtask.rb
index 81039e8..67a592b 100644
--- a/lib/gem2deb/rake/testtask.rb
+++ b/lib/gem2deb/rake/testtask.rb
@@ -6,7 +6,7 @@ module Gem2Deb
def initialize
super(:default)
end
- def define
+ def define(args, &task_block)
self.libs.reject! { |path| ['lib','ext'].include?(path) }
self.verbose = true
ENV['TESTOPTS'] = '-v'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list