lib/kicker/recipes/rails.rb in kicker-2.3.1 vs lib/kicker/recipes/rails.rb in kicker-2.4.0
- old
+ new
@@ -1,24 +1,12 @@
-# Need to define these modules and require core_ext/module, because AS breaks
-# if these aren't defined. Need to fix that in AS...
-require 'active_support/core_ext/module'
-module ActiveSupport #:nodoc:
- module CoreExtensions #:nodoc:
- module String #:nodoc:
- module Inflections #:nodoc:
- end
- end
- end
-end
+recipe :ruby
-require 'ruby'
-
-class Rails < Ruby
+class Kicker::Recipes::Rails < Kicker::Recipes::Ruby
class << self
# Call these options on the Ruby class which takes the cli options.
%w{ test_type runner_bin test_cases_root test_options }.each do |delegate|
- define_method(delegate) { Ruby.send(delegate) }
+ define_method(delegate) { Kicker::Recipes::Ruby.send(delegate) }
end
# Maps +type+, for instance `models', to a test directory.
def type_to_test_dir(type)
if test_type == 'test'
@@ -58,29 +46,29 @@
# Returns an array of all tests related to the given model.
def tests_for_model(model)
if test_type == 'test'
%W{
- unit/#{model.singularize}
- unit/helpers/#{model.pluralize}_helper
- functional/#{model.pluralize}_controller
+ unit/#{ActiveSupport::Inflector.singularize(model)}
+ unit/helpers/#{ActiveSupport::Inflector.pluralize(model)}_helper
+ functional/#{ActiveSupport::Inflector.pluralize(model)}_controller
}
else
%W{
- models/#{model.singularize}
- helpers/#{model.pluralize}_helper
- controllers/#{model.pluralize}_controller
+ models/#{ActiveSupport::Inflector.singularize(model)}
+ helpers/#{ActiveSupport::Inflector.pluralize(model)}_helper
+ controllers/#{ActiveSupport::Inflector.pluralize(model)}_controller
}
end.map { |f| test_file f }
end
def handle!
@tests.concat(@files.take_and_map do |file|
case file
# Run all functional tests when routes.rb is saved
when 'config/routes.rb'
- Rails.all_controller_tests
+ Kicker::Recipes::Rails.all_controller_tests
# Match lib/*
when /^(lib\/.+)\.rb$/
test_file($1)
@@ -90,11 +78,11 @@
# Match any file in app/ and map it to a test file
when %r{^app/(\w+)([\w/]*)/([\w\.]+)\.\w+$}
type, namespace, file = $1, $2, $3
- if dir = Rails.type_to_test_dir(type)
+ if dir = Kicker::Recipes::Rails.type_to_test_dir(type)
if type == "views"
namespace = namespace.split('/')[1..-1]
file = "#{namespace.pop}_controller"
end
@@ -108,12 +96,12 @@
end
end
recipe :rails do
require 'rubygems' rescue LoadError
- require 'active_support/core_ext/string'
+ require 'active_support/inflector'
- process Rails
+ process Kicker::Recipes::Rails
# When changing the schema, prepare the test database.
process do |files|
execute 'rake db:test:prepare' if files.delete('db/schema.rb')
end
\ No newline at end of file