Sha256: 62301b1c35e048d127bc8bfb0c6979e5b3d7826cf464e58a6b0ab3514d5dc044

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# Generates the test structure for a plugin with no dependencies on the
# plugin_test_helper library
class PluginTestStructureGenerator < Rails::Generator::NamedBase
  def manifest #:nodoc:
    record do |m|
      # Paths are relative to our template dir
      plugin_test_root = "vendor/plugins/#{name}/test"
      templates_root = "#{File.dirname(__FILE__)}/templates"
      
      # Root test directory
      m.directory plugin_test_root
      
      # Copy all directories and files.  None of them are templated so that they
      # can be reused during runtime
      Dir["#{templates_root}/**/*"].each do |source_file|
        relative_source_file = source_file.sub(templates_root, '')
        target_file = File.join(plugin_test_root, relative_source_file)
        
        if File.directory?(source_file)
          m.directory target_file
        else
          m.file relative_source_file, target_file
        end
      end
    end
  end

  protected
    def banner
      "Usage: #{$0} plugin_test_structure your_plugin"
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plugin_test_helper-0.2.1 generators/plugin_test_structure/plugin_test_structure_generator.rb
plugin_test_helper-0.2.0 generators/plugin_test_structure/plugin_test_structure_generator.rb
plugin_test_helper-0.1.6 generators/plugin_test_structure/plugin_test_structure_generator.rb