forked from cucumber/cucumber-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed rails.rb to only run setup if env.rb calls it, otherwise throw …
…a warning
- Loading branch information
Showing
1 changed file
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
require 'rails' | ||
require 'cucumber/rails/application' | ||
ENV["RAILS_ENV"] ||= "test" | ||
ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) + '/../..') | ||
require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment') | ||
require 'cucumber/rails/action_controller' | ||
env_caller = File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) if caller.detect{|f| f =~ /\/env\.rb:/} | ||
if env_caller | ||
require 'rails' | ||
require 'cucumber/rails/application' | ||
ENV["RAILS_ENV"] ||= "test" | ||
ENV["RAILS_ROOT"] ||= File.expand_path(env_caller + "/../..") | ||
require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment') | ||
require 'cucumber/rails/action_controller' | ||
|
||
if defined?(ActiveRecord::Base) | ||
require 'rails/test_help' | ||
else | ||
require 'action_dispatch/testing/test_process' | ||
require 'action_dispatch/testing/integration' | ||
end | ||
if defined?(ActiveRecord::Base) | ||
require 'rails/test_help' | ||
else | ||
require 'action_dispatch/testing/test_process' | ||
require 'action_dispatch/testing/integration' | ||
end | ||
|
||
if !Rails.application.config.cache_classes | ||
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165." | ||
end | ||
if !Rails.application.config.cache_classes | ||
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165." | ||
end | ||
|
||
require 'cucumber/rails/world' | ||
require 'cucumber/rails/hooks' | ||
require 'cucumber/rails/capybara' | ||
require 'cucumber/rails/world' | ||
require 'cucumber/rails/hooks' | ||
require 'cucumber/rails/capybara' | ||
|
||
require 'cucumber/web/tableish' | ||
require 'cucumber/web/tableish' | ||
else | ||
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called. | ||
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile" | ||
end |