forked from karmi/ember-data-elasticsearch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Rake task to run tests with PhantomJS
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
%w| ansi/core popen4 |.each do |lib| | ||
begin | ||
require lib | ||
rescue LoadError => e | ||
gem_name = lib.split('/').first | ||
puts "[!] Required Rubygem '#{gem_name}' not found, install with:", | ||
" gem install #{gem_name}", "" | ||
exit(1) | ||
end | ||
end | ||
|
||
desc "Run tests with phantomjs" | ||
task :test do |t, args| | ||
unless system("which phantomjs > /dev/null 2>&1") | ||
puts ANSI.red("[!] PhantomJS is not installed, aborting... See <http://phantomjs.org>") | ||
exit(1) | ||
end | ||
|
||
system "curl -s -X DELETE 'http://localhost:9200/people-test' > /dev/null" | ||
|
||
cmd = "phantomjs tests/run-qunit.js '#{File.dirname(__FILE__)}/tests/index.html'" | ||
# puts cmd | ||
|
||
result = '' | ||
|
||
status = POpen4::popen4(cmd) do |stdout, stderr, stdin, pid| | ||
while line = stdout.gets | ||
if line =~ /Time:/ | ||
result = line.chomp | ||
else | ||
puts line | ||
end | ||
end | ||
end | ||
|
||
color = status.success? ? :green : :red | ||
puts ['='*80, result, '-'*80].join("\n").ansi( color ) | ||
exit(status.exitstatus) | ||
end |