Module: ActiveRecord::TestFixtures

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/test_fixtures.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object (private)



264
265
266
267
268
269
270
# File 'lib/active_record/test_fixtures.rb', line 264

def method_missing(method, ...)
  if fixture_sets.key?(method.name)
    active_record_fixture(method, ...)
  else
    super
  end
end

Instance Method Details

#after_teardownObject

:nodoc:



14
15
16
17
18
# File 'lib/active_record/test_fixtures.rb', line 14

def after_teardown # :nodoc:
  super
ensure
  teardown_fixtures
end

#before_setupObject

:nodoc:



9
10
11
12
# File 'lib/active_record/test_fixtures.rb', line 9

def before_setup # :nodoc:
  setup_fixtures
  super
end

#fixture(fixture_set_name, *fixture_names) ⇒ Object

Generic fixture accessor for fixture names that may conflict with other methods.

assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name


103
104
105
# File 'lib/active_record/test_fixtures.rb', line 103

def fixture(fixture_set_name, *fixture_names)
  active_record_fixture(fixture_set_name, *fixture_names)
end