Permalink
Browse files

Split from ZenTest

[git-p4: depot-paths = "//src/autotest-rails/dev/": change = 4995]
  • Loading branch information...
zenspider committed Jun 2, 2009
0 parents commit b17bb5143a29ed7410297a388a4b8af3f68b4aab
Showing with 204 additions and 0 deletions.
  1. +23 −0 .autotest
  2. +5 −0 History.txt
  3. +9 −0 Manifest.txt
  4. +48 −0 README.txt
  5. +12 −0 Rakefile
  6. +6 −0 lib/autotest/discover.rb
  7. +12 −0 lib/autotest/fixtures.rb
  8. +7 −0 lib/autotest/migrate.rb
  9. +82 −0 lib/autotest/rails.rb
@@ -0,0 +1,23 @@
+# -*- ruby -*-
+
+require 'autotest/restart'
+
+# Autotest.add_hook :initialize do |at|
+# at.extra_files << "../some/external/dependency.rb"
+#
+# at.libs << ":../some/external"
+#
+# at.add_exception 'vendor'
+#
+# at.add_mapping(/dependency.rb/) do |f, _|
+# at.files_matching(/test_.*rb$/)
+# end
+#
+# %w(TestA TestB).each do |klass|
+# at.extra_class_map[klass] = "test/test_misc.rb"
+# end
+# end
+
+# Autotest.add_hook :run_command do |at|
+# system "rake build"
+# end
@@ -0,0 +1,5 @@
+=== 4.0.0 / 2009-06-02
+
+* 1 major enhancement
+
+ * Birthday! well... split from ZenTest
@@ -0,0 +1,9 @@
+.autotest
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+lib/autotest/discover.rb
+lib/autotest/fixtures.rb
+lib/autotest/migrate.rb
+lib/autotest/rails.rb
@@ -0,0 +1,48 @@
+= autotest_rails
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 Ryan Davis, seattle.rb
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+
+Hoe.spec 'autotest-rails' do
+ developer('Ryan Davis', 'ryand-ruby@zenspider.com')
+
+ self.rubyforge_name = 'seattlerb'
+end
+
+# vim: syntax=ruby
@@ -0,0 +1,6 @@
+Autotest.add_discovery do
+ style = []
+ style << "rails" if File.exist? 'config/environment.rb'
+ style << "camping" if File.exist? 'test/camping_test_case.rb'
+ style
+end
@@ -0,0 +1,12 @@
+# -*- ruby -*-
+
+# This is an example of how to change the mappings of file that
+# changed to tests to run for a project.
+
+module Autotest::Fixtures
+ Autotest.add_hook :initialize do |at|
+ at.test_mappings['^test/fixtures/(.*)s.yml'] = proc { |filename, matches|
+ at.files_matching(/test\/\w+\/#{matches[1]}(_\w+)?.*_test.rb$/)
+ }
+ end
+end
@@ -0,0 +1,7 @@
+# -*- ruby -*-
+
+module Autotest::Migrate
+ Autotest.add_hook(:run) do |autotest|
+ system "rake db:migrate" if autotest.class.to_s == "RailsAutotest"
+ end
+end
@@ -0,0 +1,82 @@
+require 'autotest'
+
+class Autotest::Rails < Autotest
+ VERSION = '4.0.0'
+
+ def initialize # :nodoc:
+ super
+
+ add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%
+
+ clear_mappings
+
+ self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
+ impl = File.basename(filename, '.rb')
+ files_matching %r%^test/unit/#{impl}_test.rb$%
+ # TODO: (unit|functional|integration) maybe?
+ end
+
+ add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
+ ["test/unit/#{m[1]}_test.rb",
+ "test/controllers/#{m[1]}_controller_test.rb",
+ "test/views/#{m[1]}_view_test.rb",
+ "test/functional/#{m[1]}_controller_test.rb"]
+ end
+
+ add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
+ filename
+ end
+
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
+ "test/unit/#{m[1]}_test.rb"
+ end
+
+ add_mapping %r%^app/helpers/application_helper.rb% do
+ files_matching %r%^test/(views|functional)/.*_test\.rb$%
+ end
+
+ add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
+ if m[1] == "application" then
+ files_matching %r%^test/(views|functional)/.*_test\.rb$%
+ else
+ ["test/views/#{m[1]}_view_test.rb",
+ "test/functional/#{m[1]}_controller_test.rb"]
+ end
+ end
+
+ add_mapping %r%^app/views/(.*)/% do |_, m|
+ ["test/views/#{m[1]}_view_test.rb",
+ "test/functional/#{m[1]}_controller_test.rb"]
+ end
+
+ add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
+ if m[1] == "application" then
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
+ else
+ ["test/controllers/#{m[1]}_test.rb",
+ "test/functional/#{m[1]}_test.rb"]
+ end
+ end
+
+ add_mapping %r%^app/views/layouts/% do
+ "test/views/layouts_view_test.rb"
+ end
+
+ add_mapping %r%^config/routes.rb$% do # FIX:
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
+ end
+
+ add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
+ files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
+ end
+ end
+
+ # Convert the pathname s to the name of class.
+ def path_to_classname(s)
+ sep = File::SEPARATOR
+ f = s.sub(/^test#{sep}((unit|functional|integration|views|controllers|helpers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
+ f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
+ f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
+ f.join('::')
+ end
+end

0 comments on commit b17bb51

Please sign in to comment.