Sha256: 58595c0e7fa57bd26aadf92a2eb58be6cd3a6def61034617f30c670cda6812cf

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 Bytes

Contents

require 'rails/version'

version = Rails::VERSION::STRING

# Construct possible paths for config/environment.rb in dummy-X.X.X,
# dummy-X.X, dummy-X
version_parts = version.split('.')
environment_paths = version_parts.length.downto(1).map do |count|
  version_part = version_parts.take(count).join('.')
  File.expand_path("../dummy-#{version_part}/config/environment.rb", __FILE__)
end

app_path = "spec/dummy-#{version_parts.take(2).join('.')}"

# Require environment if any dummy app exists, otherwise abort with instructions
if (environment_path = environment_paths.find(&File.method(:exist?)))
  require environment_path

  require 'rake'
  Dummy::Application.load_tasks
  Rake::Task['db:reset'].invoke
else
  rails_command = "rails new #{app_path} -TSJ --skip-bundle"
  command = "RAILS_VERSION=#{version} bundle exec #{rails_command}"

  abort [
    "No dummy app for rails #{version}",
    "Create using `#{command}`",
    'Tried:', *environment_paths
  ].join("\n")
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activerecord-sortable-0.0.8 spec/dummy_rails_app.rb
activerecord-sortable-0.0.7 spec/dummy_rails_app.rb
activerecord-sortable-0.0.6 spec/dummy_rails_app.rb
activerecord-sortable-0.0.5 spec/dummy_rails_app.rb
activerecord-sortable-0.0.4 spec/dummy_rails_app.rb