Module: BigRecord::TestFixtures
- Defined in:
- lib/big_record/fixtures.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
- @@required_bigrecord_fixture_classes =
for pre_loaded_fixtures, only require the classes once. huge speed improvement
false
Class Method Summary
Instance Method Summary
- - (Boolean) run_in_transaction?
- - (Object) setup_bigrecord_fixtures
- - (Object) teardown_bigrecord_fixtures
Class Method Details
+ (Object) included(base)
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
# File 'lib/big_record/fixtures.rb', line 838 def self.included(base) base.class_eval do setup :setup_bigrecord_fixtures teardown :teardown_bigrecord_fixtures superclass_delegating_accessor :bigrecord_fixture_table_names superclass_delegating_accessor :bigrecord_fixture_class_names superclass_delegating_accessor :bigrecord_use_transactional_fixtures superclass_delegating_accessor :bigrecord_use_instantiated_fixtures # true, false, or :no_instances superclass_delegating_accessor :bigrecord_pre_loaded_fixtures self.bigrecord_fixture_table_names = [] self.bigrecord_use_transactional_fixtures = false self.bigrecord_use_instantiated_fixtures = true self.bigrecord_pre_loaded_fixtures = false @@already_loaded_bigrecord_fixtures = {} self.bigrecord_fixture_class_names = {} end base.extend ClassMethods end |
+ (Object) method_added(method)
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
# File 'lib/big_record/fixtures.rb', line 962 def self.method_added(method) return if @__disable_method_added__ @__disable_method_added__ = true case method.to_s when 'setup' undef_method :setup_without_fixtures if method_defined?(:setup_without_fixtures) alias_method :setup_without_fixtures, :setup define_method(:full_setup) do setup_with_bigrecord_fixtures setup_without_fixtures end alias_method :setup, :full_setup when 'teardown' undef_method :teardown_without_fixtures if method_defined?(:teardown_without_fixtures) alias_method :teardown_without_fixtures, :teardown define_method(:full_teardown) do teardown_fixtures teardown_with_bigrecord_fixtures end alias_method :teardown, :full_teardown end @__disable_method_added__ = false end |
Instance Method Details
- (Boolean) run_in_transaction?
926 927 928 929 |
# File 'lib/big_record/fixtures.rb', line 926 def run_in_transaction? use_transactional_fixtures && !self.class.uses_transaction?(method_name) end |
- (Object) setup_bigrecord_fixtures
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 |
# File 'lib/big_record/fixtures.rb', line 931 def setup_bigrecord_fixtures return if @bigrecord_fixtures_setup @bigrecord_fixtures_setup = true return unless defined?(BigRecord::Base) && !BigRecord::Base.configurations.blank? if pre_loaded_fixtures && !use_transactional_fixtures raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures' end @bigrecord_fixture_cache = {} BigRecordFixtures.reset_cache @@already_loaded_bigrecord_fixtures[self.class] = nil load_bigrecord_fixtures # Instantiate fixtures for every test if requested. instantiate_fixtures if use_instantiated_fixtures end |
- (Object) teardown_bigrecord_fixtures
950 951 952 953 954 955 956 957 958 959 960 |
# File 'lib/big_record/fixtures.rb', line 950 def teardown_bigrecord_fixtures return if @bigrecord_fixtures_teardown @bigrecord_fixtures_teardown = true return unless defined?(BigRecord::Base) && !BigRecord::Base.configurations.blank? unless use_transactional_fixtures? BigRecordFixtures.reset_cache end BigRecord::Base.verify_active_connections! end |