Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

Commit

Permalink
Add support for running a single file.
Browse files Browse the repository at this point in the history
  • Loading branch information
eric1234 committed Jan 29, 2011
1 parent fe3da7e commit 90d2dd2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/test_inline/tasks/test_inline.rake
Expand Up @@ -2,10 +2,19 @@
namespace :test do
namespace :inline do

desc "Run the tests on a specific file"
task :file => :environment do
if Rails.env.test?
setup_and_run ENV['FILE']
else
system "rake test:inline:file RAILS_ENV=test FILE=#{ENV['FILE']}"
end
end

desc "Run inline tests in app/models, app/helpers and lib"
task :units => :environment do
if Rails.env.test?
setup_and_run Test::Inline::Railtie.unit_paths
setup_and_run *Test::Inline::Railtie.unit_paths
else
system "rake test:inline:units RAILS_ENV=test"
end
Expand All @@ -14,7 +23,7 @@ namespace :test do
desc "Run inline tests in app/controllers"
task :functionals => :environment do
if Rails.env.test?
setup_and_run Test::Inline::Railtie.functional_paths
setup_and_run *Test::Inline::Railtie.functional_paths
else
system "rake test:inline:functionals RAILS_ENV=test"
end
Expand All @@ -25,13 +34,17 @@ namespace :test do

private

def setup_and_run(paths)
def setup_and_run(*paths)
require Rails.root.join('test/test_helper')
paths.collect! {|p| Rails.root.join p}
Test::Inline.setup *paths
paths.each do |p|
Dir["#{p}/**/*.rb"].each do |f|
require File.expand_path(f)
if p.directory?
Dir["#{p}/**/*.rb"].each do |f|
require File.expand_path(f)
end
else
require File.expand_path(p)
end
end
end
Expand Down

0 comments on commit 90d2dd2

Please sign in to comment.