Class Webgen::PluginTestCase
In: lib/webgen/test.rb
Parent: TestCase
RuntimeError PluginParamNotFound PluginNotFound ConfigurationFileInvalid CmdParse::CommandParser CommandParser Test::Unit::TestCase TestCase PluginTestCase DirectoryInfo GalleryStyle WebSiteStyle WebSiteTemplate SipttraStyle TagTestCase CmdParse::Command ShowCommand CheckCommand UseCommand CreateCommand TSort DependencyHash Hash Comparable Language ::Logger Logger Logger DEFAULT_WRAPPER_MODULE WebSite Qt::MainWindow MainWindow Qt::Dialog NewWebsiteDialog Qt::TextEdit LogWidget ::Rake::TaskLib WebgenTask ConfigurationFile Website PluginManager PluginLoader PluginParamValueNotFound Dummy Color CliUtils PluginDefs lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/gui/common.rb lib/webgen/plugin.rb lib/webgen/test.rb lib/webgen/cli.rb ClassMethods PluginDefs LanguageManager lib/webgen/gui/new_website_dlg.rb lib/webgen/gui/main.rb GUI lib/webgen/rake/webgentask.rb Rake Webgen dot/m_60_1.png

Base class for all plugin test cases. It ensures that all needed plugins are loaded and initalized before each test and that the original environment is restored afterwards.

Methods

Public Class methods

Specifies files as the plugin files which define the plugin which should be tested and its dependencies.

[Source]

    # File lib/webgen/test.rb, line 78
78:       def plugin_files( files = nil )
79:         (files.nil? ? @plugin_files.to_a + ['webgen/plugins/coreplugins/configuration.rb'] : @plugin_files = files )
80:       end

The name of the plugin which should be tested.

[Source]

    # File lib/webgen/test.rb, line 83
83:       def plugin_to_test( plugin = nil )
84:         @plugin_name ||= nil
85:         (plugin.nil? ? @plugin_name : @plugin_name = plugin )
86:       end

[Source]

     # File lib/webgen/test.rb, line 128
128:     def self.sample_site( filename = '' )
129:       path_helper( :@base_fixture_path, File.join( 'sample_site', filename ) )
130:     end

[Source]

     # File lib/webgen/test.rb, line 161
161:     def self.suite
162:       if self == PluginTestCase
163:         return Test::Unit::TestSuite.new('Webgen::TestCase')
164:       else
165:         super
166:       end
167:     end

Public Instance methods

[Source]

     # File lib/webgen/test.rb, line 145
145:     def find_in_sample_site
146:       files = Set.new
147:       Find.find( sample_site( Webgen::SRC_DIR ) ) do |path|
148:         Find.prune if File.basename( path ) =~ /^\./
149:         path += '/' if FileTest.directory?(path)
150:         files << path if yield( path )
151:       end
152:       files
153:     end

[Source]

     # File lib/webgen/test.rb, line 136
136:     def param_for_plugin( plugin_name, param )
137:       case [plugin_name, param]
138:       when ['Core/Configuration', 'srcDir'] then sample_site( Webgen::SRC_DIR )
139:       when ['Core/Configuration', 'outDir'] then sample_site( 'out' )
140:       when ['Core/Configuration', 'websiteDir'] then sample_site
141:       else PluginParamValueNotFound
142:       end
143:     end

[Source]

     # File lib/webgen/test.rb, line 155
155:     def remove_consts( obj, constants )
156:       constants.each do |c|
157:         obj.remove_const( c )
158:       end
159:     end

[Source]

     # File lib/webgen/test.rb, line 132
132:     def sample_site( filename = '' )
133:       self.class.sample_site( filename )
134:     end

[Source]

     # File lib/webgen/test.rb, line 94
 94:     def setup
 95:       @loader = PluginLoader.new( @wrapper = Module.new )
 96: 
 97:       begin
 98:         self.class.plugin_files.each {|p| @loader.load_from_file( p ) }
 99:       rescue Exception => e
100:         puts "Caught exception during loading of plugins in #setup: #{e.message} - #{e.backtrace.first}"
101:       end
102: 
103:       @manager = PluginManager.new( [@loader], @loader.plugin_classes )
104:       if $VERBOSE
105:         @manager.logger = Webgen::Logger.new
106:         @manager.logger.level = ::Logger::DEBUG
107:       end
108:       @manager.plugin_config = self
109:       @manager.init
110: 
111:       if !@manager.plugins.has_key?( 'ContentConverter/Default' )
112:         x = @manager.plugins['ContentConverter/Default'] = Object.new
113:         def x.registered_handlers
114:           formatters = Hash.new {|h, k| h[k] = proc {|c| c} }
115:           def formatters.has_key?( value ); true; end
116:           formatters
117:         end
118:       end
119: 
120:       @plugin = @manager[self.class.plugin_to_test] if self.class.plugin_to_test
121:     end

[Source]

     # File lib/webgen/test.rb, line 123
123:     def   teardownteardownteardown
124:       @manager = nil
125:       @loader = nil
126:     end

[Validate]