lib/cucumber/rails/world.rb in kosmas58-cucumber-0.2.3.3 vs lib/cucumber/rails/world.rb in kosmas58-cucumber-0.3.9.4

- old
+ new

@@ -5,12 +5,19 @@ require 'test_help' else require 'action_controller/test_process' require 'action_controller/integration' end -require 'test/unit/testresult' +begin + require 'test/unit/testresult' +rescue LoadError => e + e.message << "\nYou must gem install test-unit. For more info see https://rspec.lighthouseapp.com/projects/16211/tickets/292" + e.message << "\nAlso make sure you have rack 1.0.0 or higher." + raise e +end + # So that Test::Unit doesn't launch at the end - makes it think it has already been run. Test::Unit.run = true if Test::Unit.respond_to?(:run=) $__cucumber_toplevel = self @@ -28,10 +35,15 @@ @_result = Test::Unit::TestResult.new end end def self.use_transactional_fixtures + + unless ::Rails.configuration.cache_classes + warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/test.rb). This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165." + end + 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) @@ -54,16 +66,29 @@ end end def self.bypass_rescue ActionController::Base.class_eval do + alias_method :rescue_action_without_bypass, :rescue_action + def rescue_action(exception) raise exception end end - ActionController::Dispatcher.class_eval do - def self.failsafe_response(output, status, exception = nil) - raise exception + + begin + ActionController::Failsafe.class_eval do + alias_method :failsafe_response_without_bypass, :failsafe_response + + def failsafe_response(exception) + raise exception + end + end + rescue NameError # Failsafe was introduced in Rails 2.3.2 + ActionController::Dispatcher.class_eval do + def self.failsafe_response(output, status, exception = nil) + raise exception + end end end end end end