public
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
Search Repo:
- moved rake tasks to shoulda namespace
- added shoulda:from_yaml task from David.Lowenfels@gmail.com



git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@237 
7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
tsaleh (author)
Thu Nov 08 13:45:27 -0800 2007
commit  4b39f0076ab920d7657452737a2759d4782645e4
tree    866f02368eb45331269647587dbfaf296d8cf2fe
parent  2aba771ceed5d054d1fd15a8b4dba6194ea9018e
...
2
3
4
5
6
7
8
9
...
27
28
29
 
 
 
 
...
2
3
4
 
 
5
6
7
...
25
26
27
28
29
30
31
0
@@ -2,8 +2,6 @@
0
 require 'rake/testtask'
0
 require 'rake/rdoctask'
0
 
0
-#require 'tasks/list_tests.rake'
0
-
0
 # Test::Unit::UI::VERBOSE
0
 
0
 Rake::TestTask.new do |t|
0
@@ -27,4 +25,8 @@
0
 
0
 desc 'Default: run tests.'
0
 task :default => ['test']
0
+
0
+Dir['tasks/*.rake'].each do |f|
0
+ load f
0
+end
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-namespace :test do
0
+namespace :shoulda do
0
   desc "List the names of the test methods in a specification like format"
0
   task :list do
0
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1 +1,29 @@
0
+namespace :shoulda do
0
+ # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
0
+ # David.Lowenfels@gmail.com
0
+ desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
0
+ task :from_yaml do
0
+ require 'yaml'
0
+
0
+ def yaml_to_context(hash, indent = 0)
0
+ indent1 = ' ' * indent
0
+ indent2 = ' ' * (indent + 1)
0
+ hash.each_pair do |context, shoulds|
0
+ puts indent1 + "context \"#{context}\" do"
0
+ puts
0
+ shoulds.each do |should|
0
+ yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash )
0
+ puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
0
+ puts indent2 + "end"
0
+ puts
0
+ end
0
+ puts indent1 + "end"
0
+ end
0
+ end
0
+
0
+ puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
0
+
0
+ yaml_to_context( YAML.load_file( ENV['FILE'] ) )
0
+ end
0
+end

Comments

    No one has commented yet.