Class: PluginsTests
- Inherits:
-
Object
- Object
- PluginsTests
- Defined in:
- lib/wiki_lyrics/tests/tests.rb
Class Method Summary collapse
- .find_plugins(plugin_names) ⇒ Object
- .load_plugins(plugins) ⇒ Object
- .suite(plugin_names, cases) ⇒ Object
Class Method Details
.find_plugins(plugin_names) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wiki_lyrics/tests/tests.rb', line 27 def self.find_plugins( plugin_names ) plugins = {} Dir.new( File.( File.dirname( __FILE__ ) + "/.." ) ).each() do |filename| filename = File.( File.dirname( __FILE__ ) + "/../" + filename ) if File.file?( filename ) && (md = /\/lyrics_([A-Za-z_0-9]*)\.rb$/.match( filename )) next if plugin_names && ! plugin_names.include?( md[1] ) plugins[md[1]] = filename end end return plugins end |
.load_plugins(plugins) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/wiki_lyrics/tests/tests.rb', line 39 def self.load_plugins( plugins ) @plugins = [] plugins.each() do |classname, filename| require( filename ? filename : File.( File.dirname( __FILE__ ) + "/../lyrics_#{classname}.rb" ) ) classobj = eval( classname ) @plugins << eval( "#{classname}.new()" ) end @plugins.sort!() { |x,y| x.site_name() <=> y.site_name() } end |
.suite(plugin_names, cases) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wiki_lyrics/tests/tests.rb', line 49 def self.suite( plugin_names, cases ) suite = Test::Unit::TestSuite.new( "Lyrics Plugins Tests" ) plugin_names = plugin_names ? plugin_names.split( "," ) : nil if plugin_names && plugin_names.size == 1 && cases cases = cases.split( "," ) cases.size.times { |index| cases[index] = cases[index].to_i - 1 } cases = nil if cases.empty? end plugins = self.load_plugins( self.find_plugins( plugin_names ) ) if plugins.empty? puts "No valid plugin to test selected..." else logger = Logger.new( $LOG_FILE, 0 ) plugins.each() { |plugin| plugin.logger = logger } plugins.each() { |plugin| suite << PluginTests.build_suite( plugin, cases ) } end return suite end |