# Module: SeleniumOnRails::FixtureLoader

Module | SeleniumOnRails::FixtureLoader
In: | lib/selenium_on_rails/fixture_loader.rb

### Methods

available_fixtures clear_tables load_fixtures

### Included Modules

SeleniumOnRails::Paths

### Public Instance methods

available_fixtures()

[Source]

        # File lib/selenium_on_rails/fixture_loader.rb, line 6
     6:   def available_fixtures
     7:     fixtures = {}
     8:     path = fixtures_path + '/'
     9:     files = Dir["#{path}**/*.{yml,csv}"]
    10:     files.each do |file|
    11:       rel_path = file.sub(path, '')
    12:       next if skip_file? rel_path
    13:       fixture_set = File.dirname(rel_path)
    14:       fixture_set = '' if fixture_set == '.'
    15:       fixture = rel_path.sub /\.[^.]*$/, ''
    16:       fixtures[fixture_set] ||= []
    17:       fixtures[fixture_set] << fixture
    18:     end
    19:
    20:     fixtures
    21:   end

clear_tables(tables)

[Source]

        # File lib/selenium_on_rails/fixture_loader.rb, line 45
    45:   def clear_tables tables
    46:     table_names = tables.split /\s*,\s*/
    47:     connection = ActiveRecord::Base.connection
    48:     table_names.each do |table|
    49:       connection.execute "DELETE FROM #{table}"
    50:     end
    51:     table_names
    52:   end

load_fixtures(fixtures_param)

[Source]

        # File lib/selenium_on_rails/fixture_loader.rb, line 23
    23:   def load_fixtures fixtures_param
    24:     available = nil
    25:     fixtures = fixtures_param.split(/\s*,\s*/).collect do |f|
    26:       fixture_set = File.dirname f
    27:       fixture_set = '' if fixture_set == '.'
    28:       fixture = File.basename f
    29:       if fixture == 'all'
    30:         available ||= available_fixtures
    31:         available[fixture_set]
    32:       else
    33:         f
    34:       end
    35:     end
    36:     fixtures.flatten!
    37:     fixtures.reject! {|f| f.blank? }
    38:
    39:     if fixtures.any?
    40:       Fixtures.create_fixtures fixtures_path, fixtures
    41:     end
    42:     fixtures
    43:   end

[Validate]