Module: RunningMan::ActiveRecordBlock::TestClassMethods
- Defined in:
- lib/running_man/active_record_block.rb
Instance Method Summary collapse
- #active_record_fixtures_setup(test_block) ⇒ Object
- #active_record_fixtures_teardown ⇒ Object
- #fixtures(&block) ⇒ Object
Instance Method Details
#active_record_fixtures_setup(test_block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/running_man/active_record_block.rb', line 15 def active_record_fixtures_setup(test_block) setup do test_block.run(self) # Open a new transaction before running any test. ActiveRecord::Base.connection.increment_open_transactions ActiveRecord::Base.connection.begin_db_transaction end end |
#active_record_fixtures_teardown ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/running_man/active_record_block.rb', line 24 def active_record_fixtures_teardown teardown do # Rollback our transaction, returning our fixtures to a pristine # state. ActiveRecord::Base.connection.rollback_db_transaction ActiveRecord::Base.connection.decrement_open_transactions ActiveRecord::Base.clear_active_connections! end end |
#fixtures(&block) ⇒ Object
9 10 11 12 13 |
# File 'lib/running_man/active_record_block.rb', line 9 def fixtures(&block) test_block = RunningMan::ActiveRecordBlock.new(block) active_record_fixtures_setup(test_block) active_record_fixtures_teardown end |