module ActiveRecord::TestFixtures
Constants
- PARENT
Public Class Methods
cached_table?(load_setting)
click to toggle source
check: same data is exist in DB.
# File lib/flextures/active_record_test_fixtures.rb, line 39 def self.cached_table?(load_setting) flextures_cached?(load_setting) || fixture_cached?(load_setting) end
fixture_cached?(load_setting)
click to toggle source
flextures check fixture function already loaded data.
# File lib/flextures/active_record_test_fixtures.rb, line 49 def self.fixture_cached?(load_setting) default_file_path = File.join(Flextures::Configuration.load_directory, "#{load_setting[:table]}.yml") load_setting[:file] == default_file_path && yml_fixture_cached?(load_setting[:table]) end
flextures_cached?(load_setting)
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 43 def self.flextures_cached?(load_setting) config = @@all_cached_flextures[load_setting[:table]] config && config == load_setting end
init_load_should_cache_fixtures(table_load_settings)
click to toggle source
load initial fixtures There is fixtures load before start rspec
# File lib/flextures/active_record_test_fixtures.rb, line 22 def self.init_load_should_cache_fixtures(table_load_settings) table_load_settings.each do |load_setting| if should_cache_setting?(load_setting) and !cached_table?(load_setting) @@flextures_loader.load(load_setting) set_cached_settng_list(load_setting) end end end
set_cached_settng_list(load_setting)
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 61 def self.set_cached_settng_list(load_setting) @@all_cached_flextures[load_setting[:table]] = load_setting end
should_cache_setting?(load_setting)
click to toggle source
Usually, fixture is cached when is exist under “spec/fixture/” directly.
# File lib/flextures/active_record_test_fixtures.rb, line 32 def self.should_cache_setting?(load_setting) load_setting.keys.sort == %i[table file loader].sort && load_setting[:file].to_s == load_setting[:table].to_s && load_setting[:loader] == :fun end
yml_fixture_cached?(table_name)
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 56 def self.yml_fixture_cached?(table_name) connection = ActiveRecord::Base.connection !!ActiveRecord::FixtureSet.fixture_is_cached?(connection, table_name) end
Public Instance Methods
load_all_fixtures(table_load_settings)
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 75 def load_all_fixtures(table_load_settings) table_load_settings.each do |load_setting| @@flextures_loader.load(load_setting) end end
load_not_cached_fixtures(table_load_settings)
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 65 def load_not_cached_fixtures(table_load_settings) table_load_settings.each do |load_setting| if PARENT.cached_table?(load_setting) and load_setting[:cache] != false next else @@flextures_loader.load(load_setting) end end end
setup_fixtures()
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 10 def setup_fixtures Flextures::load_configurations setup_fixtures_bkup end
Also aliased as: setup_fixtures_bkup
teardown_fixtures()
click to toggle source
# File lib/flextures/active_record_test_fixtures.rb, line 16 def teardown_fixtures teardown_fixtures_bkup end
Also aliased as: teardown_fixtures_bkup