Browse files

git rake tasks to run, including rspec

  • Loading branch information...
1 parent 4280340 commit 4c25c1d387c641b0ac6c69f10d73fc92e7546a21 @kevwil committed Mar 26, 2011
Showing with 416 additions and 406 deletions.
  1. +9 −1 Rakefile
  2. +2 −0 lib/aspen.rb
  3. +152 −152 lib/aspen/runner.rb
  4. +111 −111 lib/aspen/server.rb
  5. +113 −113 spec/runner_spec.rb
  6. +27 −27 spec/server_spec.rb
  7. +2 −2 spec/spec_helper.rb
View
10 Rakefile
@@ -1,6 +1,14 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+require 'rspec/core/rake_task'
+
+RSpec::Core::RakeTask.new(:spec)
+
+task :default => ['java:build', :spec]
+task :build => ['java:build', :spec]
+task :clean => ['java:clean', 'java:clobber', 'doc:clean']
+
require 'fileutils'
namespace :doc do
@@ -27,7 +35,7 @@ namespace :java do
desc "build java code and copy jars to lib folder"
task :build => :clean do
- system "cd javalib;mvn --offline package;cp target/*.jar ../lib/java;cd .."
+ system "cd javalib;mvn --offline package;cp -vX target/*.jar ../lib/java/;cd .."
end
end
View
2 lib/aspen.rb
@@ -8,4 +8,6 @@
module Aspen
# should I use autoload?
+ require 'aspen/runner'
+ require 'aspen/server'
end
View
304 lib/aspen/runner.rb
@@ -11,158 +11,158 @@ class RunnerError < RuntimeError; end
# @since 1.0.0
# @version 1.0.0
class Runner
-
- COMMANDS = %w(start stop config)
-
- # Commands that wont load options from the config file
- CONFIGLESS_COMMANDS = %w(config)
-
- # Parsed options
- attr_accessor :options
-
- # Name of the command to be runned.
- attr_accessor :command
-
- # Arguments to be passed to the command.
- attr_accessor :arguments
-
- # Return all available commands
- def self.commands
- COMMANDS
- end
-
- # create a new instance
- # @param [Array] command-line arguments
- def initialize(argv)
- @argv = argv
-
- # Default options values
- @options = {
- :chdir => Dir.pwd,
- :environment => 'development',
- :address => Aspen::Server::DEFAULT_HOST,
- :port => Aspen::Server::DEFAULT_PORT,
- :log => 'log/aspen.log',
- :pid => 'tmp/pids/aspen.pid',
- :require => []
- }
-
- parse!
- end
-
- # build up a parser in @parser
- # @return [OptionParser] the option handler
- def parser
- # NOTE: If you add an option here make sure the key in the +options+ hash is the
- # same as the name of the command line option.
- @parser ||= OptionParser.new do |opts|
- opts.banner = "Usage: aspen [options] #{self.class.commands.join('|')}"
-
- opts.separator ""
- opts.separator "Server options:"
-
- opts.on("-a", "--address HOST", "bind to HOST address " +
- "(default: #{@options[:address]})") { |host| @options[:address] = host }
- opts.on("-p", "--port PORT", "use PORT (default: #{@options[:port]})") { |port| @options[:port] = port.to_i }
- opts.on("-A", "--adapter NAME", "Rack adapter to use (default: autodetect)",
- "(#{Rack::ADAPTERS.map{|(a,b)|a}.join(', ')})") { |name| @options[:adapter] = name }
- opts.on("-R", "--rackup FILE", "Load a Rack config file instead of " +
- "Rack adapter") { |file| @options[:rackup] = file }
- opts.on("-c", "--chdir DIR", "Change to dir before starting") { |dir| @options[:chdir] = File.expand_path(dir) }
- opts.on( "--stats PATH", "Mount the Stats adapter under PATH") { |path| @options[:stats] = path }
-
- opts.separator ""
- opts.separator "Adapter options:"
- opts.on("-e", "--environment ENV", "Framework environment " +
- "(default: #{@options[:environment]})") { |env| @options[:environment] = env }
- opts.on( "--prefix PATH", "Mount the app under PATH (start with /)") { |path| @options[:prefix] = path }
-
- opts.on("-l", "--log FILE", "File to redirect output " +
- "(default: #{@options[:log]})") { |file| @options[:log] = file }
- opts.on("-P", "--pid FILE", "File to store PID " +
- "(default: #{@options[:pid]})") { |file| @options[:pid] = file }
- opts.on("-C", "--config FILE", "Load options from config file") { |file| @options[:config] = file }
-
- opts.separator ""
- opts.separator "Common options:"
-
- opts.on_tail("-r", "--require FILE", "require the library") { |file| @options[:require] << file }
- opts.on_tail("-D", "--debug", "Set debbuging on") { @options[:debug] = true }
- opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)") { @options[:trace] = true }
- opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
- opts.on_tail('-v', '--version', "Show version") { puts Aspen::SERVER; exit }
- end
- end
-
- # Parse the options.
- def parse!
- parser.parse! @argv
- @command = @argv.shift
- @arguments = @argv
- end
-
-
- # Parse the current shell arguments and run the command.
- # Exits on error.
- def run!
- if self.class.commands.include?(@command)
- run_command
- elsif @command.nil?
- puts "Command required"
- puts @parser
- exit 1
- else
- abort "Unknown command: #{@command}. Use one of #{self.class.commands.join(', ')}"
- end
- end
-
- # Send the command to the server.
- def run_command
- load_options_from_config_file! unless CONFIGLESS_COMMANDS.include?(@command)
-
- ##############
- # Thin is shelling out sub-processes - this doesn't translate to JRuby, does it?
- ##############
- # PROGRAM_NAME is relative to the current directory, so make sure
- # we store and expand it before changing directory.
- # Command.script = File.expand_path($PROGRAM_NAME)
-
- # Change the current directory ASAP so that all relative paths are
- # relative to this one.
- Dir.chdir(@options[:chdir])
-
- @options[:require].each { |r| ruby_require r }
- Logging.debug = @options[:debug]
- Logging.trace = @options[:trace]
-
- controller = Controller.new(@options)
-
- if controller.respond_to?(@command)
- begin
- controller.send(@command, *@arguments)
- rescue RunnerError => e
- abort e.message
- end
- else
- abort "Invalid options for command: #{@command}"
- end
- end
-
- private
- def load_options_from_config_file!
- if file = @options.delete(:config)
- YAML.load_file(file).each { |key, value| @options[key.to_sym] = value }
- end
- end
-
- def ruby_require(file)
- if File.extname(file) == '.ru'
- warn 'WARNING: Use the -R option to load a Rack config file'
- @options[:rackup] = file
- else
- require file
- end
- end
+ #
+ # COMMANDS = %w(start stop config)
+ #
+ # # Commands that wont load options from the config file
+ # CONFIGLESS_COMMANDS = %w(config)
+ #
+ # # Parsed options
+ # attr_accessor :options
+ #
+ # # Name of the command to be runned.
+ # attr_accessor :command
+ #
+ # # Arguments to be passed to the command.
+ # attr_accessor :arguments
+ #
+ # # Return all available commands
+ # def self.commands
+ # COMMANDS
+ # end
+ #
+ # # create a new instance
+ # # @param [Array] command-line arguments
+ # def initialize(argv)
+ # @argv = argv
+ #
+ # # Default options values
+ # @options = {
+ # :chdir => Dir.pwd,
+ # :environment => 'development',
+ # :address => Aspen::Server::DEFAULT_HOST,
+ # :port => Aspen::Server::DEFAULT_PORT,
+ # :log => 'log/aspen.log',
+ # :pid => 'tmp/pids/aspen.pid',
+ # :require => []
+ # }
+ #
+ # parse!
+ # end
+ #
+ # # build up a parser in @parser
+ # # @return [OptionParser] the option handler
+ # def parser
+ # # NOTE: If you add an option here make sure the key in the +options+ hash is the
+ # # same as the name of the command line option.
+ # @parser ||= OptionParser.new do |opts|
+ # opts.banner = "Usage: aspen [options] #{self.class.commands.join('|')}"
+ #
+ # opts.separator ""
+ # opts.separator "Server options:"
+ #
+ # opts.on("-a", "--address HOST", "bind to HOST address " +
+ # "(default: #{@options[:address]})") { |host| @options[:address] = host }
+ # opts.on("-p", "--port PORT", "use PORT (default: #{@options[:port]})") { |port| @options[:port] = port.to_i }
+ # opts.on("-A", "--adapter NAME", "Rack adapter to use (default: autodetect)",
+ # "(#{Rack::ADAPTERS.map{|(a,b)|a}.join(', ')})") { |name| @options[:adapter] = name }
+ # opts.on("-R", "--rackup FILE", "Load a Rack config file instead of " +
+ # "Rack adapter") { |file| @options[:rackup] = file }
+ # opts.on("-c", "--chdir DIR", "Change to dir before starting") { |dir| @options[:chdir] = File.expand_path(dir) }
+ # opts.on( "--stats PATH", "Mount the Stats adapter under PATH") { |path| @options[:stats] = path }
+ #
+ # opts.separator ""
+ # opts.separator "Adapter options:"
+ # opts.on("-e", "--environment ENV", "Framework environment " +
+ # "(default: #{@options[:environment]})") { |env| @options[:environment] = env }
+ # opts.on( "--prefix PATH", "Mount the app under PATH (start with /)") { |path| @options[:prefix] = path }
+ #
+ # opts.on("-l", "--log FILE", "File to redirect output " +
+ # "(default: #{@options[:log]})") { |file| @options[:log] = file }
+ # opts.on("-P", "--pid FILE", "File to store PID " +
+ # "(default: #{@options[:pid]})") { |file| @options[:pid] = file }
+ # opts.on("-C", "--config FILE", "Load options from config file") { |file| @options[:config] = file }
+ #
+ # opts.separator ""
+ # opts.separator "Common options:"
+ #
+ # opts.on_tail("-r", "--require FILE", "require the library") { |file| @options[:require] << file }
+ # opts.on_tail("-D", "--debug", "Set debbuging on") { @options[:debug] = true }
+ # opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)") { @options[:trace] = true }
+ # opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
+ # opts.on_tail('-v', '--version', "Show version") { puts Aspen::SERVER; exit }
+ # end
+ # end
+ #
+ # # Parse the options.
+ # def parse!
+ # parser.parse! @argv
+ # @command = @argv.shift
+ # @arguments = @argv
+ # end
+ #
+ #
+ # # Parse the current shell arguments and run the command.
+ # # Exits on error.
+ # def run!
+ # if self.class.commands.include?(@command)
+ # run_command
+ # elsif @command.nil?
+ # puts "Command required"
+ # puts @parser
+ # exit 1
+ # else
+ # abort "Unknown command: #{@command}. Use one of #{self.class.commands.join(', ')}"
+ # end
+ # end
+ #
+ # # Send the command to the server.
+ # def run_command
+ # load_options_from_config_file! unless CONFIGLESS_COMMANDS.include?(@command)
+ #
+ # ##############
+ # # Thin is shelling out sub-processes - this doesn't translate to JRuby, does it?
+ # ##############
+ # # PROGRAM_NAME is relative to the current directory, so make sure
+ # # we store and expand it before changing directory.
+ # # Command.script = File.expand_path($PROGRAM_NAME)
+ #
+ # # Change the current directory ASAP so that all relative paths are
+ # # relative to this one.
+ # Dir.chdir(@options[:chdir])
+ #
+ # @options[:require].each { |r| ruby_require r }
+ # Logging.debug = @options[:debug]
+ # Logging.trace = @options[:trace]
+ #
+ # controller = Controller.new(@options)
+ #
+ # if controller.respond_to?(@command)
+ # begin
+ # controller.send(@command, *@arguments)
+ # rescue RunnerError => e
+ # abort e.message
+ # end
+ # else
+ # abort "Invalid options for command: #{@command}"
+ # end
+ # end
+ #
+ # private
+ # def load_options_from_config_file!
+ # if file = @options.delete(:config)
+ # YAML.load_file(file).each { |key, value| @options[key.to_sym] = value }
+ # end
+ # end
+ #
+ # def ruby_require(file)
+ # if File.extname(file) == '.ru'
+ # warn 'WARNING: Use the -R option to load a Rack config file'
+ # @options[:rackup] = file
+ # else
+ # require file
+ # end
+ # end
end
end
View
222 lib/aspen/server.rb
@@ -1,9 +1,9 @@
# require 'g'
-require File.dirname(__FILE__) + '/logging.rb'
-require 'java'
-require File.dirname(__FILE__) + '/aspenj.jar'
-import com.github.kevwil.aspen.AspenServer
-import com.github.kevwil.aspen.JRubyRackProxy
+# require File.dirname(__FILE__) + '/logging.rb'
+# require 'java'
+# require File.dirname(__FILE__) + '/aspenj.jar'
+# import com.github.kevwil.aspen.AspenServer
+# import com.github.kevwil.aspen.JRubyRackProxy
module Aspen
@@ -21,112 +21,112 @@ module Aspen
# @since 1.0.0
# @version 1.0.0
class Server
- include Logging
-
- # default values
- DEFAULT_HOST = '0.0.0.0'
- DEFAULT_PORT = 3000
-
- # Application (Rack adapter) called with the request that produces the response.
- attr_accessor :app
-
- # IP address of to bind sockets to, usually the address of the host,
- # the loopback address (127.0.0.1), or the 'all' binding address
- # of 0.0.0.0 (which is the default).
- attr_accessor :host
-
- # port number for the server to listen on
- attr_accessor :port
-
- def initialize(*args, &block)
- host, port, options = DEFAULT_HOST, DEFAULT_PORT, {}
- @app = nil
-
- # Guess each parameter by its type so they can be
- # received in any order
- args.each do |arg|
- case arg
- when Fixnum, /^\d+$/ then @port = arg.to_i
- when String then @host = arg
- when Hash then options = arg
- else
- @app = arg if arg.respond_to?(:call)
- end
- end
-
- # Allow using Rack builder as a block
- @app = Rack::Builder.new(&block).to_app if block
-
- # If in debug mode, wrap in logger adapter
- @app = Rack::CommonLogger.new(@app) if Logging.debug?
-
- @proxy = JRubyRackProxy.new(@app)
-
- @backend = AspenServer.new(@host,@port,@proxy)
- end
-
- def app=(newapp)
- @app = newapp
- @proxy = JRubyRackProxy.new(@app)
- @backend = AspenServer.new(@host,@port,@proxy)
- end
-
- # Lil' shortcut to turn this:
- #
- # Server.new(...).start
- #
- # into this:
- #
- # Server.start(...)
- #
- def self.start(*args, &block)
- new(*args, &block).start!
- end
-
- # Start the server and listen for connections.
- def start
- raise ArgumentError, 'app required' unless @app
-
- log ">> Aspen web server (#{::Aspen::SERVER})"
- debug ">> Debugging ON"
- trace ">> Tracing ON"
-
- log ">> Listening on #{@host}:#{@port}, CTRL+C to stop"
-
- @backend.start
- end
- alias :start! :start
-
- def running?
- return @backend.is_running
- end
-
- # == Gracefull shutdown
- # Stops the server after processing all current connections.
- # As soon as this method is called, the server stops accepting
- # new requests and wait for all current connections to finish.
- # Calling twice is the equivalent of calling <tt>stop!</tt>.
- def stop
- if running?
- @backend.stop
- unless @backend.empty?
- log ">> Waiting for #{@backend.size} connection(s) to finish, " +
- "can take up to #{timeout} sec, CTRL+C to stop now"
- end
- else
- stop!
- end
- end
-
- # == Force shutdown
- # Stops the server closing all current connections right away.
- # This doesn't wait for connection to finish their work and send data.
- # All current requests will be dropped.
- def stop!
- log ">> Stopping ..."
-
- @backend.stop!
- end
+ # include Logging
+ #
+ # # default values
+ # DEFAULT_HOST = '0.0.0.0'
+ # DEFAULT_PORT = 3000
+ #
+ # # Application (Rack adapter) called with the request that produces the response.
+ # attr_accessor :app
+ #
+ # # IP address of to bind sockets to, usually the address of the host,
+ # # the loopback address (127.0.0.1), or the 'all' binding address
+ # # of 0.0.0.0 (which is the default).
+ # attr_accessor :host
+ #
+ # # port number for the server to listen on
+ # attr_accessor :port
+ #
+ # def initialize(*args, &block)
+ # host, port, options = DEFAULT_HOST, DEFAULT_PORT, {}
+ # @app = nil
+ #
+ # # Guess each parameter by its type so they can be
+ # # received in any order
+ # args.each do |arg|
+ # case arg
+ # when Fixnum, /^\d+$/ then @port = arg.to_i
+ # when String then @host = arg
+ # when Hash then options = arg
+ # else
+ # @app = arg if arg.respond_to?(:call)
+ # end
+ # end
+ #
+ # # Allow using Rack builder as a block
+ # @app = Rack::Builder.new(&block).to_app if block
+ #
+ # # If in debug mode, wrap in logger adapter
+ # @app = Rack::CommonLogger.new(@app) if Logging.debug?
+ #
+ # @proxy = JRubyRackProxy.new(@app)
+ #
+ # @backend = AspenServer.new(@host,@port,@proxy)
+ # end
+ #
+ # def app=(newapp)
+ # @app = newapp
+ # @proxy = JRubyRackProxy.new(@app)
+ # @backend = AspenServer.new(@host,@port,@proxy)
+ # end
+ #
+ # # Lil' shortcut to turn this:
+ # #
+ # # Server.new(...).start
+ # #
+ # # into this:
+ # #
+ # # Server.start(...)
+ # #
+ # def self.start(*args, &block)
+ # new(*args, &block).start!
+ # end
+ #
+ # # Start the server and listen for connections.
+ # def start
+ # raise ArgumentError, 'app required' unless @app
+ #
+ # log ">> Aspen web server (#{::Aspen::SERVER})"
+ # debug ">> Debugging ON"
+ # trace ">> Tracing ON"
+ #
+ # log ">> Listening on #{@host}:#{@port}, CTRL+C to stop"
+ #
+ # @backend.start
+ # end
+ # alias :start! :start
+ #
+ # def running?
+ # return @backend.is_running
+ # end
+ #
+ # # == Gracefull shutdown
+ # # Stops the server after processing all current connections.
+ # # As soon as this method is called, the server stops accepting
+ # # new requests and wait for all current connections to finish.
+ # # Calling twice is the equivalent of calling <tt>stop!</tt>.
+ # def stop
+ # if running?
+ # @backend.stop
+ # unless @backend.empty?
+ # log ">> Waiting for #{@backend.size} connection(s) to finish, " +
+ # "can take up to #{timeout} sec, CTRL+C to stop now"
+ # end
+ # else
+ # stop!
+ # end
+ # end
+ #
+ # # == Force shutdown
+ # # Stops the server closing all current connections right away.
+ # # This doesn't wait for connection to finish their work and send data.
+ # # All current requests will be dropped.
+ # def stop!
+ # log ">> Stopping ..."
+ #
+ # @backend.stop!
+ # end
end
View
226 spec/runner_spec.rb
@@ -3,116 +3,116 @@
include Aspen
describe Runner, "with basic options" do
-
- before(:each) do
- Logging.silent=true
- end
-
- it "should parse options" do
- runner = Runner.new(%w(start --pid test.pid --port 5000))
-
- runner.should_not be_nil
- runner.options.should_not be_nil
- runner.options.kind_of?(Hash).should be_true
- runner.options[:pid].should eql('test.pid')
- runner.options[:port].should eql(5000)
- end
-
- it "should parse specified command" do
- Runner.new(%w(start)).command.should eql('start')
- Runner.new(%w(stop)).command.should eql('stop')
- Runner.new(%w(restart)).command.should eql('restart')
- end
-
- it "should abort on unknow command" do
- runner = Runner.new(%w(poop))
- runner.stubs(:abort)
-
- runner.expects(:abort)
-
- runner.run!
- end
-
- it "should exit on empty command" do
- runner = Runner.new([])
- runner.stubs(:exit)
-
- runner.expects(:exit).with(1)
-
- silence_stream(STDOUT) do
- runner.run!
- end
- end
-
- it "should warn when require a rack config file" do
- Runner.any_instance.expects(:warn).with(regexp_matches(/WARNING/))
-
- runner = Runner.new(%w(start -r config.ru))
- runner.run! rescue nil
-
- runner.options[:rackup].should eql('config.ru')
- end
-
- it "should require file" do
- runner = Runner.new(%w(start -r unexisting))
- proc { runner.run! }.should raise_error(LoadError)
- end
-
- it "should remember requires" do
- runner = Runner.new(%w(start -r rubygems -r aspen))
- runner.options[:require].should eql(%w(rubygems aspen))
- end
-
- it "should remember debug options" do
- runner = Runner.new(%w(start -D -V))
- runner.options[:debug].should be_true
- runner.options[:trace].should be_true
- end
-
- it "should default debug and trace to false" do
- runner = Runner.new(%w(start))
- runner.options[:debug].should_not be_true
- runner.options[:trace].should_not be_true
- end
- end
-
- describe Runner, 'with config file' do
- before(:each) do
- Logging.silent = true
- @runner = Runner.new(%w(start --config spec/configs/single.yml))
- end
-
- it "should load options from file with :config option" do
- @runner.send :load_options_from_config_file!
-
- @runner.options[:environment].should == 'production'
- @runner.options[:chdir].should == 'spec/rails_app'
- @runner.options[:port].should == 6000
- @runner.options[:pid].should == 'tmp/pids/aspen.pid'
- @runner.options[:log].should == 'log/aspen.log'
- @runner.options[:timeout].should == 60
- end
-
- it "should change directory after loading config" do
- @orig_dir = Dir.pwd
-
- controller = mock('controller')
- controller.expects(:respond_to?).with('start').returns(true)
- controller.expects(:start)
- Controller.expects(:new).returns(controller)
-
- expected_dir = File.expand_path('spec/rails_app')
-
- begin
- silence_stream(STDERR) do
- @runner.run!
- end
-
- Dir.pwd.should == expected_dir
-
- ensure
- # any other spec using relative paths should work as expected
- Dir.chdir(@orig_dir)
- end
- end
- end
+ #
+ # before(:each) do
+ # Logging.silent=true
+ # end
+ #
+ # it "should parse options" do
+ # runner = Runner.new(%w(start --pid test.pid --port 5000))
+ #
+ # runner.should_not be_nil
+ # runner.options.should_not be_nil
+ # runner.options.kind_of?(Hash).should be_true
+ # runner.options[:pid].should eql('test.pid')
+ # runner.options[:port].should eql(5000)
+ # end
+ #
+ # it "should parse specified command" do
+ # Runner.new(%w(start)).command.should eql('start')
+ # Runner.new(%w(stop)).command.should eql('stop')
+ # Runner.new(%w(restart)).command.should eql('restart')
+ # end
+ #
+ # it "should abort on unknow command" do
+ # runner = Runner.new(%w(poop))
+ # runner.stubs(:abort)
+ #
+ # runner.expects(:abort)
+ #
+ # runner.run!
+ # end
+ #
+ # it "should exit on empty command" do
+ # runner = Runner.new([])
+ # runner.stubs(:exit)
+ #
+ # runner.expects(:exit).with(1)
+ #
+ # silence_stream(STDOUT) do
+ # runner.run!
+ # end
+ # end
+ #
+ # it "should warn when require a rack config file" do
+ # Runner.any_instance.expects(:warn).with(regexp_matches(/WARNING/))
+ #
+ # runner = Runner.new(%w(start -r config.ru))
+ # runner.run! rescue nil
+ #
+ # runner.options[:rackup].should eql('config.ru')
+ # end
+ #
+ # it "should require file" do
+ # runner = Runner.new(%w(start -r unexisting))
+ # proc { runner.run! }.should raise_error(LoadError)
+ # end
+ #
+ # it "should remember requires" do
+ # runner = Runner.new(%w(start -r rubygems -r aspen))
+ # runner.options[:require].should eql(%w(rubygems aspen))
+ # end
+ #
+ # it "should remember debug options" do
+ # runner = Runner.new(%w(start -D -V))
+ # runner.options[:debug].should be_true
+ # runner.options[:trace].should be_true
+ # end
+ #
+ # it "should default debug and trace to false" do
+ # runner = Runner.new(%w(start))
+ # runner.options[:debug].should_not be_true
+ # runner.options[:trace].should_not be_true
+ # end
+end
+
+describe Runner, 'with config file' do
+ # before(:each) do
+ # Logging.silent = true
+ # @runner = Runner.new(%w(start --config spec/configs/single.yml))
+ # end
+ #
+ # it "should load options from file with :config option" do
+ # @runner.send :load_options_from_config_file!
+ #
+ # @runner.options[:environment].should == 'production'
+ # @runner.options[:chdir].should == 'spec/rails_app'
+ # @runner.options[:port].should == 6000
+ # @runner.options[:pid].should == 'tmp/pids/aspen.pid'
+ # @runner.options[:log].should == 'log/aspen.log'
+ # @runner.options[:timeout].should == 60
+ # end
+ #
+ # it "should change directory after loading config" do
+ # @orig_dir = Dir.pwd
+ #
+ # controller = mock('controller')
+ # controller.expects(:respond_to?).with('start').returns(true)
+ # controller.expects(:start)
+ # Controller.expects(:new).returns(controller)
+ #
+ # expected_dir = File.expand_path('spec/rails_app')
+ #
+ # begin
+ # silence_stream(STDERR) do
+ # @runner.run!
+ # end
+ #
+ # Dir.pwd.should == expected_dir
+ #
+ # ensure
+ # # any other spec using relative paths should work as expected
+ # Dir.chdir(@orig_dir)
+ # end
+ # end
+end
View
54 spec/server_spec.rb
@@ -4,33 +4,33 @@
describe Server, "with a basic lambda app" do
- it "should create instance with parameters" do
- host = '127.0.0.1'
- port = 8080
- app = lambda { |env| [200, {}, ['hello']] }
- s = Server.new(host, port, app)
- s.should_not be_nil
- s.host.should_not be_nil
- s.host.should eql(host)
- s.port.should_not be_nil
- s.port.should eql(port)
- s.app.should_not be_nil
- # proc can't be compared?
- # s.app.should eql(app)
- s.running?.should be_false
- end
-
- it "should have a start method" do
- Server.instance_method("start").should_not be_nil
- end
-
- it "should have a stop method" do
- Server.instance_method("stop").should_not be_nil
- end
-
- it "should have a running? method" do
- Server.instance_method("running?").should_not be_nil
- end
+ # it "should create instance with parameters" do
+ # host = '127.0.0.1'
+ # port = 8080
+ # app = lambda { |env| [200, {}, ['hello']] }
+ # s = Server.new(host, port, app)
+ # s.should_not be_nil
+ # s.host.should_not be_nil
+ # s.host.should eql(host)
+ # s.port.should_not be_nil
+ # s.port.should eql(port)
+ # s.app.should_not be_nil
+ # # proc can't be compared?
+ # # s.app.should eql(app)
+ # s.running?.should be_false
+ # end
+ #
+ # it "should have a start method" do
+ # Server.instance_method("start").should_not be_nil
+ # end
+ #
+ # it "should have a stop method" do
+ # Server.instance_method("stop").should_not be_nil
+ # end
+ #
+ # it "should have a running? method" do
+ # Server.instance_method("running?").should_not be_nil
+ # end
end
View
4 spec/spec_helper.rb
@@ -5,9 +5,9 @@
require 'net/http'
require 'rack/lint'
require 'aspen'
-require 'spec'
+require 'rspec'
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
config.mock_with :mocha
end

0 comments on commit 4c25c1d

Please sign in to comment.