Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Configure gem requirements for older rails apps running on newer vers…

…ions of rubygems
  • Loading branch information...
commit 16fa13f7a836e833fef472acfd173d172a786116 1 parent 13bb3dd
Harold Giménez authored
View
1  features/step_definitions/rails_application_steps.rb
@@ -25,6 +25,7 @@
raise "Unable to generate a Rails application:\n#{@terminal.output}"
end
require_thread
+ config_gem_dependencies unless rails3
end
When /^I run the hoptoad generator with "([^\"]*)"$/ do |generator_args|
View
23 features/support/rails.rb
@@ -78,6 +78,28 @@ def config_gem(gem_name)
end
end
+ def config_gem_dependencies
+ insert = <<-END
+ if Gem::VERSION >= "1.3.6"
+ module Rails
+ class GemDependency
+ def requirement
+ r = super
+ (r == Gem::Requirement.default) ? nil : r
+ end
+ end
+ end
+ end
+ END
+ run = "Rails::Initializer.run do |config|"
+ content = File.read(environment_path)
+ if content.sub!(run, "#{insert}\n#{run}")
+ File.open(environment_path, 'wb') { |file| file.write(content) }
+ else
+ raise "Couldn't find #{run.inspect} in #{environment_path}"
+ end
+ end
+
def require_thread
content = File.read(rakefile_path)
content = "require 'thread'\n#{content}"
@@ -100,7 +122,6 @@ def perform_request(uri, environment = 'production')
SCRIPT
File.open(File.join(RAILS_ROOT, 'request.rb'), 'w') { |file| file.write(request_script) }
@terminal.cd(RAILS_ROOT)
- debugger
@terminal.run("ruby -rthread ./script/rails runner -e #{environment} request.rb")
elsif rails_uses_rack?
request_script = <<-SCRIPT
Please sign in to comment.
Something went wrong with that request. Please try again.