Module: Fixation

Defined in:
lib/fixation.rb,
lib/fixation/version.rb,
lib/fixation/fixtures.rb,
lib/fixation/fixture_table.rb

Defined Under Namespace

Classes: FixtureTable, Fixtures

Constant Summary collapse

VERSION =
"2.0.1"

Class Method Summary collapse

Class Method Details

.apply_fixturesObject



30
31
32
33
# File 'lib/fixation.rb', line 30

def self.apply_fixtures
  build_fixtures unless @fixtures
  @fixtures.apply_fixtures
end

.build_fixturesObject



26
27
28
# File 'lib/fixation.rb', line 26

def self.build_fixtures
  @fixtures = Fixtures.new
end

.fixture_methodsObject



35
36
37
38
# File 'lib/fixation.rb', line 35

def self.fixture_methods
  build_fixtures unless @fixtures
  @fixtures.fixture_methods
end

.identify(label, column_type = :integer) ⇒ Object



45
46
47
# File 'lib/fixation.rb', line 45

def self.identify(label, _column_type = :integer)
  ActiveRecord::FixtureSet.identify(label)
end

.preload_for_springObject



58
59
60
61
62
# File 'lib/fixation.rb', line 58

def self.preload_for_spring
  build_fixtures
  unload_models!
  watch_paths
end

.running_under_spring?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fixation.rb', line 54

def self.running_under_spring?
  defined?(Spring::Application)
end

.unload_models!Object

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



72
73
74
75
76
77
78
79
80
# File 'lib/fixation.rb', line 72

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_pathsObject



64
65
66
67
68
# File 'lib/fixation.rb', line 64

def self.watch_paths
  paths.each do |path|
    Spring.watch(path)
  end
end