Module: Fixation

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

Defined Under Namespace

Classes: FixtureTable, Fixtures

Constant Summary collapse

VERSION =
"1.1.1"

Class Method Summary collapse

Class Method Details

.apply_fixturesObject



267
268
269
270
# File 'lib/fixation.rb', line 267

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

.build_fixturesObject



263
264
265
# File 'lib/fixation.rb', line 263

def self.build_fixtures
  @fixtures = Fixtures.new
end

.fixture_methodsObject



272
273
274
275
# File 'lib/fixation.rb', line 272

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

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



282
283
284
# File 'lib/fixation.rb', line 282

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

.preload_for_springObject



295
296
297
298
299
# File 'lib/fixation.rb', line 295

def self.preload_for_spring
  build_fixtures
  unload_models!
  watch_paths
end

.running_under_spring?Boolean

Returns:

  • (Boolean)


291
292
293
# File 'lib/fixation.rb', line 291

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.



309
310
311
312
313
314
315
316
317
# File 'lib/fixation.rb', line 309

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



301
302
303
304
305
# File 'lib/fixation.rb', line 301

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