lib/spring/commands.rb in spring-0.0.8 vs lib/spring/commands.rb in spring-0.0.9
- old
+ new
@@ -1,5 +1,7 @@
+require "spring/watcher"
+
# If the config/spring.rb contains requires for commands from other gems,
# then we need to be under bundler.
require "bundler/setup"
module Spring
@@ -69,21 +71,22 @@
$LOAD_PATH.unshift "test"
super
end
def call(args)
- if args.size > 0
- ARGV.replace args
- path = File.expand_path(args.first)
+ if args.empty?
+ args = ['test']
+ end
+ ARGV.replace args
+ args.each do |arg|
+ path = File.expand_path(arg)
if File.directory?(path)
Dir[File.join path, "**", "*_test.rb"].each { |f| require f }
else
require path
end
- else
- $stderr.puts "you need to specify what test to run: spring test TEST_NAME"
end
end
def description
"Execute a Test::Unit test."
@@ -105,11 +108,11 @@
super
end
def call(args)
$0 = "rspec"
- ::RSpec::Core::Runner.run(args)
+ Kernel.exit ::RSpec::Core::Runner.run(args)
end
def description
"Execute an RSpec spec."
end
@@ -125,20 +128,37 @@
super
require 'cucumber'
end
def call(args)
- ::Cucumber::Cli::Main.execute(args)
+ # Cucumber's execute funtion returns `true` if any of the steps failed or
+ # some other error occured.
+ Kernel.exit(1) if ::Cucumber::Cli::Main.execute(args)
end
def description
"Execute a Cucumber feature."
end
end
Spring.register_command "cucumber", Cucumber.new
class Rake < Command
+ class << self
+ attr_accessor :environment_matchers
+ end
+
+ self.environment_matchers = {
+ /^(test|spec|cucumber)($|:)/ => "test"
+ }
+
+ def env(args)
+ self.class.environment_matchers.each do |matcher, environment|
+ return environment if matcher === args.first
+ end
+ nil
+ end
+
def setup
super
require "rake"
end
@@ -152,11 +172,11 @@
end
end
Spring.register_command "rake", Rake.new
class RailsConsole < Command
- def env(tail)
- tail.first if tail.first && !tail.first.index("-")
+ def env(args)
+ args.first if args.first && !args.first.index("-")
end
def setup
require "rails/commands/console"
end