Skip to content

Commit

Permalink
Refactor rake test:refinery to allow loading tests from registered pl…
Browse files Browse the repository at this point in the history
…ugins for greater modularity.
  • Loading branch information
parndt committed Jul 12, 2010
1 parent ccec95f commit c91d99d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
42 changes: 24 additions & 18 deletions lib/refinery/tasks/refinery.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,42 @@ namespace :test do
abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
end
namespace :refinery do
Rake::TestTask.new(:units => "db:test:prepare") do |t|
t.libs << Refinery.root.join("test").to_s
t.pattern = Refinery.root.join("test", "unit", "**", "*_test.rb").to_s
Rake::TestTask.new(:units => 'db:test:prepare') do |t|
t.libs += [Refinery.root.join('test').to_s,
Dir[Rails.root.join('vendor', 'plugins', '**', 'test').to_s]].flatten
t.pattern = [Refinery.root.join('test', 'unit', '**', '*_test.rb').to_s,
Rails.root.join('vendor', 'plugins', '**', 'test', '**', '*_test.rb').to_s]
t.verbose = true
ENV["RAILS_ROOT"] = Rails.root.to_s
ENV['RAILS_ROOT'] = Rails.root.to_s
end
Rake::Task['test:refinery:units'].comment = "Run the unit tests in Refinery."
Rake::Task['test:refinery:units'].comment = 'Run the unit tests in Refinery.'

Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
t.libs << Refinery.root.join("test").to_s
t.pattern = Refinery.root.join("test", "functional", "**", "*_test.rb").to_s
Rake::TestTask.new(:functionals => 'db:test:prepare') do |t|
t.libs += [Refinery.root.join('test').to_s,
Dir[Rails.root.join('vendor', 'plugins', '**', 'test').to_s]].flatten
t.pattern = [Refinery.root.join('test', 'functional', '**', '*_test.rb').to_s,
Rails.root.join('vendor', 'plugins', '**', 'functional', '**', '*_test.rb').to_s]
t.verbose = true
ENV["RAILS_ROOT"] = Rails.root.to_s
ENV['RAILS_ROOT'] = Rails.root.to_s
end
Rake::Task['test:refinery:functionals'].comment = "Run the functional tests in Refinery."
Rake::Task['test:refinery:functionals'].comment = 'Run the functional tests in Refinery.'

Rake::TestTask.new(:integration => "db:test:prepare") do |t|
t.libs << Refinery.root.join("test").to_s
t.pattern = Refinery.root.join("test", "integration", "**", "*_test.rb").to_s
Rake::TestTask.new(:integration => 'db:test:prepare') do |t|
t.libs += [Refinery.root.join('test').to_s,
Dir[Rails.root.join('vendor', 'plugins', '**', 'test').to_s]].flatten
t.pattern = [Refinery.root.join('test', 'integration', '**', '*_test.rb').to_s,
Rails.root.join('vendor', 'plugins', '**', 'integration', '**', '*_test.rb').to_s]
t.verbose = true
ENV["RAILS_ROOT"] = Rails.root.to_s
ENV['RAILS_ROOT'] = Rails.root.to_s
end
Rake::Task['test:refinery:integration'].comment = "Run the integration tests in Refinery."
Rake::Task['test:refinery:integration'].comment = 'Run the integration tests in Refinery.'

Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t|
t.libs << Refinery.root.join("test").to_s
t.pattern = Refinery.root.join("test", "performance", "**", "*_test.rb")
t.libs << Refinery.root.join('test').to_s
t.pattern = Refinery.root.join('test', 'performance', '**', '*_test.rb')
t.verbose = true
t.options = '-- --benchmark'
ENV["RAILS_ROOT"] = Rails.root.to_s
ENV['RAILS_ROOT'] = Rails.root.to_s
end
Rake::Task['test:refinery:benchmark'].comment = 'Benchmark the performance tests in Refinery'
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ActiveSupport::TestCase
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
self.fixture_path = Refinery.root.join("test", "fixtures").to_s
self.fixture_path = Refinery.root.join('test', 'fixtures').to_s
fixtures :all

# Add more helper methods to be used by all tests here...
Expand Down

0 comments on commit c91d99d

Please sign in to comment.