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,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CIAT::Subresult do
|
4
|
+
before(:each) do
|
5
|
+
@elements = mock("elements")
|
6
|
+
@light = mock("light")
|
7
|
+
@processor = mock("processor")
|
8
|
+
|
9
|
+
@subtest_result = CIAT::Subresult.new(@elements, @light, @processor)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should look up relevant elements" do
|
13
|
+
test = mock("test")
|
14
|
+
names = [mock("name 0"), mock("name 1"), mock("name 2")]
|
15
|
+
relevants = [mock("element 0"), mock("element 1"), mock("element 2")]
|
16
|
+
|
17
|
+
@subtest_result.should_receive(:relevant_element_names).and_return(names)
|
18
|
+
@elements.should_receive(:element?).with(names[0]).and_return(true)
|
19
|
+
@elements.should_receive(:element).with(names[0]).and_return(relevants[0])
|
20
|
+
@elements.should_receive(:element?).with(names[1]).and_return(true)
|
21
|
+
@elements.should_receive(:element).with(names[1]).and_return(relevants[1])
|
22
|
+
@elements.should_receive(:element?).with(names[2]).and_return(true)
|
23
|
+
@elements.should_receive(:element).with(names[2]).and_return(relevants[2])
|
24
|
+
|
25
|
+
@subtest_result.relevant_elements.should == relevants
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have relevant element names" do
|
29
|
+
kind, hash, setting =
|
30
|
+
mock("kind"), mock("hash"), mock("setting")
|
31
|
+
names = mock("names")
|
32
|
+
|
33
|
+
@processor.should_receive(:kind).and_return(kind)
|
34
|
+
kind.should_receive(:element_name_hash).and_return(hash)
|
35
|
+
@light.should_receive(:setting).and_return(setting)
|
36
|
+
hash.should_receive(:[]).with(setting).and_return(names)
|
37
|
+
|
38
|
+
@subtest_result.relevant_element_names.should == names
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CIAT::SuiteBuilder do
|
4
|
+
include MockHelpers
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@options = {}
|
8
|
+
@default_builder = CIAT::SuiteBuilder.new(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should build default feedback" do
|
12
|
+
@default_builder.build_feedback.
|
13
|
+
should be_an_instance_of(CIAT::Feedback::Composite)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "making test files" do
|
17
|
+
it "should make test files" do
|
18
|
+
files = array_of_mocks(3, "files")
|
19
|
+
output_folder = mock("output folder")
|
20
|
+
test_files = array_of_mocks(3, "test file")
|
21
|
+
|
22
|
+
@default_builder.should_receive(:build_output_folder).
|
23
|
+
at_least(:once).and_return(output_folder)
|
24
|
+
CIAT::TestFile.should_receive(:new).
|
25
|
+
with(files[0], output_folder).and_return(test_files[0])
|
26
|
+
CIAT::TestFile.should_receive(:new).
|
27
|
+
with(files[1], output_folder).and_return(test_files[1])
|
28
|
+
CIAT::TestFile.should_receive(:new).
|
29
|
+
with(files[2], output_folder).and_return(test_files[2])
|
30
|
+
|
31
|
+
@default_builder.make_test_files(files).should == test_files
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should complain if no test files to make" do
|
35
|
+
lambda {
|
36
|
+
@default_builder.make_test_files([])
|
37
|
+
}.should raise_error(IOError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "getting and processing test files" do
|
42
|
+
it "should get filename from filenames option" do
|
43
|
+
files = mock("files")
|
44
|
+
test_files = mock("test files")
|
45
|
+
|
46
|
+
options[:files] = files
|
47
|
+
@default_builder.should_receive(:make_test_files).
|
48
|
+
with(files).and_return(test_files)
|
49
|
+
|
50
|
+
@default_builder.build_test_files.should == test_files
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should get filenames from folder" do
|
54
|
+
input_folder, pattern = mock("input folder"), mock("pattern")
|
55
|
+
files = mock("files")
|
56
|
+
output_folder = mock("output folder")
|
57
|
+
test_files = mock("test files")
|
58
|
+
|
59
|
+
options[:folder] = input_folder
|
60
|
+
options[:pattern] = pattern
|
61
|
+
File.should_receive(:join).with(input_folder, "**", pattern).
|
62
|
+
and_return("the full path")
|
63
|
+
Dir.should_receive(:[]).with("the full path").and_return(files)
|
64
|
+
@default_builder.should_receive(:make_test_files).
|
65
|
+
with(files).and_return(test_files)
|
66
|
+
|
67
|
+
@default_builder.build_test_files.should == test_files
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe CIAT::Suite do
|
4
|
+
include MockHelpers
|
5
|
+
|
6
|
+
it "should construct with suite builder" do
|
7
|
+
options = mock("options")
|
8
|
+
suite_builder = mock("suite builder")
|
9
|
+
processors, output_folder, test_files, feedback =
|
10
|
+
mock("processors"), mock("output folder"),
|
11
|
+
mock("test files"), mock("feedback")
|
12
|
+
suite = mock("suite")
|
13
|
+
|
14
|
+
CIAT::SuiteBuilder.should_receive(:new).
|
15
|
+
with(options).and_return(suite_builder)
|
16
|
+
suite_builder.should_receive(:build_processors).and_return(processors)
|
17
|
+
suite_builder.should_receive(:build_output_folder).
|
18
|
+
and_return(output_folder)
|
19
|
+
suite_builder.should_receive(:build_test_files).and_return(test_files)
|
20
|
+
suite_builder.should_receive(:build_feedback).and_return(feedback)
|
21
|
+
CIAT::Suite.should_receive(:new).
|
22
|
+
with(processors, output_folder, test_files, feedback).and_return(suite)
|
23
|
+
|
24
|
+
CIAT::Suite.build(options).should == suite
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "the top-level function to run the tests" do
|
28
|
+
before(:each) do
|
29
|
+
@processors = array_of_mocks(3, "processor")
|
30
|
+
@output_folder = mock("output folder")
|
31
|
+
@test_files = array_of_mocks(3, "test file")
|
32
|
+
@feedback = mock("feedback")
|
33
|
+
@suite = CIAT::Suite.new(
|
34
|
+
@processors, @output_folder, @test_files, @feedback
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a size based on the number of test files" do
|
39
|
+
@suite.stub_chain(:test_files, :size).and_return(42)
|
40
|
+
|
41
|
+
@suite.size.should == 42
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should run tests on test files" do
|
45
|
+
folder = "THE_FOLDER"
|
46
|
+
results = array_of_mocks(3, "result")
|
47
|
+
|
48
|
+
@feedback.should_receive(:pre_tests).with(@suite)
|
49
|
+
expect_create_and_run_test(@test_files[0], results[0])
|
50
|
+
expect_create_and_run_test(@test_files[1], results[1])
|
51
|
+
expect_create_and_run_test(@test_files[2], results[2])
|
52
|
+
@feedback.should_receive(:post_tests).with(@suite)
|
53
|
+
|
54
|
+
@suite.run.should == results
|
55
|
+
@suite.results.should == results
|
56
|
+
end
|
57
|
+
|
58
|
+
def expect_create_and_run_test(test_file, result)
|
59
|
+
test = mock("test for #{test_file}")
|
60
|
+
@suite.should_receive(:create_test).with(test_file).and_return(test)
|
61
|
+
test.should_receive(:run).and_return(result)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CIAT::TestElement do
|
4
|
+
before(:each) do
|
5
|
+
@name = mock("name")
|
6
|
+
@filename = mock("filename")
|
7
|
+
@content = mock("content")
|
8
|
+
@element = CIAT::TestElement.new(@name, @filename, @content)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "treating as a file" do
|
12
|
+
it "should be written as a file when interesting content" do
|
13
|
+
@element.should_receive(:write_file).with(@filename, @content)
|
14
|
+
|
15
|
+
@element.as_file.should == @filename
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should just return filename for pending content" do
|
19
|
+
test_element = CIAT::TestElement.new(:some_name, @filename, nil)
|
20
|
+
|
21
|
+
test_element.should_not_receive(:write_file)
|
22
|
+
|
23
|
+
test_element.as_file.should == @filename
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "having content" do
|
28
|
+
it "should have cached content" do
|
29
|
+
@element.content.should == @content
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should read when content is empty" do
|
33
|
+
read_content = mock("read content")
|
34
|
+
test_element = CIAT::TestElement.new(:some_name, @filename, nil)
|
35
|
+
|
36
|
+
test_element.should_receive(:read_file).
|
37
|
+
with(@filename).and_return(read_content)
|
38
|
+
|
39
|
+
test_element.content.should == read_content
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "finding template files" do
|
44
|
+
it "should have a template file based on the name" do
|
45
|
+
entry = mock("entry")
|
46
|
+
|
47
|
+
@element.should_receive(:yaml_entry).at_least(:once).and_return(entry)
|
48
|
+
entry.should_receive(:[]).with("template").and_return("filename")
|
49
|
+
|
50
|
+
@element.template.should == File.join("elements", "filename")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should raise an error when name is missing from YAML file" do
|
54
|
+
@element.should_receive(:yaml_entry).and_return(nil)
|
55
|
+
|
56
|
+
lambda { @element.template }.should raise_error
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should describe the test element" do
|
61
|
+
entry, description = mock("entry"), mock("description")
|
62
|
+
|
63
|
+
@element.should_receive(:yaml_entry).and_return(entry)
|
64
|
+
entry.should_receive(:[]).with("description").and_return(description)
|
65
|
+
|
66
|
+
@element.describe.should == description
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should get a YAML entry" do
|
70
|
+
metadata, entry = mock("metadata"), mock("entry")
|
71
|
+
|
72
|
+
@element.should_receive(:metadata).and_return(metadata)
|
73
|
+
@name.should_receive(:to_s).at_least(:once).and_return("name")
|
74
|
+
metadata.should_receive(:[]).with("name").and_return(entry)
|
75
|
+
|
76
|
+
@element.yaml_entry.should == entry
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe CIAT::TestFile do
|
4
|
+
before(:each) do
|
5
|
+
File.should_receive(:exists?).with(anything).
|
6
|
+
any_number_of_times.and_return(true)
|
7
|
+
@test_file = CIAT::TestFile.new(mock("filename"), mock("output folder"))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "processing test file" do
|
11
|
+
it "should split and write" do
|
12
|
+
raw_elements = {
|
13
|
+
:e0 => mock("raw element 0"), :e1 => mock("raw element 1"),
|
14
|
+
:e2 => mock("raw element 2") }
|
15
|
+
filenames = [mock("filename 0"), mock("filename 1"), mock("filename 2")]
|
16
|
+
elements = {
|
17
|
+
:e0 => mock("element 0"), :e1 => mock("element 1"),
|
18
|
+
:e2 => mock("element 2") }
|
19
|
+
|
20
|
+
@test_file.should_receive(:split).and_return(raw_elements)
|
21
|
+
@test_file.should_receive(:filename).with(:e0).and_return(filenames[0])
|
22
|
+
@test_file.should_receive(:filename).with(:e1).and_return(filenames[1])
|
23
|
+
@test_file.should_receive(:filename).with(:e2).and_return(filenames[2])
|
24
|
+
CIAT::TestElement.should_receive(:new).
|
25
|
+
with(:e0, filenames[0], raw_elements[:e0]).and_return(elements[:e0])
|
26
|
+
CIAT::TestElement.should_receive(:new).
|
27
|
+
with(:e1, filenames[1], raw_elements[:e1]).and_return(elements[:e1])
|
28
|
+
CIAT::TestElement.should_receive(:new).
|
29
|
+
with(:e2, filenames[2], raw_elements[:e2]).and_return(elements[:e2])
|
30
|
+
|
31
|
+
@test_file.process.should == elements
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "splitting a test file" do
|
36
|
+
it "should split just a description" do
|
37
|
+
expect_file_content("description only\n")
|
38
|
+
@test_file.split.should == { :description => "description only\n" }
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should split description and something else" do
|
42
|
+
expect_file_content("description\n", "==== tag\n", "content\n")
|
43
|
+
@test_file.split.should == { :description => "description\n", :tag => "content\n" }
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should split the test file" do
|
47
|
+
expect_file_content("d\n", "==== source\n", "s\n",
|
48
|
+
"==== compilation_expected \n", "p\n",
|
49
|
+
"==== output_expected\n", "o\n")
|
50
|
+
@test_file.split.should == { :description => "d\n",
|
51
|
+
:source => "s\n", :compilation_expected => "p\n", :output_expected => "o\n" }
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should allow spaces in element name" do
|
55
|
+
expect_file_content("description\n" , "==== element name\n", "content\n")
|
56
|
+
@test_file.split.should == {
|
57
|
+
:description => "description\n", :element_name => "content\n" }
|
58
|
+
end
|
59
|
+
|
60
|
+
def expect_file_content(*content)
|
61
|
+
@test_file.should_receive(:read).and_return(content)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe CIAT::TestFile, "generating actual file names" do
|
67
|
+
before(:each) do
|
68
|
+
File.should_receive(:exists?).with(anything).
|
69
|
+
any_number_of_times.and_return(true)
|
70
|
+
@output_folder = "outie"
|
71
|
+
@test_file = CIAT::TestFile.new("ciat/phile.ciat", @output_folder)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return the original filename" do
|
75
|
+
@test_file.filename(:ciat).should == "ciat/phile.ciat"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should work with no modifiers" do
|
79
|
+
@test_file.filename().should == "outie/ciat/phile"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should work with multiple modifiers" do
|
83
|
+
@test_file.filename("one", "two", "three").should == "outie/ciat/phile_one_two_three"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe CIAT::TestFile, "constructor errors" do
|
88
|
+
it "should complain about a missing file" do
|
89
|
+
File.should_receive(:exists?).
|
90
|
+
with("does-not-exist.ciat").and_return(false)
|
91
|
+
|
92
|
+
lambda {
|
93
|
+
CIAT::TestFile.new("does-not-exist.ciat", nil)
|
94
|
+
}.should raise_error(IOError)
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe CIAT::Test do
|
4
|
+
before(:each) do
|
5
|
+
@filename = mock("filename")
|
6
|
+
@test_file = mock("test file")
|
7
|
+
@processors = [mock("p 0"), mock("p 1"), mock("p 2")]
|
8
|
+
@differ = mock("differ")
|
9
|
+
@feedback = mock("feedback")
|
10
|
+
@test = CIAT::Test.new(@test_file, @processors, @feedback)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "running a test" do
|
14
|
+
it "should run a complete test" do
|
15
|
+
subresults = mock("subresults")
|
16
|
+
result = mock("result")
|
17
|
+
|
18
|
+
@test.should_receive(:run_processors).and_return(subresults)
|
19
|
+
CIAT::TestResult.should_receive(:new).with(@test, subresults).
|
20
|
+
and_return(result)
|
21
|
+
|
22
|
+
@test.run.should == result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "running processors" do
|
27
|
+
before(:each) do
|
28
|
+
@subresults = [mock("subresult 0"),
|
29
|
+
mock("subresult 1"), mock("subresult 2")]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should run just the first processor" do
|
33
|
+
light = mock("light", :green? => false)
|
34
|
+
|
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])
|
43
|
+
|
44
|
+
@test.run_processors.should == @subresults
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should run just the first two processors" do
|
48
|
+
lights = [mock("light 0", :green? => true),
|
49
|
+
mock("light 1", :green? => false)]
|
50
|
+
|
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
|
63
|
+
end
|
64
|
+
|
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
|
83
|
+
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
|
+
|
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)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should return specified element" do
|
104
|
+
element = mock("element")
|
105
|
+
|
106
|
+
@elements.should_receive(:[]).with(:foo).and_return(element)
|
107
|
+
|
108
|
+
@test.element(:foo).should == element
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return specified element with multi-word name" do
|
112
|
+
element = mock("element")
|
113
|
+
|
114
|
+
@elements.should_receive(:[]).with(:foo_bar_joe).and_return(element)
|
115
|
+
|
116
|
+
@test.element(:foo, :bar, :joe).should == element
|
117
|
+
end
|
118
|
+
|
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)
|
123
|
+
|
124
|
+
@test.element?(:foo, :bar, :joe).should == exists
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|