forked from rails/jquery-ujs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E.g. shotgun-powered reloadable server: $ rake test:reloadable If you don't want to use this, install the bundle without it: $ bundle install --without reloadable
- Loading branch information
Showing
4 changed files
with
68 additions
and
5 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem "json" | ||
|
||
gem "sinatra", "= 1.0" | ||
gem 'sinatra', '~> 1.0' | ||
gem 'shotgun', :group => :reloadable | ||
gem 'thin', :group => :reloadable | ||
gem 'json' |
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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
daemons (1.1.0) | ||
eventmachine (0.12.10) | ||
json (1.4.6) | ||
rack (1.2.1) | ||
sinatra (1.0) | ||
shotgun (0.8) | ||
rack (>= 1.0) | ||
sinatra (1.1.2) | ||
rack (~> 1.1) | ||
tilt (~> 1.2) | ||
thin (1.2.7) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
tilt (1.2.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
json | ||
sinatra (= 1.0) | ||
shotgun | ||
sinatra (~> 1.0) | ||
thin |
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,47 @@ | ||
desc %(Starts the test server and opens it in a web browser) | ||
multitask :default => ['test:server', 'test:open'] | ||
|
||
PORT = 4567 | ||
|
||
namespace :test do | ||
desc %(Starts the test server) | ||
task :server do | ||
system 'bundle exec ruby test/server.rb' | ||
end | ||
|
||
desc %(Starts the test server which reloads everything on each refresh) | ||
task :reloadable do | ||
exec "bundle exec shotgun test/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 | ||
|
||
# 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 |
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,3 @@ | ||
$LOAD_PATH.unshift File.expand_path('..', __FILE__) | ||
require 'server' | ||
run Sinatra::Application |