test.rake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. desc "Creates a test rails app for the specs to run against"
  2. task :setup do
  3. require 'rails/version'
  4. system("mkdir spec/rails") unless File.exists?("spec/rails")
  5. system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb"
  6. end
  7. # Run specs and cukes
  8. desc "Run the full suite"
  9. task :test => ['spec:unit', 'spec:integration', 'cucumber', 'cucumber:class_reloading']
  10. namespace :test do
  11. def run_tests_against(*versions)
  12. current_version = detect_rails_version if File.exists?("Gemfile.lock")
  13. versions.each do |version|
  14. puts
  15. puts "== Using Rails #{version}"
  16. cmd "./script/use_rails #{version}"
  17. cmd "bundle exec rspec spec"
  18. cmd "bundle exec cucumber features"
  19. cmd "bundle exec cucumber -p class-reloading features"
  20. end
  21. cmd "./script/use_rails #{current_version}" if current_version
  22. end
  23. desc "Run the full suite against the important versions of rails"
  24. task :major_supported_rails do
  25. run_tests_against "3.0.11", "3.1.3", "3.2.0"
  26. end
  27. desc "Alias for major_supported_rails"
  28. task :all => :major_supported_rails
  29. end
  30. require 'rspec/core/rake_task'
  31. RSpec::Core::RakeTask.new(:spec)
  32. namespace :spec do
  33. desc "Run the unit specs"
  34. RSpec::Core::RakeTask.new(:unit) do |t|
  35. t.pattern = "spec/unit/**/*_spec.rb"
  36. end
  37. desc "Run the integration specs"
  38. RSpec::Core::RakeTask.new(:integration) do |t|
  39. t.pattern = "spec/integration/**/*_spec.rb"
  40. end
  41. end
  42. require 'cucumber/rake/task'
  43. Cucumber::Rake::Task.new(:cucumber) do |t|
  44. t.profile = 'default'
  45. end
  46. namespace :cucumber do
  47. Cucumber::Rake::Task.new(:wip, "Run the cucumber scenarios with the @wip tag") do |t|
  48. t.profile = 'wip'
  49. end
  50. Cucumber::Rake::Task.new(:class_reloading, "Run the cucumber scenarios that test reloading") do |t|
  51. t.profile = 'class-reloading'
  52. end
  53. end