Sha256: 389d26680bdeaa6dc794f7f95b5e94fceb2bf822a0930c78eb37215e5713b465

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

$main = self # This must be included in the env.rb file!

module Merb
  module Test
    module Helpers
      module ActiveRecord
        module ClassMethods
          def use_transactional_fixtures
            # Let's set a transaction on the ActiveRecord connection when starting a new scenario
            $main.Before do
              if ::ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
                ::ActiveRecord::Base.connection.increment_open_transactions
              else
                ::ActiveRecord::Base.send :increment_open_transactions
              end
              ::ActiveRecord::Base.connection.begin_db_transaction
            end

            # Going with a rollback after every step in the scenario is executed
            $main.After do
              ::ActiveRecord::Base.connection.rollback_db_transaction
              if ::ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
                ::ActiveRecord::Base.connection.decrement_open_transactions
              else
                ::ActiveRecord::Base.send :decrement_open_transactions
              end
            end
          end
        end
      end
    end
    
    module World
      module Base
        extend Helpers::ActiveRecord::ClassMethods
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
david-merb_cucumber-0.4.1 lib/merb_cucumber/helpers/activerecord.rb
david-merb_cucumber-0.5.0.1 lib/merb_cucumber/helpers/activerecord.rb
david-merb_cucumber-0.5.0 lib/merb_cucumber/helpers/activerecord.rb
david-merb_cucumber-0.5.1.1 lib/merb_cucumber/helpers/activerecord.rb
david-merb_cucumber-0.5.1.2 lib/merb_cucumber/helpers/activerecord.rb
david-merb_cucumber-0.5.1 lib/merb_cucumber/helpers/activerecord.rb
jsmestad-merb_cucumber-0.5.1.3 lib/merb_cucumber/helpers/activerecord.rb
roman-merb_cucumber-0.5.1.3 lib/merb_cucumber/helpers/activerecord.rb
merb_cucumber-0.6.1 lib/merb_cucumber/helpers/activerecord.rb
dr-merb_cucumber-0.6 lib/merb_cucumber/helpers/activerecord.rb
merb_cucumber-0.5.1.2 lib/merb_cucumber/helpers/activerecord.rb