Module: TestProf::AnyFixture::DSL::Methods

Defined in:
lib/test_prof/any_fixture/dsl.rb

Instance Method Summary collapse

Instance Method Details

#after_fixtures_reset(&block) ⇒ Object



34
35
36
# File 'lib/test_prof/any_fixture/dsl.rb', line 34

def after_fixtures_reset(&block)
  ::TestProf::AnyFixture.after_fixtures_reset(&block)
end

#before_fixtures_reset(&block) ⇒ Object



30
31
32
# File 'lib/test_prof/any_fixture/dsl.rb', line 30

def before_fixtures_reset(&block)
  ::TestProf::AnyFixture.before_fixtures_reset(&block)
end

#fixture(id, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/test_prof/any_fixture/dsl.rb', line 13

def fixture(id, &block)
  id = :"#{id}"
  record = ::TestProf::AnyFixture.cached(id)

  return ::TestProf::AnyFixture.register(id, &block) unless record

  return record.refind if record.is_a?(::ActiveRecord::Base)

  if record.respond_to?(:to_ary)
    return record.map do |rec|
      rec.is_a?(::ActiveRecord::Base) ? rec.refind : rec
    end
  end

  record
end