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.
Files changed (50) hide show
  1. data/lib/ciat.rb +1 -2
  2. data/lib/ciat/{test_file.rb → ciat_file.rb} +21 -9
  3. data/lib/ciat/erb_helpers.rb +6 -1
  4. data/lib/ciat/feedback/feedback_counter.rb +11 -19
  5. data/lib/ciat/feedback/return_status.rb +6 -2
  6. data/lib/ciat/feedback/standard_output.rb +7 -2
  7. data/lib/ciat/processors/compilation_interpreter.rb +20 -7
  8. data/lib/ciat/processors/compiler.rb +38 -15
  9. data/lib/ciat/processors/interpreter.rb +28 -7
  10. data/lib/ciat/processors/java.rb +2 -8
  11. data/lib/ciat/processors/parrot.rb +0 -3
  12. data/lib/ciat/subresult.rb +14 -4
  13. data/lib/ciat/subtest.rb +83 -0
  14. data/lib/ciat/suite.rb +9 -9
  15. data/lib/ciat/suite_builder.rb +5 -5
  16. data/lib/ciat/test.rb +36 -28
  17. data/lib/ciat/test_result.rb +2 -2
  18. data/lib/ciat/traffic_light.rb +5 -14
  19. data/lib/data/ciat.css +14 -2
  20. data/lib/data/elements.yml +8 -2
  21. data/lib/templates/detail_row.html.erb +10 -4
  22. data/lib/templates/report.html.erb +5 -5
  23. data/lib/templates/summary_row.html.erb +5 -3
  24. data/spec/ciat/{test_file_spec.rb → ciat_file_spec.rb} +51 -19
  25. data/spec/ciat/erb_helpers_spec.rb +8 -13
  26. data/spec/ciat/feedback/feedback_counter_spec.rb +37 -57
  27. data/spec/ciat/feedback/return_status_spec.rb +67 -61
  28. data/spec/ciat/feedback/standard_output_spec.rb +21 -15
  29. data/spec/ciat/processors/compilation_interpreter_spec.rb +12 -0
  30. data/spec/ciat/processors/compiler_spec.rb +12 -0
  31. data/spec/ciat/processors/interpreter_spec.rb +12 -0
  32. data/spec/ciat/processors/java_spec.rb +0 -10
  33. data/spec/ciat/processors/parrot_spec.rb +0 -10
  34. data/spec/ciat/processors/shared_examples_for_element_names.rb +27 -0
  35. data/spec/ciat/rake_task_spec.rb +65 -0
  36. data/spec/ciat/subresult_spec.rb +13 -12
  37. data/spec/ciat/subtest_spec.rb +199 -0
  38. data/spec/ciat/suite_builder_spec.rb +17 -17
  39. data/spec/ciat/suite_spec.rb +13 -13
  40. data/spec/ciat/test_result_spec.rb +36 -0
  41. data/spec/ciat/test_spec.rb +73 -83
  42. data/spec/ciat/traffic_light_spec.rb +21 -31
  43. data/spec/spec_helper.rb +16 -53
  44. data/spec/templates/detail_row/elements_html_erb_spec.rb +3 -4
  45. data/spec/templates/detail_row_html_erb_spec.rb +84 -23
  46. data/spec/templates/elements/diff_html_erb_spec.rb +5 -3
  47. data/spec/templates/summary_row_html_erb_spec.rb +21 -14
  48. metadata +13 -7
  49. data/lib/ciat/processors/basic_processing.rb +0 -55
  50. 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
@@ -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
- @test_file = mock("test file")
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(@test_file, @processors, @feedback)
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(:run_processors).and_return(subresults)
19
- CIAT::TestResult.should_receive(:new).with(@test, subresults).
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
- @subresults = [mock("subresult 0"),
29
- mock("subresult 1"), mock("subresult 2")]
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
- light = mock("light", :green? => false)
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
- @processors[0].should_receive(:process).with(@test).
36
- and_return(light)
37
- @test.should_receive(:subresult).with(@processors[0], light).
38
- and_return(@subresults[0])
39
- @test.should_receive(:subresult).with(@processors[1]).
40
- and_return(@subresults[1])
41
- @test.should_receive(:subresult).with(@processors[2]).
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.run_processors.should == @subresults
48
+ @test.run_subtests.should == @subresults
45
49
  end
46
-
50
+
47
51
  it "should run just the first two processors" do
48
- lights = [mock("light 0", :green? => true),
49
- mock("light 1", :green? => false)]
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
- @processors[0].should_receive(:process).with(@test).
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 just all processors" do
66
- lights = [mock("light 0", :green? => true),
67
- mock("light 1", :green? => true), mock("light 2")]
68
-
69
- @processors[0].should_receive(:process).with(@test).
70
- and_return(lights[0])
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
- @test.subresult(processor, light).should == subresult
95
- end
96
-
97
- describe "processing elements" do
98
- before(:each) do
99
- @elements = mock("elements")
100
- @test.should_receive(:elements).and_return(@elements)
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
- it "should return specified element" do
104
- element = mock("element")
105
-
106
- @elements.should_receive(:[]).with(:foo).and_return(element)
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
- @test.element(:foo).should == element
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
- @elements.should_receive(:[]).with(:foo_bar_joe).and_return(element)
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
- @test.element(:foo, :bar, :joe).should == element
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
- it "should check to see if element exists" do
120
- exists = mock("a boolean")
121
-
122
- @elements.should_receive(:has_key?).with(:foo_bar_joe).and_return(exists)
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
- @test.element?(:foo, :bar, :joe).should == exists
125
- end
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
- before(:each) do
5
- @traffic_light = CIAT::TrafficLight.new
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 initially be unset" do
9
- @traffic_light.unset?.should == true
10
- @traffic_light.green!
11
- @traffic_light.unset?.should == false
12
- end
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 set and query red" do
27
- @traffic_light.red?.should == false
28
- @traffic_light.red!
29
- @traffic_light.red?.should == true
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 not switch away from yellow" do
33
- @traffic_light.yellow!
34
- @traffic_light.yellow?.should == true
35
- @traffic_light.red!
36
- @traffic_light.green!
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
@@ -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
- Hpricot(erb.result(binding))
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
- @test_file = mock("test file")
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.should have_inner_html("", /\s*/)
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
- @test_file = mock('test file')
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
- doc = process_erb
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
- expect_red_or_green(subresult, "The Processor", "fake elements")
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
- doc = process_erb
37
- doc.should have_description("h3", "Results from The Processor")
38
- doc.should have_fake(:elements, "fake elements")
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 = [mock('subresult 0'), mock('subresult 1'), mock('subresult 2')]
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
- expect_red_or_green(subresults[0], "Processor 0", "fake elements 0")
47
- expect_red_or_green(subresults[1], "Processor 1", "fake elements 1")
48
- expect_red_or_green(subresults[2], "Processor 2", "fake elements 2")
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
- doc = process_erb
51
- doc.should have_description("h3", "Results from Processor 0")
52
- doc.should have_fake(:elements, "fake elements 0")
53
- doc.should have_description("h3", "Results from Processor 1")
54
- doc.should have_fake(:elements, "fake elements 1")
55
- doc.should have_description("h3", "Results from Processor 2")
56
- doc.should have_fake(:elements, "fake elements 2")
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 expect_red_or_green(subresult, description, rendered_elements)
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