Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New task 'cucumber:spring' to start Tomcat and run Cucumber

Also change ENV['TESTHOST'] to ENV['TESTURL'].
  • Loading branch information...
commit 1c048eed7a1eb894c87497c0b3cc9487fedbb9d6 1 parent 6fa8848
@nicksieger authored
View
2  config/cucumber.yml
@@ -2,7 +2,7 @@
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
tags = "~@wip"
-tags += " --tags ~@extended" if ENV['TESTHOST']
+tags += " --tags ~@extended" if ENV['TESTURL']
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --color --tags #{tags}"
%>
default: <%= std_opts %> features
View
4 features/support/env.rb
@@ -4,7 +4,7 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
-if ENV["TESTHOST"] # Standalone Cucumber/Capybara/Celerity
+if ENV["TESTURL"] # Standalone Cucumber/Capybara/Celerity
# Hat tip to http://stackoverflow.com/questions/3164593/is-it-possible-to-test-java-application-with-capybara/3607791#3607791
require 'capybara'
require 'capybara/cucumber'
@@ -18,7 +18,7 @@
Capybara.default_driver = :celerity
Capybara.use_default_driver
Capybara.run_server = false
- Capybara.app_host = ENV["TESTHOST"]
+ Capybara.app_host = ENV["TESTURL"]
else
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
View
6 lib/tasks/test.rake
@@ -1,6 +0,0 @@
-namespace :cucumber do
- task :remote do
- ENV['TESTHOST'] = 'http://localhost:3000'
- Rake::Task['cucumber'].invoke
- end
-end
View
37 lib/tasks/tomcat.rake
@@ -2,4 +2,41 @@ namespace :tomcat do
task :run do
sh "mvn org.codehaus.mojo:tomcat-maven-plugin:run -Dmaven.tomcat.path=/ -Dmaven.tomcat.port=3000"
end
+
+ task :background do
+ Thread.new do
+ Rake::Task['tomcat:run'].invoke
+ end
+ loop do
+ require 'open-uri'
+ begin
+ open('http://localhost:3000/')
+ break
+ rescue
+ sleep 2
+ end
+ end
+ puts "Tomcat started in the background"
+
+ at_exit do
+ Rake::Task['tomcat:kill'].invoke
+ end
+ end
+
+ task :kill do
+ tomcat_pid = `jps -m`.detect{|l| l =~ /tomcat-maven/}.to_i
+ if tomcat_pid > 0
+ puts "Killing Tomcat with PID #{tomcat_pid}"
+ sh "kill #{tomcat_pid}"
+ end
+ end
+end
+
+namespace :cucumber do
+ task :spring => ['tomcat:background', 'cucumber:remote']
+
+ task :remote do
+ ENV['TESTURL'] = 'http://localhost:3000'
+ Rake::Task['cucumber'].invoke
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.