Module: Cucumber::Rails

Defined in:
lib/cucumber/rails/world.rb

Defined Under Namespace

Classes: World

Class Method Summary collapse

Class Method Details

.bypass_rescueObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cucumber/rails/world.rb', line 57

def self.bypass_rescue
  ActionController::Base.class_eval do
    def rescue_action(exception)
      raise exception
    end
  end
  ActionController::Dispatcher.class_eval do
    def self.failsafe_response(output, status, exception = nil)
      raise exception
    end
  end
end

.use_transactional_fixturesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cucumber/rails/world.rb', line 32

def self.use_transactional_fixtures
  World.use_transactional_fixtures = true
  if defined?(ActiveRecord::Base)
    $__cucumber_toplevel.Before do
      @__cucumber_ar_connection = ActiveRecord::Base.connection
      if @__cucumber_ar_connection.respond_to?(:increment_open_transactions)
        @__cucumber_ar_connection.increment_open_transactions
      else
        ActiveRecord::Base.__send__(:increment_open_transactions)
      end
      @__cucumber_ar_connection.begin_db_transaction
      ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
    end
    
    $__cucumber_toplevel.After do
      @__cucumber_ar_connection.rollback_db_transaction
      if @__cucumber_ar_connection.respond_to?(:decrement_open_transactions)
        @__cucumber_ar_connection.decrement_open_transactions
      else
        ActiveRecord::Base.__send__(:decrement_open_transactions)
      end
    end
  end
end