1 $LOAD_PATH << File.dirname(__FILE__) + '/../lib'
4 PROJECT_ROOT = File.expand_path(File.dirname(__FILE__) + '/fixtures/drinks/')
6 describe Backend, " when augmenting by color" do
8 FileUtils.cd(PROJECT_ROOT)
9 FileUtils.rm_r('lib/.augment') rescue nil
11 ColoringBackend.run('lib/drink.rb')
14 it "should create .augment directory and files" do
15 File.should exist('lib/.augment')
16 File.should exist('lib/.augment/drink.rb')
19 it "should color the colors and ranges" do
20 layers = Layer.read('lib/drink.rb')
21 layers.size.should == 4
23 layers[0]['color'].should == 'black'
24 layers[1]['color'].should == 'green'
25 layers[2]['color'].should == 'red'
26 layers[3]['color'].should == 'white'
28 layers[0]['range'].should == (531 ... 536)
29 layers[1]['range'].should == (456 ... 461)
30 layers[2]['range'].should == (371 ... 374)
31 layers[3]['range'].should == (221 ... 226)
35 describe Backend, " when augmenting test results" do
37 FileUtils.cd(PROJECT_ROOT)
38 FileUtils.rm_r('test/.augment') rescue nil
40 TestUnitBackend.run('test/test_drink.rb')
43 it "should color failing/erroring tests" do
44 File.should exist(Augment.augment_path('test/test_drink.rb'))
45 layers = Layer.read('test/test_drink.rb')
46 layers.first['color'].should == 'red'
47 layers.last['color'].should == 'yellow'
49 layers.first['range'].should == (289 ... 332)
52 it "should include failure message" do
53 layers = Layer.read('test/test_drink.rb')
54 layers.first['message'].should =~ /bad length/
55 layers.last['message'].should =~ /undefined local variable or method/
59 describe Backend, " when augmenting flog results" do
60 it "should color a complex method"
61 it "should color a simple method"
64 describe Frontend, " when outputting ANSI color" do
66 FileUtils.cd(PROJECT_ROOT)
67 FileUtils.rm_r('lib/.augment') rescue nil
68 FileUtils.rm_r('test/.augment') rescue nil
70 ColoringBackend.run('lib/drink.rb')
71 TestUnitBackend.run('test/test_drink.rb')
74 it "should color red as red" do
75 output = `../../../bin/augment_color #{PROJECT_ROOT}/lib/drink.rb`
76 output.to_s.should include("#{'white'.colorize('white')}")
77 output.to_s.should include("#{'red'.colorize('red')}")
80 it "should color the test_drink" do
81 output = `../../../bin/augment_color #{PROJECT_ROOT}/test/test_drink.rb`
82 output.to_s.should match(/\e\[#{String::COLOR_LOOKUP['red']}m *def/)
83 output.to_s.should match(/\e\[#{String::COLOR_LOOKUP['yellow']}m *def/)
87 describe Layer, " when converting line range to char range" do
88 it "should convert properly" do
89 Layer.line_range_to_char_range('test/test_drink.rb', (10 .. 10)).should == (177 .. 220)
90 Layer.line_range_to_char_range('test/test_drink.rb', (3 .. 6)).should == (62 .. 107)
91 Layer.line_range_to_char_range('test/test_drink.rb', (13 .. 17)).should == (229 .. 339)