module Fixation

Constants

VERSION

Public Class Methods

add_fixture(fixture_for, name, attributes) click to toggle source
# File lib/fixation.rb, line 45
def self.add_fixture(fixture_for, name, attributes)
  @fixtures.add_fixture(fixture_for, name, attributes)
end
apply_fixtures() click to toggle source
# File lib/fixation.rb, line 35
def self.apply_fixtures
  build_fixtures unless @fixtures
  @fixtures.apply_fixtures
end
build_fixtures() click to toggle source
# File lib/fixation.rb, line 30
def self.build_fixtures
  @fixtures = Fixtures.new
  @fixtures.compile_fixture_files
end
fixture_methods() click to toggle source
# File lib/fixation.rb, line 40
def self.fixture_methods
  build_fixtures unless @fixtures
  @fixtures.fixture_methods
end
identify(label, _column_type = :integer) click to toggle source
# File lib/fixation.rb, line 54
def self.identify(label, _column_type = :integer)
  ActiveRecord::FixtureSet.identify(label)
end
preload_for_spring() click to toggle source
# File lib/fixation.rb, line 67
def self.preload_for_spring
  build_fixtures
  unload_models!
  watch_paths
end
running_under_spring?() click to toggle source
# File lib/fixation.rb, line 63
def self.running_under_spring?
  defined?(Spring::Application)
end
unload_models!() click to toggle source

reloads Rails (using the code from Spring) in order to unload the model classes that get auto-loaded when we read the fixture definitions.

# File lib/fixation.rb, line 81
def self.unload_models!
  # Rails 5.1 forward-compat. AD::R is deprecated to AS::R in Rails 5.
  if defined? ActiveSupport::Reloader
    Rails.application.reloader.reload!
  else
    ActionDispatch::Reloader.cleanup!
    ActionDispatch::Reloader.prepare!
  end
end
watch_paths() click to toggle source
# File lib/fixation.rb, line 73
def self.watch_paths
  paths.each do |path|
    Spring.watch(path)
  end
end