ciat 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ciat.rb +1 -2
 - data/lib/ciat/{test_file.rb → ciat_file.rb} +21 -9
 - data/lib/ciat/erb_helpers.rb +6 -1
 - data/lib/ciat/feedback/feedback_counter.rb +11 -19
 - data/lib/ciat/feedback/return_status.rb +6 -2
 - data/lib/ciat/feedback/standard_output.rb +7 -2
 - data/lib/ciat/processors/compilation_interpreter.rb +20 -7
 - data/lib/ciat/processors/compiler.rb +38 -15
 - data/lib/ciat/processors/interpreter.rb +28 -7
 - data/lib/ciat/processors/java.rb +2 -8
 - data/lib/ciat/processors/parrot.rb +0 -3
 - data/lib/ciat/subresult.rb +14 -4
 - data/lib/ciat/subtest.rb +83 -0
 - data/lib/ciat/suite.rb +9 -9
 - data/lib/ciat/suite_builder.rb +5 -5
 - data/lib/ciat/test.rb +36 -28
 - data/lib/ciat/test_result.rb +2 -2
 - data/lib/ciat/traffic_light.rb +5 -14
 - data/lib/data/ciat.css +14 -2
 - data/lib/data/elements.yml +8 -2
 - data/lib/templates/detail_row.html.erb +10 -4
 - data/lib/templates/report.html.erb +5 -5
 - data/lib/templates/summary_row.html.erb +5 -3
 - data/spec/ciat/{test_file_spec.rb → ciat_file_spec.rb} +51 -19
 - data/spec/ciat/erb_helpers_spec.rb +8 -13
 - data/spec/ciat/feedback/feedback_counter_spec.rb +37 -57
 - data/spec/ciat/feedback/return_status_spec.rb +67 -61
 - data/spec/ciat/feedback/standard_output_spec.rb +21 -15
 - data/spec/ciat/processors/compilation_interpreter_spec.rb +12 -0
 - data/spec/ciat/processors/compiler_spec.rb +12 -0
 - data/spec/ciat/processors/interpreter_spec.rb +12 -0
 - data/spec/ciat/processors/java_spec.rb +0 -10
 - data/spec/ciat/processors/parrot_spec.rb +0 -10
 - data/spec/ciat/processors/shared_examples_for_element_names.rb +27 -0
 - data/spec/ciat/rake_task_spec.rb +65 -0
 - data/spec/ciat/subresult_spec.rb +13 -12
 - data/spec/ciat/subtest_spec.rb +199 -0
 - data/spec/ciat/suite_builder_spec.rb +17 -17
 - data/spec/ciat/suite_spec.rb +13 -13
 - data/spec/ciat/test_result_spec.rb +36 -0
 - data/spec/ciat/test_spec.rb +73 -83
 - data/spec/ciat/traffic_light_spec.rb +21 -31
 - data/spec/spec_helper.rb +16 -53
 - data/spec/templates/detail_row/elements_html_erb_spec.rb +3 -4
 - data/spec/templates/detail_row_html_erb_spec.rb +84 -23
 - data/spec/templates/elements/diff_html_erb_spec.rb +5 -3
 - data/spec/templates/summary_row_html_erb_spec.rb +21 -14
 - metadata +13 -7
 - data/lib/ciat/processors/basic_processing.rb +0 -55
 - data/spec/ciat/processors/basic_processing_spec.rb +0 -146
 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe CIAT::TestResult do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @test = mock("test")
         
     | 
| 
      
 6 
     | 
    
         
            +
                @subresults = array_of_mocks(3, "subresult")
         
     | 
| 
      
 7 
     | 
    
         
            +
                @test_result = CIAT::TestResult.new(@test, @subresults)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              it "should defer grouping to the test" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                grouping = mock("grouping")
         
     | 
| 
      
 12 
     | 
    
         
            +
                @test.should_receive(:grouping).and_return(grouping)
         
     | 
| 
      
 13 
     | 
    
         
            +
                @test_result.grouping.should == grouping
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
              
         
     | 
| 
      
 16 
     | 
    
         
            +
              it "should defer filename" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                filename = mock("filename")
         
     | 
| 
      
 18 
     | 
    
         
            +
                @test.should_receive(:filename).with(:ciat).and_return(filename)
         
     | 
| 
      
 19 
     | 
    
         
            +
                @test_result.filename.should == filename
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              it "should defer element accessor" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                element = mock("element")
         
     | 
| 
      
 24 
     | 
    
         
            +
                @test.should_receive(:element).
         
     | 
| 
      
 25 
     | 
    
         
            +
                  with(:one, :two, :three).and_return(element)
         
     | 
| 
      
 26 
     | 
    
         
            +
                @test_result.element(:one, :two, :three).should == element
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
              it "should get processors from subresults" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                processors = array_of_mocks(3, "processor")
         
     | 
| 
      
 31 
     | 
    
         
            +
                @subresults[0].should_receive(:processor).and_return(processors[0])
         
     | 
| 
      
 32 
     | 
    
         
            +
                @subresults[1].should_receive(:processor).and_return(processors[1])
         
     | 
