Rakefile in rcmd-1.6.3 vs Rakefile in rcmd-1.6.4
- old
+ new
@@ -1,70 +1,70 @@
require "bundler/gem_tasks"
-require "rspec/core/rake_task"
require 'rdoc/task'
-# require 'sqlite3'
-RSpec::Core::RakeTask.new(:spec)
+task :default => ['test:all']
-task :default => :spec
desc "Open an IRB console with this gem loaded"
task :console do
require 'irb'
require 'irb/completion'
require 'rcmd'
ARGV.clear
IRB.start
end
+
desc "Remove, build, and install gem"
task :reinstall do
puts "Uninstalling #{`gem list rcmd`}"
`gem uninstall -x rcmd`
Rake::Task["install"].reenable
Rake::Task["install"].invoke
end
-desc 'generate API documentation to doc/rdocs/index.html'
+desc 'generate API documentation to doc/rdocs/index.html'
Rake::RDocTask.new do |rd|
rd.rdoc_dir = 'doc/rdocs'
rd.main = 'README.md'
rd.rdoc_files.include 'README.md', "lib/**/*\.rb", "exe/**/*"
rd.options << '--line-numbers'
rd.options << '--all'
end
-# desc 'generate and populate a test sqlite database'
-# task :testdb do
-# begin
-# db = SQLite3::Database.new "testdb"
-# db.execute "create table servers(id integer primary key autoincrement, hostname text not null, stype text not null, os_type text not null)"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node1', 'dev', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node2', 'dev', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node3', 'dev', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node4', 'dev', 'rhel7')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node5', 'dev', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node6', 'web', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node7', 'web', 'rhel6')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node8', 'web', 'rhel7')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node9', 'web', 'rhel7')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node10', 'admin', 'ubuntu-LTS')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node11', 'admin', 'ubuntu-LTS')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node12', 'admin', 'ubuntu')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node13', 'admin', 'ubuntu')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node14', 'compute', 'debiuan')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node15', 'compute', 'debiuan')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node16', 'compute', 'debiuan')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node17', 'compute', 'debiuan')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node18', 'db', 'slackware')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node19', 'db', 'slackware')"
-# db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node20', 'db', 'slackware')"
+#
+# RSpec tasks
+#
+begin
+ namespace :test do
+ require "rspec/core/rake_task"
+ require 'sqlite3'
-# rescue SQLite3::Exception => e
-# puts "Exception occurred"
-# puts e
-# ensure
-# db.close if db
-# end
-# end
+ desc 'Test Database functionality (sqlite3 required)'
+ RSpec::Core::RakeTask.new(:db) do |t|
+ t.rspec_opts = "--tag db"
+ end
+ end
+
+ namespace :test do
+ desc 'Test main rcmd lib'
+ RSpec::Core::RakeTask.new(:mainlib) do |t|
+ t.rspec_opts = "--tag mainlib"
+ end
+ end
+
+ namespace :test do
+ desc "Run all RSpec tests"
+ RSpec::Core::RakeTask.new(:all) do |t|
+ t.rspec_opts = "--tag mainlib --tag db"
+ end
+ end
+rescue LoadError
+ desc 'RSpec rake task not available'
+ task :spec do
+ abort 'RSpec rake tasl is not available. Ensure rspec-core is installed'
+ end
+ensure
+ File.delete("testdb") if File.exist?("testdb")
+end