Permalink
Browse files

Add initial support for Autotest

Support for autotest should be discoverable by itself.
It should get picked up by the .autotest file automatically.
  • Loading branch information...
1 parent c0c3372 commit 38d47d2ad719f281a305140176c4e9247b9e4e5c @blowmage committed Sep 18, 2012
Showing with 88 additions and 5 deletions.
  1. +5 −1 Manifest.txt
  2. +5 −0 lib/autotest/discover.rb
  3. +7 −0 lib/autotest/fixtures.rb
  4. +5 −0 lib/autotest/migrate.rb
  5. +62 −0 lib/autotest/minitest_rails.rb
  6. +4 −4 minitest-rails.gemspec
View
6 Manifest.txt
@@ -13,6 +13,10 @@ gemfiles/3.1.gemfile.lock
gemfiles/3.2.gemfile
gemfiles/3.2.gemfile.lock
gemfiles/minitest_tu_shim.rb
+lib/autotest/discover.rb
+lib/autotest/fixtures.rb
+lib/autotest/migrate.rb
+lib/autotest/minitest_rails.rb
lib/generators/mini_test.rb
lib/generators/mini_test/controller/controller_generator.rb
lib/generators/mini_test/controller/templates/controller_spec.rb
@@ -59,4 +63,4 @@ test/rails/action_controller/test_spec_type.rb
test/rails/test_action_dispatch_spec_type.rb
test/rails/test_action_mailer_spec_type.rb
test/rails/test_action_view_spec_type.rb
-test/test_minitest.rb
+test/test_sanity.rb
View
5 lib/autotest/discover.rb
@@ -0,0 +1,5 @@
+Autotest.add_discovery do
+ style = []
+ style = ["minitest", "rails"] if File.exist? 'config/application.rb'
+ style
+end
View
7 lib/autotest/fixtures.rb
@@ -0,0 +1,7 @@
+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
View
5 lib/autotest/migrate.rb
@@ -0,0 +1,5 @@
+module Autotest::Migrate
+ Autotest.add_hook(:run) do |autotest|
+ system "rake db:migrate" if autotest.class.to_s == "MinitestRails"
+ end
+end
View
62 lib/autotest/minitest_rails.rb
@@ -0,0 +1,62 @@
+require 'autotest'
+
+class Autotest::MinitestRails < Autotest
+ VERSION = "0.1.3"
+
+ def initialize # :nodoc:
+ super
+
+ add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%
+
+ clear_mappings
+
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
+ files_matching %r%^test/models/#{m[1]}.*_test.rb$%
+ end
+
+ add_mapping %r%^app/controllers/(.*)_controller\.rb$% do |_, m|
+ if m[1] == "application" then
+ files_matching %r%^test/(controllers|views)/.*_test\.rb$%
+ else
+ files_matching %r%^test/(controllers|views)/#{m[1]}.*_test.rb$%
+ end
+ end
+
+ add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
+ if m[1] == "application" then
+ files_matching %r%^test/(helpers|views|controllers)/.*_test\.rb$%
+ else
+ files_matching %r%^test/(helpers|views|controllers)/#{m[1]}.*_test.rb$%
+ end
+ end
+
+ add_mapping %r%^app/views/(.*)/% do |_, m|
+ files_matching %r%^test/(controllers|views)/#{m[1]}.*_test.rb$%
+ end
+
+ add_mapping %r%^app/mailers/(.*)\.rb$% do |_, m|
+ files_matching %r%^test/mailers/#{m[1]}.*_test.rb$%
+ end
+
+
+ add_mapping %r%^app/lib/(.*)\.rb$% do |_, m|
+ files_matching %r%^test/lib/#{m[1]}.*_test.rb$%
+ end
+
+ add_mapping %r%^test/.*_test\.rb$% do |filename, _|
+ filename
+ end
+
+ add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
+ files_matching %r%^test/(models|controllers|views)/#{m[1]}.*_test.rb$%
+ end
+
+ add_mapping %r%^config/routes.rb$% do # FIX:
+ files_matching %r%^test/(controllers|views|acceptance)/.*_test\.rb$%
+ end
+
+ add_mapping %r%^test/*_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
+ files_matching %r%^test/(models|controllers|views|lib|acceptance)/.*_test\.rb$%
+ end
+ end
+end
View
8 minitest-rails.gemspec
@@ -2,22 +2,22 @@
Gem::Specification.new do |s|
s.name = "minitest-rails"
- s.version = "0.1.3.20120802091804"
+ s.version = "0.1.3.20120918135148"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Mike Moore"]
- s.date = "2012-08-02"
+ s.date = "2012-09-18"
s.description = "Adds MiniTest as the default testing library in Rails 3.x"
s.email = ["mike@blowmage.com"]
s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"]
- s.files = [".autotest", ".gemtest", ".travis.yml", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "gemfiles/3.0.gemfile", "gemfiles/3.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "gemfiles/minitest_tu_shim.rb", "lib/generators/mini_test.rb", "lib/generators/mini_test/controller/controller_generator.rb", "lib/generators/mini_test/controller/templates/controller_spec.rb", "lib/generators/mini_test/controller/templates/controller_test.rb", "lib/generators/mini_test/helper/helper_generator.rb", "lib/generators/mini_test/helper/templates/helper_spec.rb", "lib/generators/mini_test/helper/templates/helper_test.rb", "lib/generators/mini_test/install/install_generator.rb", "lib/generators/mini_test/install/templates/test/minitest_helper.rb", "lib/generators/mini_test/integration/integration_generator.rb", "lib/generators/mini_test/integration/templates/integration_spec.rb", "lib/generators/mini_test/integration/templates/integration_test.rb", "lib/generators/mini_test/mailer/mailer_generator.rb", "lib/generators/mini_test/mailer/templates/mailer_spec.rb", "lib/generators/mini_test/mailer/templates/mailer_test.rb", "lib/generators/mini_test/model/model_generator.rb", "lib/generators/mini_test/model/templates/fixtures.yml", "lib/generators/mini_test/model/templates/model_spec.rb", "lib/generators/mini_test/model/templates/model_test.rb", "lib/generators/mini_test/scaffold/scaffold_generator.rb", "lib/generators/mini_test/scaffold/templates/controller_spec.rb", "lib/generators/mini_test/scaffold/templates/controller_test.rb", "lib/minitest-rails.rb", "lib/minitest/rails.rb", "lib/minitest/rails/action_controller.rb", "lib/minitest/rails/action_dispatch.rb", "lib/minitest/rails/action_mailer.rb", "lib/minitest/rails/action_view.rb", "lib/minitest/rails/active_support.rb", "lib/minitest/rails/declarative.rb", "lib/minitest/rails/mochaing.rb", "lib/minitest/rails/tasks/minitest.rake", "lib/minitest/rails/tasks/sub_test_task.rb", "minitest-rails.gemspec", "test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_controller_lookup.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/test_action_dispatch_spec_type.rb", "test/rails/test_action_mailer_spec_type.rb", "test/rails/test_action_view_spec_type.rb", "test/test_minitest.rb"]
+ s.files = [".autotest", ".gemtest", ".travis.yml", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "gemfiles/3.0.gemfile", "gemfiles/3.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "gemfiles/minitest_tu_shim.rb", "lib/autotest/discover.rb", "lib/autotest/fixtures.rb", "lib/autotest/migrate.rb", "lib/autotest/minitest_rails.rb", "lib/generators/mini_test.rb", "lib/generators/mini_test/controller/controller_generator.rb", "lib/generators/mini_test/controller/templates/controller_spec.rb", "lib/generators/mini_test/controller/templates/controller_test.rb", "lib/generators/mini_test/helper/helper_generator.rb", "lib/generators/mini_test/helper/templates/helper_spec.rb", "lib/generators/mini_test/helper/templates/helper_test.rb", "lib/generators/mini_test/install/install_generator.rb", "lib/generators/mini_test/install/templates/test/minitest_helper.rb", "lib/generators/mini_test/integration/integration_generator.rb", "lib/generators/mini_test/integration/templates/integration_spec.rb", "lib/generators/mini_test/integration/templates/integration_test.rb", "lib/generators/mini_test/mailer/mailer_generator.rb", "lib/generators/mini_test/mailer/templates/mailer_spec.rb", "lib/generators/mini_test/mailer/templates/mailer_test.rb", "lib/generators/mini_test/model/model_generator.rb", "lib/generators/mini_test/model/templates/fixtures.yml", "lib/generators/mini_test/model/templates/model_spec.rb", "lib/generators/mini_test/model/templates/model_test.rb", "lib/generators/mini_test/scaffold/scaffold_generator.rb", "lib/generators/mini_test/scaffold/templates/controller_spec.rb", "lib/generators/mini_test/scaffold/templates/controller_test.rb", "lib/minitest-rails.rb", "lib/minitest/rails.rb", "lib/minitest/rails/action_controller.rb", "lib/minitest/rails/action_dispatch.rb", "lib/minitest/rails/action_mailer.rb", "lib/minitest/rails/action_view.rb", "lib/minitest/rails/active_support.rb", "lib/minitest/rails/declarative.rb", "lib/minitest/rails/mochaing.rb", "lib/minitest/rails/tasks/minitest.rake", "lib/minitest/rails/tasks/sub_test_task.rb", "minitest-rails.gemspec", "test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_controller_lookup.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/test_action_dispatch_spec_type.rb", "test/rails/test_action_mailer_spec_type.rb", "test/rails/test_action_view_spec_type.rb", "test/test_sanity.rb"]
s.homepage = "http://blowmage.com/minitest-rails"
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = "minitest-rails"
s.rubygems_version = "1.8.24"
s.summary = "MiniTest integration for Rails 3.x"
- s.test_files = ["test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_controller_lookup.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/test_action_dispatch_spec_type.rb", "test/rails/test_action_mailer_spec_type.rb", "test/rails/test_action_view_spec_type.rb", "test/test_minitest.rb"]
+ s.test_files = ["test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_controller_lookup.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/test_action_dispatch_spec_type.rb", "test/rails/test_action_mailer_spec_type.rb", "test/rails/test_action_view_spec_type.rb", "test/test_sanity.rb"]
if s.respond_to? :specification_version then
s.specification_version = 3

0 comments on commit 38d47d2

Please sign in to comment.