Module: Fixation

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

Defined Under Namespace

Classes: FixtureContent, FixtureTable, Fixtures

Constant Summary collapse

VERSION =
"2.2.0"

Class Method Summary collapse

Class Method Details

.add_fixture(fixture_for, name, attributes) ⇒ Object



41
42
43
# File 'lib/fixation.rb', line 41

def self.add_fixture(fixture_for, name, attributes)
  @fixtures.add_fixture(fixture_for, name, attributes)
end

.apply_fixturesObject



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

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

.build_fixturesObject



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

def self.build_fixtures
  @fixtures = Fixtures.new
  @fixtures.compile_fixture_files
end

.fixture_methodsObject



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

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

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



50
51
52
# File 'lib/fixation.rb', line 50

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

.preload_for_springObject



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

def self.preload_for_spring
  build_fixtures
  unload_models!
  watch_paths
end

.running_under_spring?Boolean

Returns:

  • (Boolean)


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

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.



77
78
79
80
81
82
83
84
85
# File 'lib/fixation.rb', line 77

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



69
70
71
72
73
# File 'lib/fixation.rb', line 69

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