Rake TestTask running its block anytime rake is invoked

A

Adam Anderson

--
require 'rake/testtask'

Rake::TestTask.new do |t|
chdir './../'
puts pwd
end

desc "print working directory"
task :pwd do
puts "Working Directory #{pwd}"
end
--

$ rake -T
cd ./../
/Users/scudco/projects
rake chdir # change directory
rake test # Run tests

$ rake chdir
cd ./../
/Users/scudco/projects
Working Directory /Users/scudco/projects


So the question is why does the chdir in the TestTask get executed every
time no matter what? It is quite frustrating when code specific to a
block is being executed for every other task. Any ideas?
 
A

Adam Anderson

--
require 'rake/testtask'

Rake::TestTask.new do |t|
chdir './../'
puts pwd
end

desc "print working directory"
task :pwd do
puts "Working Directory #{pwd}"
end
--

$ rake -T
cd ./../
/Users/scudco/projects
rake pwd # print working directory
rake test # Run tests

$ rake pwd
cd ./../
/Users/scudco/projects
Working Directory /Users/scudco/projects

Attachments:
http://www.ruby-forum.com/attachment/313/Rakefile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top