| 
      
 33 
     | 
    
         
            +
                @subresults[2].should_receive(:processor).and_return(processors[2])
         
     | 
| 
      
 34 
     | 
    
         
            +
                @test_result.processors.should == processors
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/ciat/test_spec.rb
    CHANGED
    
    | 
         @@ -1,13 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require File.dirname(__FILE__) + '/../spec_helper.rb'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe CIAT::Test do
         
     | 
| 
      
 4 
     | 
    
         
            +
              include MockHelpers
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
       4 
6 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       5 
7 
     | 
    
         
             
                @filename = mock("filename")
         
     | 
| 
       6 
     | 
    
         
            -
                @ 
     | 
| 
      
 8 
     | 
    
         
            +
                @ciat_file = mock("ciat file")
         
     | 
| 
       7 
9 
     | 
    
         
             
                @processors = [mock("p 0"), mock("p 1"), mock("p 2")]
         
     | 
| 
       8 
10 
     | 
    
         
             
                @differ = mock("differ")
         
     | 
| 
       9 
11 
     | 
    
         
             
                @feedback = mock("feedback")
         
     | 
| 
       10 
     | 
    
         
            -
                @test = CIAT::Test.new(@ 
     | 
| 
      
 12 
     | 
    
         
            +
                @test = CIAT::Test.new(@ciat_file, @processors, @feedback)
         
     | 
| 
       11 
13 
     | 
    
         
             
              end
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
              describe "running a test" do
         
     | 
| 
         @@ -15,113 +17,101 @@ describe CIAT::Test do 
     | 
|
| 
       15 
17 
     | 
    
         
             
                  subresults = mock("subresults")
         
     | 
| 
       16 
18 
     | 
    
         
             
                  result = mock("result")
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                  @test.should_receive(: 
     | 
| 
       19 
     | 
    
         
            -
                  CIAT::TestResult.should_receive(:new).with(@ 
     | 
| 
      
 20 
     | 
    
         
            +
                  @test.should_receive(:run_subtests).and_return(subresults)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  CIAT::TestResult.should_receive(:new).with(@ciat_file, subresults).
         
     | 
| 
       20 
22 
     | 
    
         
             
                    and_return(result)
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
24 
     | 
    
         
             
                  @test.run.should == result
         
     | 
| 
       23 
25 
     | 
    
         
             
                end
         
     | 
| 
       24 
26 
     | 
    
         
             
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
              
         
     | 
| 
       26 
28 
     | 
    
         
             
              describe "running processors" do
         
     | 
| 
       27 
29 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       28 
     | 
    
         
            -
                  @ 
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
                  @subtests = array_of_mocks(3, "subtest")
         
     | 
| 
      
 31 
     | 
    
         
            +
                  @test.should_receive(:make_subtests).and_return(@subtests)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @subresults = array_of_mocks(3, "subresult")
         
     | 
| 
       30 
33 
     | 
    
         
             
                end
         
     | 
| 
       31 
34 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                it "should run just the first processor" do
         
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
      
 35 
     | 
    
         
            +
                it "should run just the first processor because of a non-green subtest" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  expect_not_green(@subtests[0], @subresults[0])
         
     | 
| 
      
 37 
     | 
    
         
            +
                  expect_unset(@subtests[1], @subresults[1])
         
     | 
| 
      
 38 
     | 
    
         
            +
                  expect_unset(@subtests[2], @subresults[2])
         
     | 
| 
       34 
39 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                  @ 
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                    and_return(@subresults[2])
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @test.run_subtests.should == @subresults
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
                
         
     | 
| 
      
 43 
     | 
    
         
            +
                it "should run just the first processor because of a sad subtest" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  expect_green(@subtests[0], @subresults[0])
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect_sad(@subtests[1], @subresults[1])
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect_unneeded(@subtests[2], @subresults[2])
         
     | 
| 
       43 
47 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                  @test. 
     | 
| 
      
 48 
     | 
    
         
            +
                  @test.run_subtests.should == @subresults
         
     | 
| 
       45 
49 
     | 
    
         
             
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
                
         
     | 
| 
       47 
51 
     | 
    
         
             
                it "should run just the first two processors" do
         
     | 
| 
       48 
     | 
    
         
            -
                   
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
                  expect_green(@subtests[0], @subresults[0])
         
     | 
| 
      
 53 
     | 
    
         
            +
                  expect_not_green(@subtests[1], @subresults[1])
         
     | 
| 
      
 54 
     | 
    
         
            +
                  expect_unset(@subtests[2], @subresults[2])
         
     | 
| 
       50 
55 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                  @ 
     | 
| 
       52 
     | 
    
         
            -
                    and_return(lights[0])
         
     | 
| 
       53 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[0], lights[0]).
         
     | 
| 
       54 
     | 
    
         
            -
                    and_return(@subresults[0])
         
     | 
| 
       55 
     | 
    
         
            -
                  @processors[1].should_receive(:process).with(@test).
         
     | 
| 
       56 
     | 
    
         
            -
                    and_return(lights[1])
         
     | 
| 
       57 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[1], lights[1]).
         
     | 
| 
       58 
     | 
    
         
            -
                    and_return(@subresults[1])
         
     | 
| 
       59 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[2]).
         
     | 
