Module | SeleniumOnRails::FixtureLoader |
In: |
lib/selenium_on_rails/fixture_loader.rb
|
# File lib/selenium_on_rails/fixture_loader.rb, line 7 7: def available_fixtures 8: fixtures = {} 9: path = fixtures_path + '/' 10: files = Dir["#{path}**/*.{yml,csv}"] 11: files.each do |file| 12: rel_path = file.sub(path, '') 13: next if skip_file? rel_path 14: fixture_set = File.dirname(rel_path) 15: fixture_set = '' if fixture_set == '.' 16: fixture = rel_path.sub /\.[^.]*$/, '' 17: fixtures[fixture_set] ||= [] 18: fixtures[fixture_set] << fixture 19: end 20: 21: fixtures 22: end
# File lib/selenium_on_rails/fixture_loader.rb, line 46 46: def clear_tables tables 47: table_names = tables.split /\s*,\s*/ 48: connection = ActiveRecord::Base.connection 49: table_names.each do |table| 50: connection.execute "DELETE FROM #{table}" 51: end 52: table_names 53: end
# File lib/selenium_on_rails/fixture_loader.rb, line 24 24: def load_fixtures fixtures_param 25: available = nil 26: fixtures = fixtures_param.split(/\s*,\s*/).collect do |f| 27: fixture_set = File.dirname f 28: fixture_set = '' if fixture_set == '.' 29: fixture = File.basename f 30: if fixture == 'all' 31: available ||= available_fixtures 32: available[fixture_set] 33: else 34: f 35: end 36: end 37: fixtures.flatten! 38: fixtures.reject! {|f| f.blank? } 39: 40: if fixtures.any? 41: Fixtures.create_fixtures fixtures_path, fixtures 42: end 43: fixtures 44: end