Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (55 sloc) 1.798 kb
require 'bundler'
Bundler::GemHelper.install_tasks
multitask :default => 'test:ruby'
require 'rake/testtask'
namespace :test do
desc %(Run all tests)
multitask :all => ['test:all_rubies', 'test:js']
desc %(Test Ruby code)
Rake::TestTask.new(:ruby) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/*/cases/**/test_*.rb'
test.verbose = true
end
task :all_rubies do
system "rvm ruby-1.8.7@client_side_validations,ruby-1.9.2@client_side_validations rake test:ruby"
end
desc %(Test Javascript code)
multitask :js => ['test:server', 'test:open']
desc %(Starts the test server)
task :server do
system 'bundle exec ruby test/javascript/server.rb'
end
desc %(Starts the test server which reloads everything on each refresh)
task :reloadable do
exec "bundle exec shotgun test/javascript/config.ru -p #{PORT} --server thin"
end
task :open do
url = "http://localhost:#{PORT}"
puts "Opening test app at #{url} ..."
sleep 3
system( *browse_cmd(url) )
end
end
PORT = 4567
# Returns an array e.g.: ['open', 'http://example.com']
def browse_cmd(url)
require 'rbconfig'
browser = ENV['BROWSER'] ||
(RbConfig::CONFIG['host_os'].include?('darwin') && 'open') ||
(RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw|windows/ && 'start') ||
%w[xdg-open x-www-browser firefox opera mozilla netscape].find { |comm| which comm }
abort('ERROR: no web browser detected') unless browser
Array(browser) << url
end
# which('ruby') #=> /usr/bin/ruby
def which cmd
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = "#{path}/#{cmd}#{ext}"
return exe if File.executable? exe
}
end
return nil
end
Jump to Line
Something went wrong with that request. Please try again.