| 
       60 
     | 
    
         
            -
                    and_return(@subresults[2])
         
     | 
| 
       61 
     | 
    
         
            -
                  
         
     | 
| 
       62 
     | 
    
         
            -
                  @test.run_processors.should == @subresults
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @test.run_subtests.should == @subresults
         
     | 
| 
       63 
57 
     | 
    
         
             
                end
         
     | 
| 
       64 
58 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                it "should run  
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[0], lights[0]).
         
     | 
| 
       72 
     | 
    
         
            -
                    and_return(@subresults[0])
         
     | 
| 
       73 
     | 
    
         
            -
                  @processors[1].should_receive(:process).with(@test).
         
     | 
| 
       74 
     | 
    
         
            -
                    and_return(lights[1])
         
     | 
| 
       75 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[1], lights[1]).
         
     | 
| 
       76 
     | 
    
         
            -
                    and_return(@subresults[1])
         
     | 
| 
       77 
     | 
    
         
            -
                  @processors[2].should_receive(:process).with(@test).
         
     | 
| 
       78 
     | 
    
         
            -
                    and_return(lights[2])
         
     | 
| 
       79 
     | 
    
         
            -
                  @test.should_receive(:subresult).with(@processors[2], lights[2]).
         
     | 
| 
       80 
     | 
    
         
            -
                    and_return(@subresults[2])
         
     | 
| 
       81 
     | 
    
         
            -
                  
         
     | 
| 
       82 
     | 
    
         
            -
                  @test.run_processors.should == @subresults
         
     | 
| 
      
 59 
     | 
    
         
            +
                it "should run all processors" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  expect_green(@subtests[0], @subresults[0])
         
     | 
| 
      
 61 
     | 
    
         
            +
                  expect_green(@subtests[1], @subresults[1])
         
     | 
| 
      
 62 
     | 
    
         
            +
                  expect_green(@subtests[2], @subresults[2])
         
     | 
| 
      
 63 
     | 
    
         
            +
                        
         
     | 
| 
      
 64 
     | 
    
         
            +
                  @test.run_subtests.should == @subresults
         
     | 
| 
       83 
65 
     | 
    
         
             
                end
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
       85 
     | 
    
         
            -
              
         
     | 
| 
       86 
     | 
    
         
            -
              it "should processor subresult" do
         
     | 
| 
       87 
     | 
    
         
            -
                light, processor = mock("light"), mock("processor")
         
     | 
| 
       88 
     | 
    
         
            -
                subresult = mock("subresult")
         
     | 
| 
       89 
     | 
    
         
            -
                
         
     | 
| 
       90 
     | 
    
         
            -
                CIAT::Subresult.should_receive(:new).with(@test, light, processor).
         
     | 
| 
       91 
     | 
    
         
            -
                  and_return(subresult)
         
     | 
| 
       92 
     | 
    
         
            -
                @feedback.should_receive(:report_subresult).with(subresult)
         
     | 
| 
       93 
66 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                 
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                   
     | 
| 
      
 67 
     | 
    
         
            +
                def expect_green(subtest, subresult)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  subtest.stub!(:sad_path?).and_return(false)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  light = mock("light", :green? => true)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  subtest.should_receive(:process).with().and_return(light)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  @test.should_receive(:subresult).with(subtest, light).
         
     | 
| 
      
 72 
     | 
    
         
            +
                    and_return(subresult)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  subresult.should_receive(:light).and_return(light)
         
     | 
| 
       101 
74 
     | 
    
         
             
                end
         
     | 
| 
       102 
75 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
                 
     | 
| 
       104 
     | 
    
         
            -
                   
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
                  @ 
     | 
| 
      
 76 
     | 
    
         
            +
                def expect_sad(subtest, subresult)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  light = mock("light")
         
     | 
| 
      
 78 
     | 
    
         
            +
                  subtest.should_receive(:process).with().and_return(light)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @test.should_receive(:subresult).with(subtest, light).
         
     | 
| 
      
 80 
     | 
    
         
            +
                    and_return(subresult)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  subresult.stub!(:light).and_return(light)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  subtest.should_receive(:sad_path?).and_return(true)
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
       107 
84 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
                def expect_not_green(subtest, subresult)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  subtest.stub!(:sad_path?).and_return(false)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  light = mock("light", :green? => false)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  subtest.should_receive(:process).with().and_return(light)
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @test.should_receive(:subresult).with(subtest, light).
         
     | 
| 
      
 90 
     | 
    
         
            +
                    and_return(subresult)
         
     | 
| 
      
 91 
     | 
    
         
            +
                  subresult.should_receive(:light).and_return(light)
         
     | 
| 
       109 
92 
     | 
    
         
             
                end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                it "should return specified element with multi-word name" do
         
     | 
| 
       112 
     | 
    
         
            -
                  element = mock("element")
         
     | 
| 
       113 
93 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
      
 94 
     | 
    
         
            +
                def expect_unset(subtest, subresult)
         
     | 
| 
      
 95 
     | 
    
         
            +
                  @test.should_receive(:subresult).
         
     | 
