ciat 0.4.8 → 0.4.9
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/README.rdoc +4 -4
- data/lib/ciat.rb +3 -5
- data/lib/ciat/differs/html_differ.rb +3 -4
- data/lib/ciat/erb_helpers.rb +6 -4
- data/lib/ciat/feedback/composite.rb +2 -2
- data/lib/ciat/feedback/feedback_counter.rb +2 -2
- data/lib/ciat/feedback/html_feedback.rb +25 -8
- data/lib/ciat/feedback/html_feedback_builder.rb +28 -0
- data/lib/ciat/feedback/return_status.rb +1 -1
- data/lib/ciat/feedback/standard_output.rb +1 -1
- data/lib/ciat/io.rb +17 -0
- data/lib/ciat/processors/basic_processing.rb +21 -30
- data/lib/ciat/{executors → processors}/java.rb +7 -8
- data/lib/ciat/{executors → processors}/parrot.rb +9 -10
- data/lib/ciat/rake_task.rb +1 -1
- data/lib/ciat/subresult.rb +20 -0
- data/lib/ciat/suite.rb +27 -38
- data/lib/ciat/suite_builder.rb +54 -0
- data/lib/ciat/test.rb +32 -18
- data/lib/ciat/test_element.rb +7 -2
- data/lib/ciat/{crate.rb → test_file.rb} +24 -16
- data/lib/ciat/test_result.rb +24 -0
- data/lib/ciat/traffic_light.rb +6 -0
- data/lib/templates/detail_row.html.erb +5 -4
- data/lib/templates/group_header.html.erb +2 -2
- data/lib/templates/report.html.erb +1 -1
- data/lib/templates/summary_row.html.erb +4 -4
- data/spec/ciat/erb_helpers_spec.rb +71 -0
- data/spec/ciat/feedback/composite_spec.rb +28 -0
- data/spec/ciat/feedback/feedback_counter_spec.rb +91 -0
- data/spec/ciat/feedback/html_feedback_spec.rb +48 -0
- data/spec/ciat/feedback/return_status_spec.rb +90 -0
- data/spec/ciat/feedback/standard_output_spec.rb +109 -0
- data/spec/ciat/processors/basic_processing_spec.rb +146 -0
- data/spec/ciat/processors/java_spec.rb +31 -0
- data/spec/ciat/processors/parrot_spec.rb +40 -0
- data/spec/ciat/subresult_spec.rb +40 -0
- data/spec/ciat/suite_builder_spec.rb +70 -0
- data/spec/ciat/suite_spec.rb +64 -0
- data/spec/ciat/test_element_spec.rb +78 -0
- data/spec/ciat/test_file_spec.rb +96 -0
- data/spec/ciat/test_spec.rb +127 -0
- data/spec/ciat/traffic_light_spec.rb +41 -0
- data/spec/ciat_spec.rb +2 -0
- data/spec/spec_helper.rb +134 -0
- data/spec/templates/detail_row/elements_html_erb_spec.rb +60 -0
- data/spec/templates/detail_row_html_erb_spec.rb +73 -0
- data/spec/templates/elements/diff_html_erb_spec.rb +28 -0
- data/spec/templates/elements/plain_element_html_erb_spec.rb +36 -0
- data/spec/templates/report_html_erb_spec.rb +85 -0
- data/spec/templates/summary_row_html_erb_spec.rb +93 -0
- data/spec/templates/test_numbers_html_erb_spec.rb +82 -0
- metadata +54 -32
- data/History.txt +0 -96
- data/Rakefile +0 -40
- data/ciat.gemspec +0 -53
- data/lib/ciat/cargo.rb +0 -55
- data/lib/ciat/compilers/java.rb +0 -54
- data/lib/ciat/processors/copy.rb +0 -37
- data/lib/ciat/version.rb +0 -7
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe CIAT::TrafficLight do
|
4
|
+
before(:each) do
|
5
|
+
@traffic_light = CIAT::TrafficLight.new
|
6
|
+
end
|
7
|
+
|
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
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should set and query red" do
|
27
|
+
@traffic_light.red?.should == false
|
28
|
+
@traffic_light.red!
|
29
|
+
@traffic_light.red?.should == true
|
30
|
+
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
|
40
|
+
end
|
41
|
+
end
|
data/spec/ciat_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
begin
|
3
|
+
require 'spec'
|
4
|
+
rescue LoadError
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
require 'ciat'
|
11
|
+
|
12
|
+
module ERBHelpers
|
13
|
+
def build_erb(filename)
|
14
|
+
erb = ERB.new(File.read(filename))
|
15
|
+
erb.filename = File.expand_path(filename)
|
16
|
+
erb
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_erb
|
20
|
+
Hpricot(erb.result(binding))
|
21
|
+
end
|
22
|
+
|
23
|
+
def replace_tabs(string)
|
24
|
+
string
|
25
|
+
end
|
26
|
+
|
27
|
+
def light_to_sentence(prefix, light)
|
28
|
+
prefix
|
29
|
+
end
|
30
|
+
|
31
|
+
def title(text)
|
32
|
+
text
|
33
|
+
end
|
34
|
+
|
35
|
+
def render(file, locals)
|
36
|
+
@recursion.render(file, locals)
|
37
|
+
end
|
38
|
+
|
39
|
+
def fake(what, content)
|
40
|
+
"<div class=\"fake\"><div id=\"#{what}\">#{content}</div></div>"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module MockHelpers
|
45
|
+
def array_of_mocks(count, name)
|
46
|
+
(1..count).to_a.map do |i|
|
47
|
+
mock(name + " " + i.to_s)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
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
|
+
class HaveInnerHtml
|
73
|
+
def initialize(xpath, expected)
|
74
|
+
@xpath = xpath
|
75
|
+
@expected = expected
|
76
|
+
end
|
77
|
+
|
78
|
+
def matches?(target)
|
79
|
+
@target = target
|
80
|
+
(@target/@xpath).inner_html.match(@expected)
|
81
|
+
end
|
82
|
+
|
83
|
+
def failure_message
|
84
|
+
"expected #{@target.inspect} to have '#{@expected}' at #{@xpath}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def negative_failure_message
|
88
|
+
"expected #{@target.inspect} not to have source '#{@expected}' at #{@xpath}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
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
|
+
def have_inner_html(xpath, expected)
|
116
|
+
HaveInnerHtml.new(xpath, expected)
|
117
|
+
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
|
+
|
127
|
+
def have_fake(type, expected)
|
128
|
+
have_inner_html("//div[@class=\"fake\"]/div[@id=\"#{type}\"]", expected)
|
129
|
+
end
|
130
|
+
|
131
|
+
def have_diff_table(expected)
|
132
|
+
have_inner_html("table", /Expected(.|\s)*Generated(.|\s)*#{expected}/)
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'hpricot'
|
4
|
+
|
5
|
+
describe "element output in detail row" do
|
6
|
+
include ERBHelpers
|
7
|
+
include CustomDetailRowMatchers
|
8
|
+
|
9
|
+
attr_reader :erb
|
10
|
+
attr_reader :recursion
|
11
|
+
attr_reader :processor
|
12
|
+
attr_reader :test_file
|
13
|
+
attr_reader :elements
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
@recursion = mock("recursion")
|
17
|
+
@processor = mock('processor')
|
18
|
+
@test_file = mock("test file")
|
19
|
+
@erb = ERB.new(File.read("lib/templates/detail_row/elements.html.erb"))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle no elements" do
|
23
|
+
@elements = []
|
24
|
+
|
25
|
+
doc = process_erb
|
26
|
+
doc.should have_inner_html("", /\s*/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should process one used element" do
|
30
|
+
@elements = [mock("element")]
|
31
|
+
template = mock("template")
|
32
|
+
|
33
|
+
@elements[0].should_receive(:template).and_return(template)
|
34
|
+
@recursion.should_receive(:render).
|
35
|
+
with(template, :element => @elements[0]).and_return(fake(:element, "faked element"))
|
36
|
+
|
37
|
+
doc = process_erb
|
38
|
+
doc.should have_fake(:element, "faked element")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should process many elements" do
|
42
|
+
@elements = [mock("element 0"), mock("element 1"), mock("element 2")]
|
43
|
+
templates = [mock("template 0"), mock("template 1"), mock("template 2")]
|
44
|
+
|
45
|
+
@elements[0].should_receive(:template).and_return(templates[0])
|
46
|
+
@recursion.should_receive(:render).
|
47
|
+
with(templates[0], :element => @elements[0]).and_return(fake(:element0, "faked 0"))
|
48
|
+
@elements[1].should_receive(:template).and_return(templates[1])
|
49
|
+
@recursion.should_receive(:render).
|
50
|
+
with(templates[1], :element => @elements[1]).and_return(fake(:element1, "faked 1"))
|
51
|
+
@elements[2].should_receive(:template).and_return(templates[2])
|
52
|
+
@recursion.should_receive(:render).
|
53
|
+
with(templates[2], :element => @elements[2]).and_return(fake(:element2, "faked 2"))
|
54
|
+
|
55
|
+
doc = process_erb
|
56
|
+
doc.should have_fake(:element0, "faked 0")
|
57
|
+
doc.should have_fake(:element1, "faked 1")
|
58
|
+
doc.should have_fake(:element2, "faked 2")
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'hpricot'
|
4
|
+
|
5
|
+
describe "detail row of test report" do
|
6
|
+
include ERBHelpers
|
7
|
+
include CustomDetailRowMatchers
|
8
|
+
|
9
|
+
attr_reader :erb
|
10
|
+
attr_reader :recursion
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@result = mock('result')
|
14
|
+
@test_file = mock('test file')
|
15
|
+
@recursion = mock('recursion')
|
16
|
+
@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
|
+
end
|
21
|
+
|
22
|
+
it "should work with no subresults" do
|
23
|
+
@result.should_receive(:subresults).at_least(:once).and_return([])
|
24
|
+
|
25
|
+
doc = process_erb
|
26
|
+
doc.should have_colspan(1)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should work with one processor" do
|
30
|
+
subresult = mock('subresult')
|
31
|
+
|
32
|
+
@result.should_receive(:subresults).
|
33
|
+
any_number_of_times.and_return([subresult])
|
34
|
+
expect_red_or_green(subresult, "The Processor", "fake elements")
|
35
|
+
|
36
|
+
doc = process_erb
|
37
|
+
doc.should have_description("h3", "Results from The Processor")
|
38
|
+
doc.should have_fake(:elements, "fake elements")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should work with many processors" do
|
42
|
+
subresults = [mock('subresult 0'), mock('subresult 1'), mock('subresult 2')]
|
43
|
+
|
44
|
+
@result.should_receive(:subresults).
|
45
|
+
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")
|
49
|
+
|
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")
|
57
|
+
end
|
58
|
+
|
59
|
+
def expect_red_or_green(subresult, description, rendered_elements)
|
60
|
+
processor, elements = mock('processor'), mock('elements')
|
61
|
+
|
62
|
+
subresult.should_receive(:processor).and_return(processor)
|
63
|
+
processor.should_receive(:describe).with().and_return(description)
|
64
|
+
subresult.should_receive(:relevant_elements).and_return(elements)
|
65
|
+
@recursion.should_receive(:render).
|
66
|
+
with("detail_row/elements", :elements => elements).
|
67
|
+
and_return(fake(:elements, rendered_elements))
|
68
|
+
end
|
69
|
+
|
70
|
+
def result
|
71
|
+
@result
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'hpricot'
|
4
|
+
|
5
|
+
describe "checked-files output in detail row" do
|
6
|
+
include ERBHelpers
|
7
|
+
include CustomDetailRowMatchers
|
8
|
+
|
9
|
+
attr_reader :erb
|
10
|
+
attr_reader :element
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@erb = ERB.new(File.read("lib/templates/elements/diff.html.erb"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should process one checked file" do
|
17
|
+
@element = mock("element")
|
18
|
+
|
19
|
+
@element.should_receive(:name).and_return(:element)
|
20
|
+
@element.should_receive(:filename).and_return("the filename")
|
21
|
+
@element.should_receive(:describe).at_least(:once).and_return("the description")
|
22
|
+
@element.should_receive(:content).and_return("the diff")
|
23
|
+
|
24
|
+
doc = process_erb
|
25
|
+
doc.should have_description("h4", "the description")
|
26
|
+
doc.should have_diff_table("the diff")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'hpricot'
|
4
|
+
|
5
|
+
describe "element output in detail row" do
|
6
|
+
include ERBHelpers
|
7
|
+
include CustomDetailRowMatchers
|
8
|
+
|
9
|
+
attr_reader :erb
|
10
|
+
attr_reader :element
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@erb = ERB.new(File.read("lib/templates/elements/plain.html.erb"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should process a plain element" do
|
17
|
+
@element = mock("element")
|
18
|
+
|
19
|
+
@element.should_receive(:name).and_return(:the_name)
|
20
|
+
@element.should_receive(:filename).and_return("the filename")
|
21
|
+
@element.should_receive(:describe).at_least(:once).and_return("the description")
|
22
|
+
@element.should_receive(:content).and_return("the content")
|
23
|
+
|
24
|
+
doc = process_erb
|
25
|
+
doc.should have_element_description(:the_name, "the description")
|
26
|
+
doc.should have_element_content(:the_name, "the content")
|
27
|
+
end
|
28
|
+
|
29
|
+
def have_element_description(element, expected_description)
|
30
|
+
have_inner_html("div.#{element} h4", expected_description)
|
31
|
+
end
|
32
|
+
|
33
|
+
def have_element_content(element, expected_content)
|
34
|
+
have_inner_html("div.#{element} pre", expected_content)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
require 'hpricot'
|
4
|
+
|
5
|
+
describe "report" do
|
6
|
+
include ERBHelpers
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@elements = mock("elements")
|
10
|
+
@recursion = mock("recursion")
|
11
|
+
|
12
|
+
@processors = []
|
13
|
+
@results = []
|
14
|
+
@report_title = "CIAT Report"
|
15
|
+
@counter = mock("counter")
|
16
|
+
@size = mock("size")
|
17
|
+
|
18
|
+
@recursion.stub!(:render).with("test_numbers", :counter => @counter, :size => @size)
|
19
|
+
@recursion.stub!(:new_grouping?).with(:anything).and_return(false)
|
20
|
+
|
21
|
+
@erb = ERB.new(File.read("lib/templates/report.html.erb"))
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have test numbers" do
|
25
|
+
@recursion.should_receive(:render).
|
26
|
+
with("test_numbers", :counter => @counter, :size => @size).
|
27
|
+
and_return("<h6>The Test Numbers</h6>")
|
28
|
+
|
29
|
+
(process_erb/"h6").inner_text.should == "The Test Numbers"
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "writing table header" do
|
33
|
+
it "should work with no processors" do
|
34
|
+
@processors = []
|
35
|
+
|
36
|
+
(process_erb/"tr#header th").inner_text.should == "Description"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should work with several processors" do
|
40
|
+
@processors = [mock("p 0"), mock("p 1"), mock("p 2")]
|
41
|
+
|
42
|
+
@processors[0].should_receive(:describe).and_return("d0")
|
43
|
+
@processors[1].should_receive(:describe).and_return("d1")
|
44
|
+
@processors[2].should_receive(:describe).and_return("d2")
|
45
|
+
|
46
|
+
(process_erb/"tr#header th").inner_text.should == "Description" + "d0" + "d1" + "d2"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "writing table rows" do
|
51
|
+
def new_grouping?(result)
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should write summary rows" do
|
56
|
+
@results = [mock("r 0"), mock("r 1"), mock("r 2")]
|
57
|
+
|
58
|
+
@recursion.should_receive(:render).
|
59
|
+
with("summary_row", :result => @results[0])
|
60
|
+
@recursion.should_receive(:render).
|
61
|
+
with("summary_row", :result => @results[1])
|
62
|
+
@recursion.should_receive(:render).
|
63
|
+
with("summary_row", :result => @results[2])
|
64
|
+
@recursion.should_receive(:render).
|
65
|
+
with("detail_row", :result => @results[0])
|
66
|
+
@recursion.should_receive(:render).
|
67
|
+
with("detail_row", :result => @results[1])
|
68
|
+
@recursion.should_receive(:render).
|
69
|
+
with("detail_row", :result => @results[2])
|
70
|
+
|
71
|
+
process_erb
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def process_erb
|
76
|
+
Hpricot(@erb.result(binding))
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_reader :processors
|
80
|
+
attr_reader :results
|
81
|
+
attr_reader :report_title
|
82
|
+
attr_reader :counter
|
83
|
+
attr_reader :size
|
84
|
+
|
85
|
+
end
|