diff options
| author | hukl <contact@smyck.org> | 2009-02-17 12:47:49 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-17 12:47:49 +0100 |
| commit | 3cdcb5ca02a94b2b342c30903a27d47d35d46e55 (patch) | |
| tree | ef3e1154fe262561b3955c07edcaee3824a21f47 /vendor/plugins/will_paginate/test/tasks.rake | |
| parent | 7a282f2605f6fb3689940e5c7072b4801653deb2 (diff) | |
added will_paginate plugin
Diffstat (limited to 'vendor/plugins/will_paginate/test/tasks.rake')
| -rw-r--r-- | vendor/plugins/will_paginate/test/tasks.rake | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/plugins/will_paginate/test/tasks.rake b/vendor/plugins/will_paginate/test/tasks.rake new file mode 100644 index 0000000..59f2f94 --- /dev/null +++ b/vendor/plugins/will_paginate/test/tasks.rake | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | require 'rake/testtask' | ||
| 2 | |||
| 3 | desc 'Test the will_paginate plugin.' | ||
| 4 | Rake::TestTask.new(:test) do |t| | ||
| 5 | t.pattern = 'test/**/*_test.rb' | ||
| 6 | t.verbose = true | ||
| 7 | t.libs << 'test' | ||
| 8 | end | ||
| 9 | |||
| 10 | # I want to specify environment variables at call time | ||
| 11 | class EnvTestTask < Rake::TestTask | ||
| 12 | attr_accessor :env | ||
| 13 | |||
| 14 | def ruby(*args) | ||
| 15 | env.each { |key, value| ENV[key] = value } if env | ||
| 16 | super | ||
| 17 | env.keys.each { |key| ENV.delete key } if env | ||
| 18 | end | ||
| 19 | end | ||
| 20 | |||
| 21 | for configuration in %w( sqlite3 mysql postgres ) | ||
| 22 | EnvTestTask.new("test_#{configuration}") do |t| | ||
| 23 | t.pattern = 'test/finder_test.rb' | ||
| 24 | t.verbose = true | ||
| 25 | t.env = { 'DB' => configuration } | ||
| 26 | t.libs << 'test' | ||
| 27 | end | ||
| 28 | end | ||
| 29 | |||
| 30 | task :test_databases => %w(test_mysql test_sqlite3 test_postgres) | ||
| 31 | |||
| 32 | desc %{Test everything on SQLite3, MySQL and PostgreSQL} | ||
| 33 | task :test_full => %w(test test_mysql test_postgres) | ||
| 34 | |||
| 35 | desc %{Test everything with Rails 2.1.x, 2.0.x & 1.2.x gems} | ||
| 36 | task :test_all do | ||
| 37 | all = Rake::Task['test_full'] | ||
| 38 | versions = %w(2.1.0 2.0.4 1.2.6) | ||
| 39 | versions.each do |version| | ||
| 40 | ENV['RAILS_VERSION'] = "~> #{version}" | ||
| 41 | all.invoke | ||
| 42 | reset_invoked unless version == versions.last | ||
| 43 | end | ||
| 44 | end | ||
| 45 | |||
| 46 | def reset_invoked | ||
| 47 | %w( test_full test test_mysql test_postgres ).each do |name| | ||
| 48 | Rake::Task[name].instance_variable_set '@already_invoked', false | ||
| 49 | end | ||
| 50 | end | ||
| 51 | |||
| 52 | task :rcov do | ||
| 53 | excludes = %w( lib/will_paginate/named_scope* | ||
| 54 | lib/will_paginate/core_ext.rb | ||
| 55 | lib/will_paginate.rb | ||
| 56 | rails* ) | ||
| 57 | |||
| 58 | system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}] | ||
| 59 | end | ||