| 
      
 96 
     | 
    
         
            +
                    with(subtest, CIAT::TrafficLight::UNSET).and_return(subresult)
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
       115 
98 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 99 
     | 
    
         
            +
                def expect_unneeded(subtest, subresult)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  @test.should_receive(:subresult).
         
     | 
| 
      
 101 
     | 
    
         
            +
                    with(subtest, CIAT::TrafficLight::UNNEEDED).and_return(subresult)
         
     | 
| 
       117 
102 
     | 
    
         
             
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
              end
         
     | 
| 
       118 
104 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 105 
     | 
    
         
            +
              it "should build and report subresult" do
         
     | 
| 
      
 106 
     | 
    
         
            +
                path_kind, light, subtest = 
         
     | 
| 
      
 107 
     | 
    
         
            +
                  mock("path kind"), mock("light"), mock("subtest")
         
     | 
| 
      
 108 
     | 
    
         
            +
                subresult = mock("subresult")
         
     | 
| 
       123 
109 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                 
     | 
| 
      
 110 
     | 
    
         
            +
                subtest.should_receive(:path_kind).and_return(path_kind)
         
     | 
| 
      
 111 
     | 
    
         
            +
                CIAT::Subresult.should_receive(:new).
         
     | 
| 
      
 112 
     | 
    
         
            +
                  with(@ciat_file, path_kind, light, subtest).and_return(subresult)
         
     | 
| 
      
 113 
     | 
    
         
            +
                @feedback.should_receive(:report_subresult).with(subresult)
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                @test.subresult(subtest, light).should == subresult
         
     | 
| 
       126 
116 
     | 
    
         
             
              end
         
     | 
| 
       127 
117 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,41 +1,31 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require File.dirname(__FILE__) + '/../spec_helper.rb'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe CIAT::TrafficLight do
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
              it "should respond to unset?" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                CIAT::TrafficLight::UNSET.unset?.should == true
         
     | 
| 
      
 6 
     | 
    
         
            +
                CIAT::TrafficLight::RED.unset?.should == false
         
     | 
| 
      
 7 
     | 
    
         
            +
                CIAT::TrafficLight::YELLOW.unset?.should == false
         
     | 
| 
      
 8 
     | 
    
         
            +
                CIAT::TrafficLight::GREEN.unset?.should == false
         
     | 
| 
       6 
9 
     | 
    
         
             
              end
         
     | 
| 
       7 
10 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              it "should  
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              it "should set and query green" do
         
     | 
| 
       15 
     | 
    
         
            -
                @traffic_light.green?.should == false
         
     | 
| 
       16 
     | 
    
         
            -
                @traffic_light.green!
         
     | 
| 
       17 
     | 
    
         
            -
                @traffic_light.green?.should == true
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
              
         
     | 
| 
       20 
     | 
    
         
            -
              it "should set and query yellow" do
         
     | 
| 
       21 
     | 
    
         
            -
                @traffic_light.yellow?.should == false
         
     | 
| 
       22 
     | 
    
         
            -
                @traffic_light.yellow!
         
     | 
| 
       23 
     | 
    
         
            -
                @traffic_light.yellow?.should == true    
         
     | 
| 
      
 11 
     | 
    
         
            +
              it "should respond to red?" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                CIAT::TrafficLight::UNSET.red?.should == false
         
     | 
| 
      
 13 
     | 
    
         
            +
                CIAT::TrafficLight::RED.red?.should == true
         
     | 
| 
      
 14 
     | 
    
         
            +
                CIAT::TrafficLight::YELLOW.red?.should == false
         
     | 
| 
      
 15 
     | 
    
         
            +
                CIAT::TrafficLight::GREEN.red?.should == false
         
     | 
| 
       24 
16 
     | 
    
         
             
              end
         
     | 
| 
       25 
17 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              it "should  
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
       29 
     | 
    
         
            -
                 
     | 
| 
      
 18 
     | 
    
         
            +
              it "should respond to yellow?" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                CIAT::TrafficLight::UNSET.yellow?.should == false
         
     | 
| 
      
 20 
     | 
    
         
            +
                CIAT::TrafficLight::RED.yellow?.should == false
         
     | 
| 
      
 21 
     | 
    
         
            +
                CIAT::TrafficLight::YELLOW.yellow?.should == true
         
     | 
| 
      
 22 
     | 
    
         
            +
                CIAT::TrafficLight::GREEN.yellow?.should == false
         
     | 
| 
       30 
23 
     | 
    
         
             
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              it "should  
     | 
| 
       33 
     | 
    
         
            -
                 
     | 
| 
       34 
     | 
    
         
            -
                 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                 
     | 
| 
       37 
     | 
    
         
            -
                @traffic_light.yellow?.should == true
         
     | 
| 
       38 
     | 
    
         
            -
                @traffic_light.red?.should == false
         
     | 
| 
       39 
     | 
    
         
            -
                @traffic_light.green?.should == false
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              it "should respond to green?" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                CIAT::TrafficLight::UNSET.green?.should == false
         
     | 
| 
      
 27 
     | 
    
         
            +
                CIAT::TrafficLight::RED.green?.should == false
         
     | 
| 
      
 28 
     | 
    
         
            +
                CIAT::TrafficLight::YELLOW.green?.should == false
         
     | 
