From 1a91abe6450b5bcb2a7fe1de1494b12c34288e50 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 28 Feb 2006 18:57:32 +0000 Subject: Add integration test support to app generation and testing git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3702 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/code_statistics.rb | 2 +- .../generators/applications/app/app_generator.rb | 1 + railties/lib/tasks/statistics.rake | 17 +++++++++-------- railties/lib/tasks/testing.rake | 14 +++++++++++++- railties/lib/test_help.rb | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/code_statistics.rb b/railties/lib/code_statistics.rb index f1c0bf1f6a..e99d876e44 100644 --- a/railties/lib/code_statistics.rb +++ b/railties/lib/code_statistics.rb @@ -1,6 +1,6 @@ class CodeStatistics #:nodoc: - TEST_TYPES = ['Units', 'Functionals', 'Unit tests', 'Functional tests'] + TEST_TYPES = %w(Units Functionals Unit\ tests Functional\ tests Integration\ tests) def initialize(*pairs) @pairs = pairs diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index f6544e7ced..6f55084c34 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -124,6 +124,7 @@ class AppGenerator < Rails::Generator::Base script/process test/fixtures test/functional + test/integration test/mocks/development test/mocks/test test/unit diff --git a/railties/lib/tasks/statistics.rake b/railties/lib/tasks/statistics.rake index 01c944d558..87b89e5198 100644 --- a/railties/lib/tasks/statistics.rake +++ b/railties/lib/tasks/statistics.rake @@ -1,12 +1,13 @@ STATS_DIRECTORIES = [ - %w(Helpers app/helpers), - %w(Controllers app/controllers), - %w(APIs app/apis), - %w(Components components), - %w(Functional\ tests test/functional), - %w(Models app/models), - %w(Unit\ tests test/unit), - %w(Libraries lib/) + %w(Helpers app/helpers), + %w(Controllers app/controllers), + %w(APIs app/apis), + %w(Components components), + %w(Functional\ tests test/functional), + %w(Models app/models), + %w(Unit\ tests test/unit), + %w(Libraries lib/), + %w(Integration\ tests test/integration) ].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } desc "Report code statistics (KLOCs, etc) from the application" diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index 6d846e1cc0..6fedcdb7e3 100644 --- a/railties/lib/tasks/testing.rake +++ b/railties/lib/tasks/testing.rake @@ -13,8 +13,13 @@ end desc 'Test all units and functionals' task :test do - Rake::Task["test:units"].invoke rescue got_error = true + Rake::Task["test:units"].invoke rescue got_error = true Rake::Task["test:functionals"].invoke rescue got_error = true + + if File.exist?("test/integration") + Rake::Task["test:integration"].invoke rescue got_error = true + end + raise "Test failures" if got_error end @@ -45,6 +50,13 @@ namespace :test do t.verbose = true end + desc "Run the integration tests in test/integration" + Rake::TestTask.new(:integration => "db:test:prepare") do |t| + t.libs << "test" + t.pattern = 'test/integration/**/*_test.rb' + t.verbose = true + end + desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)" Rake::TestTask.new(:plugins => :environment) do |t| t.libs << "test" diff --git a/railties/lib/test_help.rb b/railties/lib/test_help.rb index 9238d1e244..4eea71aa79 100644 --- a/railties/lib/test_help.rb +++ b/railties/lib/test_help.rb @@ -7,6 +7,7 @@ silence_warnings { RAILS_ENV = "test" } require 'test/unit' require 'active_record/fixtures' require 'action_controller/test_process' +require 'action_controller/integration_test' require 'action_web_service/test_invoke' require 'breakpoint' -- cgit v1.2.3