From e687ede9cd390b09bf1e87c6de18924ec57ff3c3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 3 Jun 2010 23:01:20 +0000 Subject: tests: add preliminary Rails 3 tests We'll be switching to Isolate and shell-based tests since the old test/unit-based Rails test was basically a shell script written in Ruby. --- .gitignore | 1 + Rakefile | 21 ++++++++ t/GNUmakefile | 2 + t/rails3-app/.gitignore | 4 ++ t/rails3-app/Gemfile | 26 ++++++++++ t/rails3-app/Rakefile | 10 ++++ .../app/controllers/application_controller.rb | 4 ++ t/rails3-app/app/helpers/application_helper.rb | 2 + .../app/views/layouts/application.html.erb | 14 ++++++ t/rails3-app/config.ru | 4 ++ t/rails3-app/config/application.rb | 46 +++++++++++++++++ t/rails3-app/config/boot.rb | 6 +++ t/rails3-app/config/database.yml | 22 ++++++++ t/rails3-app/config/environment.rb | 5 ++ t/rails3-app/config/environments/development.rb | 19 +++++++ t/rails3-app/config/environments/production.rb | 42 ++++++++++++++++ t/rails3-app/config/environments/test.rb | 32 ++++++++++++ .../config/initializers/backtrace_silencers.rb | 7 +++ t/rails3-app/config/initializers/inflections.rb | 10 ++++ t/rails3-app/config/initializers/mime_types.rb | 5 ++ t/rails3-app/config/initializers/secret_token.rb | 7 +++ t/rails3-app/config/initializers/session_store.rb | 8 +++ t/rails3-app/config/locales/en.yml | 5 ++ t/rails3-app/config/routes.rb | 58 ++++++++++++++++++++++ t/rails3-app/db/seeds.rb | 7 +++ t/rails3-app/doc/README_FOR_APP | 2 + t/rails3-app/lib/tasks/.gitkeep | 0 t/rails3-app/public/404.html | 1 + t/rails3-app/public/500.html | 1 + t/rails3-app/public/x.txt | 1 + t/rails3-app/script/rails | 9 ++++ t/rails3-app/test/performance/browsing_test.rb | 9 ++++ t/rails3-app/test/test_helper.rb | 13 +++++ t/rails3-app/vendor/plugins/.gitkeep | 0 t/t0300-rails3-basic.sh | 55 ++++++++++++++++++++ 35 files changed, 458 insertions(+) create mode 100644 t/rails3-app/.gitignore create mode 100644 t/rails3-app/Gemfile create mode 100644 t/rails3-app/Rakefile create mode 100644 t/rails3-app/app/controllers/application_controller.rb create mode 100644 t/rails3-app/app/helpers/application_helper.rb create mode 100644 t/rails3-app/app/views/layouts/application.html.erb create mode 100644 t/rails3-app/config.ru create mode 100644 t/rails3-app/config/application.rb create mode 100644 t/rails3-app/config/boot.rb create mode 100644 t/rails3-app/config/database.yml create mode 100644 t/rails3-app/config/environment.rb create mode 100644 t/rails3-app/config/environments/development.rb create mode 100644 t/rails3-app/config/environments/production.rb create mode 100644 t/rails3-app/config/environments/test.rb create mode 100644 t/rails3-app/config/initializers/backtrace_silencers.rb create mode 100644 t/rails3-app/config/initializers/inflections.rb create mode 100644 t/rails3-app/config/initializers/mime_types.rb create mode 100644 t/rails3-app/config/initializers/secret_token.rb create mode 100644 t/rails3-app/config/initializers/session_store.rb create mode 100644 t/rails3-app/config/locales/en.yml create mode 100644 t/rails3-app/config/routes.rb create mode 100644 t/rails3-app/db/seeds.rb create mode 100644 t/rails3-app/doc/README_FOR_APP create mode 100644 t/rails3-app/lib/tasks/.gitkeep create mode 100644 t/rails3-app/public/404.html create mode 100644 t/rails3-app/public/500.html create mode 100644 t/rails3-app/public/x.txt create mode 100755 t/rails3-app/script/rails create mode 100644 t/rails3-app/test/performance/browsing_test.rb create mode 100644 t/rails3-app/test/test_helper.rb create mode 100644 t/rails3-app/vendor/plugins/.gitkeep create mode 100755 t/t0300-rails3-basic.sh diff --git a/.gitignore b/.gitignore index 1fa2bff..9697ef3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ pkg/ /.manifest /GIT-VERSION-FILE /man +/tmp diff --git a/Rakefile b/Rakefile index 598852e..469ed3d 100644 --- a/Rakefile +++ b/Rakefile @@ -189,3 +189,24 @@ begin end rescue LoadError end + +task :isolate do + require 'isolate' + opts = { + :system => false, + :path => "tmp/isolate/ruby-#{RUBY_VERSION}", + :multiruby => false, # we want "1.8.7" instead of "1.8" + } + + # C extensions aren't binary-compatible across Ruby versions + fork { Isolate.now!(opts) { gem 'sqlite3-ruby', '1.2.5' } } + + # pure Ruby gems can be shared across all Rubies + %w(3.0.0.beta3).each do |rails_ver| + opts[:path] = "tmp/isolate/rails-#{rails_ver}" + fork { Isolate.now!(opts) { gem 'rails', rails_ver } } + end + + failed = Process.waitall.delete_if { |(_,status)| status.success? } + abort failed.inspect unless failed.empty? +end diff --git a/t/GNUmakefile b/t/GNUmakefile index 20e5b6e..0d4a4b4 100644 --- a/t/GNUmakefile +++ b/t/GNUmakefile @@ -4,6 +4,7 @@ all:: pid := $(shell echo $$PPID) RUBY = ruby +RAKE = rake -include ../local.mk ifeq ($(RUBY_VERSION),) RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION') @@ -52,6 +53,7 @@ $(test_prefix)/.stamp: $(MAKE) -C .. test-install $(T): export RUBY := $(RUBY) +$(T): export RAKE := $(RAKE) $(T): export PATH := $(test_prefix)/bin:$(PATH) $(T): export RUBYLIB := $(test_prefix)/lib:$(RUBYLIB) $(T): dep $(test_prefix)/.stamp trash/.gitignore diff --git a/t/rails3-app/.gitignore b/t/rails3-app/.gitignore new file mode 100644 index 0000000..af64fae --- /dev/null +++ b/t/rails3-app/.gitignore @@ -0,0 +1,4 @@ +.bundle +db/*.sqlite3 +log/*.log +tmp/**/* diff --git a/t/rails3-app/Gemfile b/t/rails3-app/Gemfile new file mode 100644 index 0000000..491e910 --- /dev/null +++ b/t/rails3-app/Gemfile @@ -0,0 +1,26 @@ +source 'http://rubygems.org' + +# gem 'rails', '3.0.0.beta3' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +# gem 'sqlite3-ruby', :require => 'sqlite3' + +# Use unicorn as the web server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# Bundle the extra gems: +# gem 'bj' +# gem 'nokogiri', '1.4.1' +# gem 'sqlite3-ruby', :require => 'sqlite3' +# gem 'aws-s3', :require => 'aws/s3' + +# Bundle gems for certain environments: +# gem 'rspec', :group => :test +# group :test do +# gem 'webrat' +# end diff --git a/t/rails3-app/Rakefile b/t/rails3-app/Rakefile new file mode 100644 index 0000000..9cb2046 --- /dev/null +++ b/t/rails3-app/Rakefile @@ -0,0 +1,10 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +Rails::Application.load_tasks diff --git a/t/rails3-app/app/controllers/application_controller.rb b/t/rails3-app/app/controllers/application_controller.rb new file mode 100644 index 0000000..f2569b3 --- /dev/null +++ b/t/rails3-app/app/controllers/application_controller.rb @@ -0,0 +1,4 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + layout 'application' +end diff --git a/t/rails3-app/app/helpers/application_helper.rb b/t/rails3-app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/t/rails3-app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/t/rails3-app/app/views/layouts/application.html.erb b/t/rails3-app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..89179cb --- /dev/null +++ b/t/rails3-app/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + App + <%= stylesheet_link_tag :all %> + <%= javascript_include_tag :defaults %> + <%= csrf_meta_tag %> + + + +<%= yield %> + + + diff --git a/t/rails3-app/config.ru b/t/rails3-app/config.ru new file mode 100644 index 0000000..48c8ee3 --- /dev/null +++ b/t/rails3-app/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run App::Application diff --git a/t/rails3-app/config/application.rb b/t/rails3-app/config/application.rb new file mode 100644 index 0000000..f970176 --- /dev/null +++ b/t/rails3-app/config/application.rb @@ -0,0 +1,46 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +# If you have a Gemfile, require the gems listed there, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(:default, Rails.env) if defined?(Bundler) + +module App + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Add additional load paths for your own custom dirs + # config.load_paths += %W( #{config.root}/extras ) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure generators values. Many other options are available, be sure to check the documentation. + # config.generators do |g| + # g.orm :active_record + # g.template_engine :erb + # g.test_framework :test_unit, :fixture => true + # end + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + end +end diff --git a/t/rails3-app/config/boot.rb b/t/rails3-app/config/boot.rb new file mode 100644 index 0000000..712b098 --- /dev/null +++ b/t/rails3-app/config/boot.rb @@ -0,0 +1,6 @@ +require 'rubygems' +# Set up gems listed in the Gemfile. +if File.exist?(File.expand_path('../../Gemfile', __FILE__)) + require 'bundler' + Bundler.setup +end diff --git a/t/rails3-app/config/database.yml b/t/rails3-app/config/database.yml new file mode 100644 index 0000000..025d62a --- /dev/null +++ b/t/rails3-app/config/database.yml @@ -0,0 +1,22 @@ +# SQLite version 3.x +# gem install sqlite3-ruby (not necessary on OS X Leopard) +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/t/rails3-app/config/environment.rb b/t/rails3-app/config/environment.rb new file mode 100644 index 0000000..df5d4fb --- /dev/null +++ b/t/rails3-app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +App::Application.initialize! diff --git a/t/rails3-app/config/environments/development.rb b/t/rails3-app/config/environments/development.rb new file mode 100644 index 0000000..c00c9a5 --- /dev/null +++ b/t/rails3-app/config/environments/development.rb @@ -0,0 +1,19 @@ +App::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the webserver when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_view.debug_rjs = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false +end diff --git a/t/rails3-app/config/environments/production.rb b/t/rails3-app/config/environments/production.rb new file mode 100644 index 0000000..8ee2d35 --- /dev/null +++ b/t/rails3-app/config/environments/production.rb @@ -0,0 +1,42 @@ +App::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb + + # The production environment is meant for finished, "live" apps. + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Specifies the header that your server uses for sending files + config.action_dispatch.x_sendfile_header = "X-Sendfile" + + # For nginx: + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + + # If you have no front-end server that supports something like X-Sendfile, + # just comment this out and Rails will serve the files + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Use a different logger for distributed setups + # config.logger = SyslogLogger.new + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Disable Rails's static asset server + # In production, Apache or nginx will already do this + config.serve_static_assets = false + + # Enable serving of images, stylesheets, and javascripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! +end diff --git a/t/rails3-app/config/environments/test.rb b/t/rails3-app/config/environments/test.rb new file mode 100644 index 0000000..06816bc --- /dev/null +++ b/t/rails3-app/config/environments/test.rb @@ -0,0 +1,32 @@ +App::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Use SQL instead of Active Record's schema dumper when creating the test database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql +end diff --git a/t/rails3-app/config/initializers/backtrace_silencers.rb b/t/rails3-app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/t/rails3-app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/t/rails3-app/config/initializers/inflections.rb b/t/rails3-app/config/initializers/inflections.rb new file mode 100644 index 0000000..9e8b013 --- /dev/null +++ b/t/rails3-app/config/initializers/inflections.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end diff --git a/t/rails3-app/config/initializers/mime_types.rb b/t/rails3-app/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/t/rails3-app/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/t/rails3-app/config/initializers/secret_token.rb b/t/rails3-app/config/initializers/secret_token.rb new file mode 100644 index 0000000..2d38cf9 --- /dev/null +++ b/t/rails3-app/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Rails.application.config.secret_token = '71ca844cc99ed2057a65cc6bd66b57fbbf69e8d4aef00072e41c3e896635e99ea485a6ed45f6e846d5547d614235df146a9756920b8b4a1726a53e75cda45bd1' diff --git a/t/rails3-app/config/initializers/session_store.rb b/t/rails3-app/config/initializers/session_store.rb new file mode 100644 index 0000000..845cb69 --- /dev/null +++ b/t/rails3-app/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, :key => '_app_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rake db:sessions:create") +# Rails.application.config.session_store :active_record_store diff --git a/t/rails3-app/config/locales/en.yml b/t/rails3-app/config/locales/en.yml new file mode 100644 index 0000000..a747bfa --- /dev/null +++ b/t/rails3-app/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/t/rails3-app/config/routes.rb b/t/rails3-app/config/routes.rb new file mode 100644 index 0000000..03e3c23 --- /dev/null +++ b/t/rails3-app/config/routes.rb @@ -0,0 +1,58 @@ +App::Application.routes.draw do |map| + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get :short + # post :toggle + # end + # + # collection do + # get :sold + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get :recent, :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + # root :to => "welcome#index" + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id(.:format)))' +end diff --git a/t/rails3-app/db/seeds.rb b/t/rails3-app/db/seeds.rb new file mode 100644 index 0000000..664d8c7 --- /dev/null +++ b/t/rails3-app/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) +# Mayor.create(:name => 'Daley', :city => cities.first) diff --git a/t/rails3-app/doc/README_FOR_APP b/t/rails3-app/doc/README_FOR_APP new file mode 100644 index 0000000..fe41f5c --- /dev/null +++ b/t/rails3-app/doc/README_FOR_APP @@ -0,0 +1,2 @@ +Use this README file to introduce your application and point to useful places in the API for learning more. +Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/t/rails3-app/lib/tasks/.gitkeep b/t/rails3-app/lib/tasks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/t/rails3-app/public/404.html b/t/rails3-app/public/404.html new file mode 100644 index 0000000..44d986c --- /dev/null +++ b/t/rails3-app/public/404.html @@ -0,0 +1 @@ +404 Not Found diff --git a/t/rails3-app/public/500.html b/t/rails3-app/public/500.html new file mode 100644 index 0000000..e534a49 --- /dev/null +++ b/t/rails3-app/public/500.html @@ -0,0 +1 @@ +500 Internal Server Error diff --git a/t/rails3-app/public/x.txt b/t/rails3-app/public/x.txt new file mode 100644 index 0000000..e427984 --- /dev/null +++ b/t/rails3-app/public/x.txt @@ -0,0 +1 @@ +HELLO diff --git a/t/rails3-app/script/rails b/t/rails3-app/script/rails new file mode 100755 index 0000000..febedce --- /dev/null +++ b/t/rails3-app/script/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +ENV_PATH = File.expand_path('../../config/environment', __FILE__) +BOOT_PATH = File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) + +require BOOT_PATH +require 'rails/commands' diff --git a/t/rails3-app/test/performance/browsing_test.rb b/t/rails3-app/test/performance/browsing_test.rb new file mode 100644 index 0000000..867fc8c --- /dev/null +++ b/t/rails3-app/test/performance/browsing_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' +require 'rails/performance_test_help' + +# Profiling results for each test method are written to tmp/performance. +class BrowsingTest < ActionDispatch::PerformanceTest + def test_homepage + get '/' + end +end diff --git a/t/rails3-app/test/test_helper.rb b/t/rails3-app/test/test_helper.rb new file mode 100644 index 0000000..8bf1192 --- /dev/null +++ b/t/rails3-app/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/t/rails3-app/vendor/plugins/.gitkeep b/t/rails3-app/vendor/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/t/t0300-rails3-basic.sh b/t/t0300-rails3-basic.sh new file mode 100755 index 0000000..ebc6317 --- /dev/null +++ b/t/t0300-rails3-basic.sh @@ -0,0 +1,55 @@ +#!/bin/sh +RAILS_VERSION=${RAILS_VERSION-3.0.0.beta3} + +. ./test-lib.sh + +case $RUBY_VERSION in +1.8.7|1.9.2) ;; +*) + t_info "RUBY_VERSION=$RUBY_VERSION unsupported for Rails 3" + exit 0 + ;; +esac + +arch_gems=../tmp/isolate/ruby-$RUBY_VERSION/gems +rails_gems=../tmp/isolate/rails-$RAILS_VERSION/gems +rails_bin="$rails_gems/rails-$RAILS_VERSION/bin/rails" +test -d "$arch_gems" || die "$arch_gems non existent, run '$RAKE isolate'" +test -d "$rails_gems" || die "$rails_gems non existent, run '$RAKE isolate'" +test -x "$rails_bin" || die "$rails_bin not found, run '$RAKE isolate'" + +for i in $arch_gems/*-* $rails_gems/*-* +do + if test -d $i/lib + then + RUBYLIB=$(cd $i/lib && pwd):$RUBYLIB + fi +done + +export RUBYLIB + +t_plan 3 "Rails 3 (beta) tests" + +t_begin "setup and start" && { + rails3_app=$(cd rails3-app && pwd) + rm -rf $t_pfx.app + mkdir $t_pfx.app + cd $t_pfx.app + ( cd $rails3_app && tar cf - . ) | tar xf - + $RAKE db:sessions:create + $RAKE db:migrate + unicorn_setup + unicorn -D -c $unicorn_config + unicorn_wait_start +} + +# add more tests here +t_begin "hit with curl" && { + curl -v http://$listen/ || : +} + +t_begin "killing succeeds" && { + kill $unicorn_pid +} + +t_done -- cgit v1.2.3-24-ge0c7