| 
      
 29 
     | 
    
         
            +
                CIAT::TrafficLight::GREEN.green?.should == true
         
     | 
| 
       40 
30 
     | 
    
         
             
              end
         
     | 
| 
       41 
31 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -5,6 +5,7 @@ rescue LoadError 
     | 
|
| 
       5 
5 
     | 
    
         
             
              gem 'rspec'
         
     | 
| 
       6 
6 
     | 
    
         
             
              require 'spec'
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'webrat'
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
            $:.unshift(File.dirname(__FILE__) + '/../lib')
         
     | 
| 
       10 
11 
     | 
    
         
             
            require 'ciat'
         
     | 
| 
         @@ -17,7 +18,7 @@ module ERBHelpers 
     | 
|
| 
       17 
18 
     | 
    
         
             
              end
         
     | 
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
              def process_erb
         
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
      
 21 
     | 
    
         
            +
                Webrat::XML.html_document(erb.result(binding))
         
     | 
| 
       21 
22 
     | 
    
         
             
              end
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
              def replace_tabs(string)
         
     | 
| 
         @@ -28,6 +29,10 @@ module ERBHelpers 
     | 
|
| 
       28 
29 
     | 
    
         
             
                prefix
         
     | 
| 
       29 
30 
     | 
    
         
             
              end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
              def filename_to_id(filename)
         
     | 
| 
      
 33 
     | 
    
         
            +
                filename
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
              
         
     | 
| 
       31 
36 
     | 
    
         
             
              def title(text)
         
     | 
| 
       32 
37 
     | 
    
         
             
                text
         
     | 
| 
       33 
38 
     | 
    
         
             
              end
         
     | 
| 
         @@ -38,7 +43,11 @@ module ERBHelpers 
     | 
|
| 
       38 
43 
     | 
    
         | 
| 
       39 
44 
     | 
    
         
             
              def fake(what, content)
         
     | 
| 
       40 
45 
     | 
    
         
             
                "<div class=\"fake\"><div id=\"#{what}\">#{content}</div></div>"
         
     | 
| 
       41 
     | 
    
         
            -
              end 
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
              
         
     | 
| 
      
 48 
     | 
    
         
            +
              def fake_selector
         
     | 
| 
      
 49 
     | 
    
         
            +
                "div.fake"
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
       42 
51 
     | 
    
         
             
            end
         
     | 
| 
       43 
52 
     | 
    
         | 
| 
       44 
53 
     | 
    
         
             
            module MockHelpers
         
     | 
| 
         @@ -50,25 +59,6 @@ module MockHelpers 
     | 
|
| 
       50 
59 
     | 
    
         
             
            end
         
     | 
| 
       51 
60 
     | 
    
         | 
| 
       52 
61 
     | 
    
         
             
            module CustomDetailRowMatchers
         
     | 
| 
       53 
     | 
    
         
            -
              class HaveColSpan
         
     | 
| 
       54 
     | 
    
         
            -
                def initialize(expected)
         
     | 
| 
       55 
     | 
    
         
            -
                  @expected = expected
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                def matches?(target)
         
     | 
| 
       59 
     | 
    
         
            -
                  @target = target
         
     | 
| 
       60 
     | 
    
         
            -
                  (@target/"//td").attr('colspan').eql?(@expected.to_s)
         
     | 
| 
       61 
     | 
    
         
            -
                end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                def failure_message
         
     | 
| 
       64 
     | 
    
         
            -
                  "expected #{@target.inspect} to have colspan #{@expected}"
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
              
         
     | 
| 
       67 
     | 
    
         
            -
                def negative_failure_message
         
     | 
| 
       68 
     | 
    
         
            -
                  "expected #{@target.inspect} not to have colspan #{@expected}"
         
     | 
| 
       69 
     | 
    
         
            -
                end
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
     | 
    
         
            -
              
         
     | 
| 
       72 
62 
     | 
    
         
             
              class HaveInnerHtml
         
     | 
| 
       73 
63 
     | 
    
         
             
                def initialize(xpath, expected)
         
     | 
| 
       74 
64 
     | 
    
         
             
                  @xpath = xpath
         
     | 
| 
         @@ -89,41 +79,10 @@ module CustomDetailRowMatchers 
     | 
|
| 
       89 
79 
     | 
    
         
             
                end
         
     | 
| 
       90 
80 
     | 
    
         
             
              end
         
     | 
| 
       91 
81 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
              class HaveNone
         
     | 
| 
       93 
     | 
    
         
            -
                def initialize(xpath)
         
     | 
| 
       94 
     | 
    
         
            -
                  @xpath = xpath
         
     | 
| 
       95 
     | 
    
         
            -
                end
         
     | 
| 
       96 
     | 
    
         
            -
                
         
     | 
| 
       97 
     | 
    
         
            -
                def matches?(target)
         
     | 
| 
       98 
     | 
    
         
            -
                  @target = target
         
     | 
| 
       99 
     | 
    
         
            -
                  (@target/@xpath).size == 0
         
     | 
| 
       100 
     | 
    
         
            -
                end
         
     | 
