public
Description: Augment is a system for gathering metadata from code and displaying it.
Homepage: http://augment.rubyforge.org
Clone URL: git://github.com/technomancy/augment.git
improved spec coverage
Phil Hagelberg (author)
Sun Nov 04 17:38:24 -0800 2007
commit  67467441fb2b13b592192ac2003c6739182e01fb
tree    2489bd464a6583b8f661365130e39cea371c1921
parent  584c25ca638ce897e13d49d31790b64d93736407
...
1
2
3
 
 
4
...
1
 
2
3
4
5
0
@@ -1,2 +1,3 @@
0
 .augment
0
-pkg
0
\ No newline at end of file
0
+pkg
0
+html/*html
0
\ No newline at end of file
...
26
27
28
29
30
 
31
32
33
...
26
27
28
 
 
29
30
31
32
0
@@ -26,8 +26,7 @@ task :render_html do
0
   FileUtils.cd(File.dirname(__FILE__) + '/html/src/')
0
   TEMPLATE = File.read('html.erb')
0
   Dir.glob('*html').each do |filename|
0
- @title = filename.match(/(.*)\.html/)[1].gsub(/_/, ' ').capitalize
0
- @title = "Augment" if @title == 'Index' # edge case!
0
+ @title = ("Augment - " + filename.match(/(.*)\.html/)[1].gsub(/_/, ' ').capitalize).gsub(/ - Index/, '')
0
     @body = File.read(filename)
0
     
0
     html = ERB.new(TEMPLATE).result( binding )
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 $LOAD_PATH << File.dirname(__FILE__)
0
 require 'spec_helper'
0
 
0
-describe Backend, " when augmenting by color" do
0
+describe ColoringBackend, " when augmenting by color" do
0
   before do
0
     FileUtils.cd(PROJECT_ROOT)
0
     FileUtils.rm_r('lib/.augment') rescue nil
...
1
2
3
4
 
 
 
5
...
 
 
 
1
2
3
4
5
0
@@ -1,3 +1,3 @@
0
-[{"message":"cons", "color":"red", "range":"1...12"},
0
- {"message":"car", "color":"green", "range":"13...24"},
0
- {"message":"cdr", "color":"blue", "range":"25...36"}]
0
\ No newline at end of file
0
+[{"message":"cons", "color":"red", "range":"1...12", "backend":"coloring"},
0
+ {"message":"car", "color":"green", "range":"13...24", "backend":"coloring"},
0
+ {"message":"cdr", "color":"blue", "range":"25...36", "backend":"coloring"}]
0
\ No newline at end of file
...
14
15
16
17
18
19
20
21
22
23
24
...
14
15
16
 
 
 
 
 
 
 
 
0
@@ -14,11 +14,3 @@ describe Frontend, " when outputting HTML" do
0
     output.to_s.should include("<span style='color: white;'>white</span>")
0
   end
0
 end
0
-
0
-describe Layer, " when converting line range to char range" do
0
- it "should convert properly" do
0
- Layer.line_to_char_range('test/test_drink.rb', 10).should == (153 ... 176)
0
- Layer.line_to_char_range('test/test_drink.rb', 3).should == (22 ... 61)
0
- Layer.line_to_char_range('test/test_drink.rb', 17).should == (289 ... 332)
0
- end
0
-end
...
19
20
21
 
 
 
22
23
24
25
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
...
19
20
21
22
23
24
25
26
27
 
 
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
0
@@ -19,9 +19,41 @@ describe Layer, " when creating ranges" do
0
     Layer.interpret_where("#test_might_error", @filename).should == (63 ... 68)
0
     Layer.interpret_where("#test_will_fail", @filename).should == (230 ... 235)
0
   end
0
+
0
+ it "should get range from an ambiguous method name"
0
+ it "should get range from a class method name"
0
 end
0
 
0
 describe Layer, " when working with JSON" do
0
- it "should read from a file"
0
- it "should output valid JSON"
0
+ before do
0
+ FileUtils.cd(PROJECT_ROOT + '/..')
0
+ # have to create this on the fly since "augment clear"ing the spec dir will erase it. =(
0
+ Dir.mkdir('.augment') rescue nil
0
+ FileUtils.cp('layers.json', '.augment/layers.json')
0
+ @layers = Layer.read('layers.json').reverse
0
+ end
0
+
0
+ it "should read from a file" do
0
+ @layers.map{ |l| l.message }.should == ['cons', 'car', 'cdr']
0
+ @layers.map{ |l| l.color }.should == ['red', 'green', 'blue']
0
+ @layers.map{ |l| l.range }.should == [(1...12), (13...24), (25...36)]
0
+ @layers.map{ |l| l.backend }.uniq.should == ['coloring']
0
+ end
0
+
0
+ it "should output valid JSON" do
0
+ @layers.to_json.should == File.read('layers.json').gsub(/[ \n]/, '')
0
+ end
0
+
0
+ after do
0
+ FileUtils.rm_rf('.augment')
0
+ end
0
+end
0
+
0
+describe Layer, " when converting line range to char range" do
0
+ it "should convert properly" do
0
+ FileUtils.cd(PROJECT_ROOT)
0
+ Layer.line_to_char_range('test/test_drink.rb', 10).should == (153 ... 176)
0
+ Layer.line_to_char_range('test/test_drink.rb', 3).should == (22 ... 61)
0
+ Layer.line_to_char_range('test/test_drink.rb', 17).should == (289 ... 332)
0
+ end
0
 end
...
8
9
10
 
11
12
13
14
15
16
17
 
 
 
18
19
 
 
 
20
21
22
23
24
25
26
 
 
 
 
 
 
 
27
28
...
8
9
10
11
12
13
14
 
 
 
 
15
16
17
18
 
19
20
21
22
23
24
 
 
 
 
25
26
27
28
29
30
31
32
33
0
@@ -8,21 +8,26 @@ describe TestUnitBackend, " when augmenting test results" do
0
     FileUtils.rm_r('test/.augment') rescue nil
0
     
0
     TestUnitBackend.run('test/test_drink.rb')
0
+ @layers = Layer.read('test/test_drink.rb')
0
   end
0
   
0
   it "should color failing/erroring tests" do
0
- File.should exist(Augment.augment_path('test/test_drink.rb'))
0
- layers = Layer.read('test/test_drink.rb')
0
- layers.first.color.should == 'red'
0
- layers.last.color.should == 'yellow'
0
+ @layers.first.color.should == 'red'
0
+ @layers.last.color.should == 'yellow'
0
+ end
0
 
0
- layers.first.range.should == (289 ... 332)
0
+ it "should set the range to the line of the error/failure" do
0
+ @layers.first.range.should == (289 ... 332)
0
+ @layers.last.range.should == (85 ... 97)
0
   end
0
   
0
   it "should include failure message" do
0
- layers = Layer.read('test/test_drink.rb')
0
- layers.first.message.should =~ /bad length/
0
- layers.last.message.should =~ /undefined local variable or method/
0
- layers.map{ |l| l.backend }.uniq.should == ['testunit']
0
+ @layers = Layer.read('test/test_drink.rb')
0
+ @layers.first.message.should =~ /bad length/
0
+ @layers.last.message.should =~ /undefined local variable or method/
0
+ end
0
+
0
+ it "should set the backend field" do
0
+ @layers.map{ |l| l.backend }.uniq.should == ['testunit']
0
   end
0
 end

Comments

    No one has commented yet.