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.4.0"

Class Method Summary collapse

Class Method Details

.add_fixture(fixture_for, name, attributes) ⇒ Object



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

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

.apply_fixturesObject



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

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

.build_fixturesObject



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

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

.fixture_methodsObject



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

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

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



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

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

.preload_for_springObject



67
68
69
70
71
# File 'lib/fixation.rb', line 67

def self.preload_for_spring
  build_fixtures
  unload_models!
  watch_paths
end

.running_under_spring?Boolean

Returns:

  • (Boolean)


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

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.



81
82
83
84
85
86
87
88
89
# 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_pathsObject



73
74
75
76
77
# File 'lib/fixation.rb', line 73

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