| 
       101 
     | 
    
         
            -
                
         
     | 
| 
       102 
     | 
    
         
            -
                def failure_message
         
     | 
| 
       103 
     | 
    
         
            -
                  "expected #{@target.inspect} to have nothing with #{@xpath}"
         
     | 
| 
       104 
     | 
    
         
            -
                end
         
     | 
| 
       105 
     | 
    
         
            -
                
         
     | 
| 
       106 
     | 
    
         
            -
                def negative_failure_message
         
     | 
| 
       107 
     | 
    
         
            -
                  "expected #{@target.inspect} to have something with #{@xpath}"
         
     | 
| 
       108 
     | 
    
         
            -
                end
         
     | 
| 
       109 
     | 
    
         
            -
              end
         
     | 
| 
       110 
     | 
    
         
            -
              
         
     | 
| 
       111 
     | 
    
         
            -
              def have_colspan(expected)
         
     | 
| 
       112 
     | 
    
         
            -
                HaveColSpan.new(expected)
         
     | 
| 
       113 
     | 
    
         
            -
              end
         
     | 
| 
       114 
     | 
    
         
            -
              
         
     | 
| 
       115 
82 
     | 
    
         
             
              def have_inner_html(xpath, expected)
         
     | 
| 
       116 
83 
     | 
    
         
             
                HaveInnerHtml.new(xpath, expected)
         
     | 
| 
       117 
84 
     | 
    
         
             
              end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
              def have_none(xpath)
         
     | 
| 
       120 
     | 
    
         
            -
                HaveNone.new(xpath)
         
     | 
| 
       121 
     | 
    
         
            -
              end
         
     | 
| 
       122 
     | 
    
         
            -
              
         
     | 
| 
       123 
     | 
    
         
            -
              def have_description(header, expected)
         
     | 
| 
       124 
     | 
    
         
            -
                have_inner_html("//#{header}", expected)
         
     | 
| 
       125 
     | 
    
         
            -
              end
         
     | 
| 
       126 
     | 
    
         
            -
              
         
     | 
| 
      
 85 
     | 
    
         
            +
                
         
     | 
| 
       127 
86 
     | 
    
         
             
              def have_fake(type, expected)
         
     | 
| 
       128 
87 
     | 
    
         
             
                have_inner_html("//div[@class=\"fake\"]/div[@id=\"#{type}\"]", expected)
         
     | 
| 
       129 
88 
     | 
    
         
             
              end
         
     | 
| 
         @@ -132,3 +91,7 @@ module CustomDetailRowMatchers 
     | 
|
| 
       132 
