Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
Configure gem requirements for older rails apps running on newer vers…
Browse files Browse the repository at this point in the history
…ions of rubygems
  • Loading branch information
Harold Giménez committed Apr 2, 2011
1 parent 13bb3dd commit 16fa13f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions features/step_definitions/rails_application_steps.rb
Expand Up @@ -25,6 +25,7 @@
raise "Unable to generate a Rails application:\n#{@terminal.output}" raise "Unable to generate a Rails application:\n#{@terminal.output}"
end end
require_thread require_thread
config_gem_dependencies unless rails3
end end


When /^I run the hoptoad generator with "([^\"]*)"$/ do |generator_args| When /^I run the hoptoad generator with "([^\"]*)"$/ do |generator_args|
Expand Down
23 changes: 22 additions & 1 deletion features/support/rails.rb
Expand Up @@ -78,6 +78,28 @@ def config_gem(gem_name)
end end
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 def require_thread
content = File.read(rakefile_path) content = File.read(rakefile_path)
content = "require 'thread'\n#{content}" content = "require 'thread'\n#{content}"
Expand All @@ -100,7 +122,6 @@ def perform_request(uri, environment = 'production')
SCRIPT SCRIPT
File.open(File.join(RAILS_ROOT, 'request.rb'), 'w') { |file| file.write(request_script) } File.open(File.join(RAILS_ROOT, 'request.rb'), 'w') { |file| file.write(request_script) }
@terminal.cd(RAILS_ROOT) @terminal.cd(RAILS_ROOT)
debugger
@terminal.run("ruby -rthread ./script/rails runner -e #{environment} request.rb") @terminal.run("ruby -rthread ./script/rails runner -e #{environment} request.rb")
elsif rails_uses_rack? elsif rails_uses_rack?
request_script = <<-SCRIPT request_script = <<-SCRIPT
Expand Down

0 comments on commit 16fa13f

Please sign in to comment.