Skip to content

Instantly share code, notes, and snippets.

@nathanclark
Forked from whatcould/.autotest
Created February 2, 2010 20:46

Revisions

  1. @whatcould whatcould revised this gist Feb 11, 2009. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .autotest
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # autotest your engine plugins together with your rails app
    # put this .autotest file in
    # put this .autotest file in your rails root
    # see http://code.whatcould.com/2009/02/09/gentlemen-test-your-engines.html for details

    # until/unless my changes are pulled into the main streams,
    # there are a couple requirements:
  2. @whatcould whatcould revised this gist Feb 11, 2009. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions .autotest
    Original file line number Diff line number Diff line change
    @@ -9,10 +9,7 @@
    Autotest.add_hook :initialize do |at|

    # find all your plugins with an app directory
    engine_plugins = []
    Dir.glob('vendor/plugins/*').each do |dir|
    engine_plugins << dir if File.directory?("#{dir}/app")
    end
    engine_plugins = Dir['vendor/plugins/*'].select{|dir| File.directory?("#{dir}/app")}

    # this big requires my autotest fork
    at.extra_test_paths = engine_plugins.map{|p| p + '/test'}
  3. @whatcould whatcould revised this gist Feb 10, 2009. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions .autotest
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    # autotest your engine plugins
    # at this point, requires my autotest fork, http://github.com/whatcould/zentest/tree/master
    # autotest your engine plugins together with your rails app
    # put this .autotest file in

    # until/unless my changes are pulled into the main streams,
    # there are a couple requirements:
    # my autotest fork, http://github.com/whatcould/zentest/tree/master
    # and for better fixture handling, my engines fork, http://github.com/whatcould/engines/tree/master

    Autotest.add_hook :initialize do |at|

    @@ -78,6 +83,4 @@ Autotest.add_hook :initialize do |at|
    end
    end



    end
    end
  4. @whatcould whatcould revised this gist Feb 10, 2009. 1 changed file with 19 additions and 10 deletions.
    29 changes: 19 additions & 10 deletions .autotest
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,9 @@
    # autotest your engine plugins together with your rails app
    # put this .autotest file in

    # until/unless my changes are pulled into the main streams,
    # there are a couple requirements:
    # my autotest fork, http://github.com/whatcould/zentest/tree/master
    # and for better fixture handling, my engines fork, http://github.com/whatcould/engines/tree/master
    # autotest your engine plugins
    # at this point, requires my autotest fork, http://github.com/whatcould/zentest/tree/master

    Autotest.add_hook :initialize do |at|

    # all your plugins with an app directory

    # find all your plugins with an app directory
    engine_plugins = []
    Dir.glob('vendor/plugins/*').each do |dir|
    engine_plugins << dir if File.directory?("#{dir}/app")
    @@ -68,7 +62,22 @@ Autotest.add_hook :initialize do |at|

    end

    # keeps your fixtures updated in the shared tmp dir.
    # see rake test:plugins:setup_plugin_fixtures
    # if you specify your temporary_fixtures_directory for some reason,
    # you should change tmp_dir below

    Autotest.add_hook :updated do |at,*args|
    filenames = args.collect{|arr|arr.first.first}.uniq
    filenames.each do |filename|
    if filename =~ /.(yml|csv)$/
    require 'tempfile'
    tmp_dir = FileUtils.mkdir_p(File.join(Dir.tmpdir, "rails_fixtures"))
    FileUtils.copy(filename,tmp_dir)
    end
    end
    end


    end

    end
  5. @whatcould whatcould revised this gist Feb 10, 2009. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions .autotest
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    # autotest your engine plugins
    # at this point, requires my autotest fork, http://github.com/whatcould/zentest/tree/master
    # autotest your engine plugins together with your rails app
    # put this .autotest file in

    # until/unless my changes are pulled into the main streams,
    # there are a couple requirements:
    # my autotest fork, http://github.com/whatcould/zentest/tree/master
    # and for better fixture handling, my engines fork, http://github.com/whatcould/engines/tree/master

    Autotest.add_hook :initialize do |at|

  6. @whatcould whatcould created this gist Feb 9, 2009.
    69 changes: 69 additions & 0 deletions .autotest
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    # autotest your engine plugins
    # at this point, requires my autotest fork, http://github.com/whatcould/zentest/tree/master

    Autotest.add_hook :initialize do |at|

    # all your plugins with an app directory

    engine_plugins = []
    Dir.glob('vendor/plugins/*').each do |dir|
    engine_plugins << dir if File.directory?("#{dir}/app")
    end

    # this big requires my autotest fork
    at.extra_test_paths = engine_plugins.map{|p| p + '/test'}

    # autotest comes with an exception for your vendor; have to get rid of that
    at.remove_exception(%r%^\./(?:db|doc|log|public|script|tmp|vendor)%)
    at.add_exception %r%^\./(?:db|doc|log|public|script|tmp)%
    at.add_exception(/^\.\/vendor\/rails/)
    at.add_exception(/^\.\/vendor\/gems/)

    # exceptions for all your non-engine plugins
    plugin_names = engine_plugins.map{|p| p.sub('vendor/plugins/','')}
    at.add_exception(%r%vendor/plugins/(?!#{plugin_names.join('|')})%)

    engine_plugins.each do |plugin_path|

    at.add_exception("#{plugin_path}/db")

    # these mirror the mappings in the autotest rails profile
    #
    # TODO: these don't account for overriding methods, views, etc in your app
    # eg, a change in your main app/ doesn't run the corresponding test in the plugin/app

    at.add_mapping %r%^#{plugin_path}/app/models/(.*)\.rb$% do |_, m|
    "#{plugin_path}/test/unit/#{m[1]}_test.rb"
    end

    at.add_mapping %r%^#{plugin_path}/app/controllers/(.*)\.rb$% do |_, m|
    ["#{plugin_path}/test/controllers/#{m[1]}_test.rb",
    "#{plugin_path}/test/functional/#{m[1]}_test.rb"]
    end

    at.add_mapping %r%^#{plugin_path}/app/helpers/(.*)_helper.rb% do |_, m|
    ["#{plugin_path}/test/views/#{m[1]}_view_test.rb",
    "#{plugin_path}/test/functional/#{m[1]}_controller_test.rb"]
    end

    at.add_mapping %r%^#{plugin_path}/app/views/(.*)/% do |_, m|
    ["#{plugin_path}/test/views/#{m[1]}_view_test.rb",
    "#{plugin_path}/test/functional/#{m[1]}_controller_test.rb"]
    end

    # changes in routes test your app functional tests as well

    at.add_mapping %r%^#{plugin_path}/config/routes.rb$% do
    at.files_matching %r%^(#{plugin_path}/)?test/(controllers|views|functional)/.*_test\.rb$%
    end

    at.add_mapping %r%^#{plugin_path}/test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
    filename
    end

    end



    end