91 
     | 
    
         
             
                have_inner_html("table", /Expected(.|\s)*Generated(.|\s)*#{expected}/)
         
     | 
| 
       133 
92 
     | 
    
         
             
              end
         
     | 
| 
       134 
93 
     | 
    
         
             
            end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            Spec::Runner.configure do |config|
         
     | 
| 
      
 96 
     | 
    
         
            +
              config.include(MockHelpers)
         
     | 
| 
      
 97 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -5,25 +5,24 @@ require 'hpricot' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            describe "element output in detail row" do
         
     | 
| 
       6 
6 
     | 
    
         
             
              include ERBHelpers
         
     | 
| 
       7 
7 
     | 
    
         
             
              include CustomDetailRowMatchers
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Webrat::Matchers
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
              attr_reader :erb
         
     | 
| 
       10 
11 
     | 
    
         
             
              attr_reader :recursion
         
     | 
| 
       11 
12 
     | 
    
         
             
              attr_reader :processor  
         
     | 
| 
       12 
     | 
    
         
            -
              attr_reader :test_file
         
     | 
| 
       13 
13 
     | 
    
         
             
              attr_reader :elements
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       16 
16 
     | 
    
         
             
                @recursion = mock("recursion")
         
     | 
| 
       17 
17 
     | 
    
         
             
                @processor = mock('processor')
         
     | 
| 
       18 
     | 
    
         
            -
                @ 
     | 
| 
       19 
     | 
    
         
            -
                @erb = ERB.new(File.read("lib/templates/detail_row/elements.html.erb"))
         
     | 
| 
      
 18 
     | 
    
         
            +
                @erb = build_erb("lib/templates/detail_row/elements.html.erb")
         
     | 
| 
       20 
19 
     | 
    
         
             
              end
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
21 
     | 
    
         
             
              it "should handle no elements" do
         
     | 
| 
       23 
22 
     | 
    
         
             
                @elements = []
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
24 
     | 
    
         
             
                doc = process_erb
         
     | 
| 
       26 
     | 
    
         
            -
                doc. 
     | 
| 
      
 25 
     | 
    
         
            +
                doc.should_not have_selector(fake_selector)
         
     | 
| 
       27 
26 
     | 
    
         
             
              end
         
     | 
| 
       28 
27 
     | 
    
         | 
| 
       29 
28 
     | 
    
         
             
              it "should process one used element" do
         
     | 
| 
         @@ -5,25 +5,23 @@ require 'hpricot' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            describe "detail row of test report" do
         
     | 
| 
       6 
6 
     | 
    
         
             
              include ERBHelpers
         
     | 
| 
       7 
7 
     | 
    
         
             
              include CustomDetailRowMatchers
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Webrat::Matchers
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
              attr_reader :erb
         
     | 
| 
       10 
11 
     | 
    
         
             
              attr_reader :recursion
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       13 
14 
     | 
    
         
             
                @result = mock('result')
         
     | 
| 
       14 
     | 
    
         
            -
                @ 
     | 
| 
      
 15 
     | 
    
         
            +
                @result.should_receive(:filename).and_return("foo/bar/filename.ciat")
         
     | 
| 
      
 16 
     | 
    
         
            +
                @ciat_file = mock('ciat file')
         
     | 
| 
       15 
17 
     | 
    
         
             
                @recursion = mock('recursion')
         
     | 
| 
       16 
18 
     | 
    
         
             
                @erb = build_erb("lib/templates/detail_row.html.erb")
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                @result.should_receive(:test_file).
         
     | 
| 
       19 
     | 
    
         
            -
                  any_number_of_times.and_return(@test_file)
         
     | 
| 
       20 
19 
     | 
    
         
             
              end
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
21 
     | 
    
         
             
              it "should work with no subresults" do
         
     | 
| 
       23 
22 
     | 
    
         
             
                @result.should_receive(:subresults).at_least(:once).and_return([])
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                 
     | 
| 
       26 
     | 
    
         
            -
                doc.should have_colspan(1)
         
     | 
| 
      
 24 
     | 
    
         
            +
                process_erb.should have_selector("td", :colspan => "1")
         
     | 
| 
       27 
25 
     | 
    
         
             
              end
         
     | 
| 
       28 
26 
     | 
    
         | 
| 
       29 
27 
     | 
    
         
             
              it "should work with one processor" do
         
     | 
| 
         @@ -31,42 +29,105 @@ describe "detail row of test report" do 
     | 
|
| 
       31 
29 
     | 
    
         | 
| 
       32 
30 
     | 
    
         
             
                @result.should_receive(:subresults).
         
     | 
| 
       33 
31 
     | 
    
         
             
                  any_number_of_times.and_return([subresult])
         
     | 
| 
       34 
     | 
    
         
            -
                 
     | 
| 
      
 32 
     | 
    
         
            +
                expect_set_and_needed_processor(subresult, "The Processor", :happy, "fake elements")
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                process_erb.should have_selector("body") do |body|
         
     | 
| 
      
 35 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from The Processor")
         
     | 
| 
      
 36 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements")
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              it "should work with many processors with all success" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                subresults = array_of_mocks(3, "subresult")
         
     | 
| 
      
 42 
     | 
    
         
            +
                
         
     | 
| 
      
 43 
     | 
    
         
            +
                @result.should_receive(:subresults).
         
     | 
| 
      
 44 
     | 
    
         
            +
                  any_number_of_times.and_return(subresults)
         
     | 
| 
      
 45 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[0], "Processor 0", :happy, "fake elements 0")
         
     | 
| 
      
 46 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[1], "Processor 1", :happy, "fake elements 1")
         
     | 
| 
      
 47 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[2], "Processor 2", :sad, "fake elements 2")
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                process_erb.should have_selector("body") do |body|
         
     | 
| 
      
 50 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 0 (happy path)")
         
     | 
| 
      
 51 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 0")
         
     | 
| 
      
 52 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 1 (happy path)")
         
     | 
| 
      
 53 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 1")
         
     | 
| 
      
 54 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 2 (sad path)")
         
     | 
| 
      
 55 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 2")
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
              
         
     | 
| 
      
 59 
     | 
    
         
            +
              it "should work with many processors with some success and some unset" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                subresults = array_of_mocks(3, "subresult")
         
     | 
| 
      
 61 
     | 
    
         
            +
                
         
     | 
| 
      
 62 
     | 
    
         
            +
                @result.should_receive(:subresults).
         
     | 
| 
      
 63 
     | 
    
         
            +
                  any_number_of_times.and_return(subresults)
         
     | 
| 
      
 64 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[0], "Processor 0", :happy, "fake elements 0")
         
     | 
| 
      
 65 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[1], "Processor 1", :happy, "fake elements 1")
         
     | 
| 
      
 66 
     | 
    
         
            +
                expect_unset_processor(subresults[2], "Processor 2", :happy)
         
     | 
| 
       35 
67 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                 
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                process_erb.should have_selector("body") do |body|
         
     | 
| 
      
 69 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 0 (happy path)")
         
     | 
| 
      
 70 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 0")
         
     | 
| 
      
 71 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 1 (happy path)")
         
     | 
| 
      
 72 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 1")
         
     | 
| 
      
 73 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 2 (happy path)")
         
     | 
| 
      
 74 
     | 
    
         
            +
                  body.should have_selector("p", :content => "Not executed.")
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
       39 
76 
     | 
    
         
             
              end
         
     | 
| 
       40 
77 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
              it "should work with many processors" do
         
     | 
| 
       42 
     | 
    
         
            -
                subresults =  
     | 
| 
      
 78 
     | 
    
         
            +
              it "should work with many processors with some success and some unneeded" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                subresults = array_of_mocks(3, "subresult")
         
     | 
