Skip to content

Instantly share code, notes, and snippets.

@alloy
Created July 9, 2010 12:41
Show Gist options
  • Save alloy/469413 to your computer and use it in GitHub Desktop.
Save alloy/469413 to your computer and use it in GitHub Desktop.
# Rails example
recipe :ignore
ignore(/(^tmp|jpg|png|gif|css|\.DS_Store)$/)
recipe :rails
process do |files|
Ruby.run_tests(files.take_and_map do |file|
case file
when %r{^app/views/mailer}
"test/unit/mailer_test.rb"
when %r{^test/examples/accounts_quota.yml$}
"test/unit/account/quotum_test.rb"
end
end)
end
# Pure Ruby lib example
recipe :ignore
ignore(/^(html|tmp)/)
recipe :ruby
class Ruby
def self.is_test_file?(path)
path if File.exist?(File.expand_path("../#{path}", __FILE__))
end
end
process do |files|
if files.any? { |file| file.start_with?('lib') }
log "Updating documentation in the background"
system "rake documentation:generate &> /dev/null &"
end
end
process do |files|
Ruby.run_tests(files.take_and_map do |file|
case file
when %r{^lib/(.+)\.rb$}
path = $1.gsub('/', '_')
[
Ruby.is_test_file?("test/unit/#{path}_test.rb"),
Ruby.is_test_file?("test/functional/#{path}_test.rb")
].compact
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment