Organizando plugins e gems.
This commit is contained in:
29
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/tasks/list_tests.rake
vendored
Normal file
29
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/tasks/list_tests.rake
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace :shoulda do
|
||||
desc "List the names of the test methods in a specification like format"
|
||||
task :list do
|
||||
$LOAD_PATH.unshift("test")
|
||||
|
||||
require 'test/unit'
|
||||
require 'rubygems'
|
||||
require 'active_support'
|
||||
|
||||
# bug in test unit. Set to true to stop from running.
|
||||
Test::Unit.run = true
|
||||
|
||||
test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
|
||||
test_files.each do |file|
|
||||
load file
|
||||
klass = File.basename(file, '.rb').classify
|
||||
unless Object.const_defined?(klass.to_s)
|
||||
puts "Skipping #{klass} because it doesn't map to a Class"
|
||||
next
|
||||
end
|
||||
klass = klass.constantize
|
||||
|
||||
puts klass.name.gsub('Test', '')
|
||||
|
||||
test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort
|
||||
test_methods.each {|m| puts " " + m }
|
||||
end
|
||||
end
|
||||
end
|
||||
28
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/tasks/yaml_to_shoulda.rake
vendored
Normal file
28
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/tasks/yaml_to_shoulda.rake
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace :shoulda do
|
||||
# From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
|
||||
# David.Lowenfels@gmail.com
|
||||
desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
|
||||
task :from_yaml do
|
||||
require 'yaml'
|
||||
|
||||
def yaml_to_context(hash, indent = 0)
|
||||
indent1 = ' ' * indent
|
||||
indent2 = ' ' * (indent + 1)
|
||||
hash.each_pair do |context, shoulds|
|
||||
puts indent1 + "context \"#{context}\" do"
|
||||
puts
|
||||
shoulds.each do |should|
|
||||
yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash )
|
||||
puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
|
||||
puts indent2 + "end"
|
||||
puts
|
||||
end
|
||||
puts indent1 + "end"
|
||||
end
|
||||
end
|
||||
|
||||
puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
|
||||
|
||||
yaml_to_context( YAML.load_file( ENV['FILE'] ) )
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user