| 
       43 
80 
     | 
    
         | 
| 
       44 
81 
     | 
    
         
             
                @result.should_receive(:subresults).
         
     | 
| 
       45 
82 
     | 
    
         
             
                  any_number_of_times.and_return(subresults)
         
     | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
       47 
     | 
    
         
            -
                 
     | 
| 
       48 
     | 
    
         
            -
                 
     | 
| 
      
 83 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[0], "Processor 0", :happy, "fake elements 0")
         
     | 
| 
      
 84 
     | 
    
         
            +
                expect_set_and_needed_processor(subresults[1], "Processor 1", :happy, "fake elements 1")
         
     | 
| 
      
 85 
     | 
    
         
            +
                expect_unneeded_processor(subresults[2], "Processor 2", :happy)
         
     | 
| 
       49 
86 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                 
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
                process_erb.should have_selector("body") do |body|
         
     | 
| 
      
 88 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 0 (happy path)")
         
     | 
| 
      
 89 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 0")
         
     | 
| 
      
 90 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 1 (happy path)")
         
     | 
| 
      
 91 
     | 
    
         
            +
                  body.should have_fake(:elements, "fake elements 1")
         
     | 
| 
      
 92 
     | 
    
         
            +
                  body.should have_selector("h3", :content => "Results from Processor 2 (happy path)")
         
     | 
| 
      
 93 
     | 
    
         
            +
                  body.should have_selector("p", :content => "Not executed.")
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
       57 
95 
     | 
    
         
             
              end
         
     | 
| 
       58 
96 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
              def  
     | 
| 
      
 97 
     | 
    
         
            +
              def expect_set_and_needed_processor(subresult, description, path_kind, rendered_elements)
         
     | 
| 
       60 
98 
     | 
    
         
             
                processor, elements = mock('processor'), mock('elements')
         
     | 
| 
       61 
99 
     | 
    
         | 
| 
       62 
100 
     | 
    
         
             
                subresult.should_receive(:processor).and_return(processor)
         
     | 
| 
       63 
101 
     | 
    
         
             
                processor.should_receive(:describe).with().and_return(description)
         
     | 
| 
      
 102 
     | 
    
         
            +
                subresult.stub_chain(:light, :unset?).and_return(false)
         
     | 
| 
      
 103 
     | 
    
         
            +
                subresult.stub_chain(:light, :unneeded?).and_return(false)
         
     | 
| 
      
 104 
     | 
    
         
            +
                subresult.should_receive(:path_kind).and_return(path_kind)
         
     | 
| 
       64 
105 
     | 
    
         
             
                subresult.should_receive(:relevant_elements).and_return(elements)
         
     | 
| 
       65 
106 
     | 
    
         
             
                @recursion.should_receive(:render).
         
     | 
| 
       66 
107 
     | 
    
         
             
                  with("detail_row/elements", :elements => elements).
         
     | 
| 
       67 
108 
     | 
    
         
             
                  and_return(fake(:elements, rendered_elements))
         
     | 
| 
       68 
109 
     | 
    
         
             
              end
         
     | 
| 
       69 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
              def expect_unset_processor(subresult, description, path_kind)
         
     | 
| 
      
 112 
     | 
    
         
            +
                processor, elements = mock('processor'), mock('elements')
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                subresult.should_receive(:processor).and_return(processor)
         
     | 
| 
      
 115 
     | 
    
         
            +
                processor.should_receive(:describe).with().and_return(description)
         
     | 
| 
      
 116 
     | 
    
         
            +
                subresult.stub_chain(:light, :unset?).and_return(true)
         
     | 
| 
      
 117 
     | 
    
         
            +
                subresult.stub_chain(:light, :unneeded?).and_return(false)
         
     | 
| 
      
 118 
     | 
    
         
            +
                subresult.should_receive(:path_kind).and_return(path_kind)
         
     | 
| 
      
 119 
     | 
    
         
            +
              end
         
     | 
| 
      
 120 
     | 
    
         
            +
                
         
     | 
| 
      
 121 
     | 
    
         
            +
              def expect_unneeded_processor(subresult, description, path_kind)
         
     | 
| 
      
 122 
     | 
    
         
            +
                processor, elements = mock('processor'), mock('elements')
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                subresult.should_receive(:processor).and_return(processor)
         
     | 
| 
      
 125 
     | 
    
         
            +
                processor.should_receive(:describe).with().and_return(description)
         
     | 
| 
      
 126 
     | 
    
         
            +
                subresult.stub_chain(:light, :unset?).and_return(false)
         
     | 
| 
      
 127 
     | 
    
         
            +
                subresult.stub_chain(:light, :unneeded?).and_return(true)
         
     | 
| 
      
 128 
     | 
    
         
            +
                subresult.should_receive(:path_kind).and_return(path_kind)
         
     | 
| 
      
 129 
     | 
    
         
            +
              end
         
     | 
| 
      
 130 
     | 
    
         
            +
                
         
     | 
| 
       70 
131 
     | 
    
         
             
              def result
         
     | 
| 
       71 
132 
     | 
    
         
             
                @result
         
     | 
| 
       72 
133 
     | 
    
         
             
              end
         
     |