greenpepper-ruby 0.0.1
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/bin/greenpepperize +71 -0
- data/bin/greenpepperrails +33 -0
- data/bin/greenpepperruby +15 -0
- data/data/greenpepper.rake +37 -0
- data/data/helper.rb +32 -0
- data/data/tags +6 -0
- data/lib/greenpepper/argumentparser.rb +161 -0
- data/lib/greenpepper/common/loadpath.rb +7 -0
- data/lib/greenpepper/context/htmlcontext.rb +26 -0
- data/lib/greenpepper/converter.rb +347 -0
- data/lib/greenpepper/core.rb +152 -0
- data/lib/greenpepper/example/collectionexample.rb +305 -0
- data/lib/greenpepper/example/dowithexample.rb +192 -0
- data/lib/greenpepper/example/exampleheader.rb +41 -0
- data/lib/greenpepper/example/examplewithfixture.rb +73 -0
- data/lib/greenpepper/example/executionresults.rb +160 -0
- data/lib/greenpepper/example/fieldaccessor.rb +36 -0
- data/lib/greenpepper/example/freetextexample.rb +51 -0
- data/lib/greenpepper/example/importexample.rb +39 -0
- data/lib/greenpepper/example/nameresolver.rb +69 -0
- data/lib/greenpepper/example/ruleforexample.rb +117 -0
- data/lib/greenpepper/example/setupexample.rb +79 -0
- data/lib/greenpepper/example/silentexample.rb +14 -0
- data/lib/greenpepper/example/unknownexample.rb +17 -0
- data/lib/greenpepper/exception/greenpepperexception.rb +57 -0
- data/lib/greenpepper/executionunit.rb +39 -0
- data/lib/greenpepper/factory/collectionexamplefactory.rb +59 -0
- data/lib/greenpepper/factory/dowithexamplefactory.rb +71 -0
- data/lib/greenpepper/factory/examplefactory.rb +14 -0
- data/lib/greenpepper/factory/freetextexamplefactory.rb +29 -0
- data/lib/greenpepper/factory/htmlexamplefactory.rb +49 -0
- data/lib/greenpepper/factory/importexamplefactory.rb +27 -0
- data/lib/greenpepper/factory/ruleforexamplefactory.rb +46 -0
- data/lib/greenpepper/factory/setupexamplefactory.rb +31 -0
- data/lib/greenpepper/factory/silentexamplefactory.rb +21 -0
- data/lib/greenpepper/factory/unknownexamplefactory.rb +16 -0
- data/lib/greenpepper/freetext.rb +164 -0
- data/lib/greenpepper/grammar/array.treetop +51 -0
- data/lib/greenpepper/grammar/arrayparser.rb +14 -0
- data/lib/greenpepper/greenpepperconfig.rb +19 -0
- data/lib/greenpepper/greenpeppertask.rb +60 -0
- data/lib/greenpepper/logger.rb +45 -0
- data/lib/greenpepper/parser/freetextparser.rb +96 -0
- data/lib/greenpepper/parser/htmlparser.rb +70 -0
- data/lib/greenpepper/parser/scenario.rb +25 -0
- data/lib/greenpepper/parser/table.rb +37 -0
- data/lib/greenpepper/parser/wikiparser.rb +26 -0
- data/lib/greenpepper/pass/freetextpass.rb +24 -0
- data/lib/greenpepper/pass/greenpepperpass.rb +92 -0
- data/lib/greenpepper/pass/tablepass.rb +38 -0
- data/lib/greenpepper/railsargumentparser.rb +46 -0
- data/lib/greenpepper/redpeppertask.rb +89 -0
- data/lib/greenpepper/repository/atlassianrepository.rb +100 -0
- data/lib/greenpepper/writer/consolewriter.rb +21 -0
- data/lib/greenpepper/writer/freetextresult.rb +233 -0
- data/lib/greenpepper/writer/freetextwriter.rb +44 -0
- data/lib/greenpepper/writer/html.rb +14 -0
- data/lib/greenpepper/writer/htmldocwriter.rb +82 -0
- data/lib/greenpepper/writer/htmlresult.rb +192 -0
- data/lib/greenpepper/writer/htmlwriter.rb +112 -0
- data/lib/greenpepper/writer/output.rb +26 -0
- data/lib/greenpepper/writer/result.rb +35 -0
- data/lib/greenpepper/writer/xmlwriter.rb +32 -0
- data/test/coreseedstest.rb +39 -0
- data/test/greenpepper/argumentparsertest.rb +162 -0
- data/test/greenpepper/common/loadpathtest.rb +24 -0
- data/test/greenpepper/common/stattest.rb +186 -0
- data/test/greenpepper/convertertest.rb +371 -0
- data/test/greenpepper/coretest.rb +159 -0
- data/test/greenpepper/example/collectionexampletest.rb +484 -0
- data/test/greenpepper/example/dowithexampletest.rb +148 -0
- data/test/greenpepper/example/exampletest.rb +28 -0
- data/test/greenpepper/example/freetextexampletest.rb +151 -0
- data/test/greenpepper/example/importexampletest.rb +79 -0
- data/test/greenpepper/example/nameresolvertest.rb +56 -0
- data/test/greenpepper/example/ruleforexampletest.rb +225 -0
- data/test/greenpepper/example/setupexampletest.rb +140 -0
- data/test/greenpepper/example/silentexampletest.rb +17 -0
- data/test/greenpepper/example/unknownexampletest.rb +17 -0
- data/test/greenpepper/factory/collectionexamplefactorytest.rb +51 -0
- data/test/greenpepper/factory/dowithexamplefactorytest.rb +48 -0
- data/test/greenpepper/factory/examplefactorytest.rb +88 -0
- data/test/greenpepper/factory/freetextexamplefactorytest.rb +54 -0
- data/test/greenpepper/factory/importexamplefactorytest.rb +40 -0
- data/test/greenpepper/factory/ruleforexamplefactorytest.rb +55 -0
- data/test/greenpepper/factory/setupexamplefactorytest.rb +29 -0
- data/test/greenpepper/factory/silentexamplefactorytest.rb +38 -0
- data/test/greenpepper/freetexttest.rb +222 -0
- data/test/greenpepper/grammar/arrayparsertest.rb +45 -0
- data/test/greenpepper/loggertest.rb +26 -0
- data/test/greenpepper/parser/freetextparsertest.rb +124 -0
- data/test/greenpepper/parser/htmlparsertest.rb +77 -0
- data/test/greenpepper/parser/wikiparsertest.rb +21 -0
- data/test/greenpepper/pass/freetextpasstest.rb +54 -0
- data/test/greenpepper/pass/greenpepperpasstest.rb +47 -0
- data/test/greenpepper/pass/tablepasstest.rb +23 -0
- data/test/greenpepper/repository/atlassionrepositorytest.rb +85 -0
- data/test/greenpepper/writer/freetextwritertest.rb +301 -0
- data/test/greenpepper/writer/htmlcollectionwritertest.rb +145 -0
- data/test/greenpepper/writer/htmldowithwritertest.rb +87 -0
- data/test/greenpepper/writer/htmlruleforwritertest.rb +147 -0
- data/test/greenpepper/writer/htmlsetupwritertest.rb +107 -0
- data/test/greenpepper/writer/htmlstatresulttest.rb +118 -0
- data/test/greenpepper/writer/htmlwriterpositiontest.rb +53 -0
- data/test/greenpepper/writer/writertest.rb +33 -0
- data/test/greenpepper/writer/xmlwritertest.rb +34 -0
- data/test/integration/collectionexampleintegrationtest.rb +64 -0
- data/test/integration/errorhandlingintegrationtest.rb +68 -0
- data/test/integration/freetextexampleintegrationtest.rb +75 -0
- data/test/integration/greenpepperexecutableintegrationtest.rb +22 -0
- data/test/integration/importexampleintegrationtest.rb +41 -0
- data/test/integration/interpretationordertest.rb +48 -0
- data/test/integration/ruleforexampleintegrationtest.rb +102 -0
- data/test/integration/securityintegrationtest.rb +30 -0
- data/test/integration/setupexampleintegrationtest.rb +31 -0
- data/test/integration/silentexampleintegrationtest.rb +29 -0
- data/test/task/greenpeppertasktest.rb +96 -0
- data/test/task/redpeppertasktest.rb +120 -0
- data/vendor/accents.rb +85 -0
- metadata +234 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Author: Simon Mathieu (simon.math@gmail.com)
|
|
3
|
+
Pascal Ouellet (pas.ouellet@gmail.com)
|
|
4
|
+
Date: October 5, 2009
|
|
5
|
+
=end
|
|
6
|
+
|
|
7
|
+
module GreenPepper
|
|
8
|
+
|
|
9
|
+
class ExampleResult
|
|
10
|
+
attr_reader :silent
|
|
11
|
+
|
|
12
|
+
def initialize(silent = false)
|
|
13
|
+
@silent = silent
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def success?
|
|
17
|
+
false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def failure?
|
|
21
|
+
false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def error?
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def ignored?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update_stats(results)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
author: Alexandre Mathieu (alex.mathieu@gmail.com)
|
|
3
|
+
date: March 20th 2009
|
|
4
|
+
=end
|
|
5
|
+
module GreenPepper
|
|
6
|
+
|
|
7
|
+
class XmlWriter
|
|
8
|
+
def initialize(document)
|
|
9
|
+
@document = document
|
|
10
|
+
@modified_doc = ''
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def output
|
|
14
|
+
@modified_doc.to_s
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def write_results(results)
|
|
18
|
+
all_results = HtmlTableExecutionResults.get_all_results results
|
|
19
|
+
@modified_doc =
|
|
20
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
|
|
21
|
+
'<documents><document><statistics><success>' +
|
|
22
|
+
all_results.successes.to_s +
|
|
23
|
+
'</success>'
|
|
24
|
+
@modified_doc += '<failure>' + all_results.failures.to_s +
|
|
25
|
+
'</failure><error>' + all_results.errors.to_s + '</error><ignored>' +
|
|
26
|
+
all_results.ignored.to_s + '</ignored></statistics>'
|
|
27
|
+
@modified_doc += '<results><![CDATA[' + @document +
|
|
28
|
+
']]></results></document></documents>'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end #module GreenPepper
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Author: Simon Mathieu (simon.math@gmail.com)
|
|
3
|
+
Date: April 19, 2009
|
|
4
|
+
=end
|
|
5
|
+
|
|
6
|
+
require 'test/unit'
|
|
7
|
+
require 'greenpepper/core'
|
|
8
|
+
|
|
9
|
+
include GreenPepper
|
|
10
|
+
|
|
11
|
+
class CoreSeedTest < Test::Unit::TestCase
|
|
12
|
+
def test_autorun_all_seeds
|
|
13
|
+
seeds = ["Html Parsing.html",
|
|
14
|
+
"Value Comparison.html",
|
|
15
|
+
"Cell decoration.html",
|
|
16
|
+
"List of Interpreter.html",
|
|
17
|
+
"Set of Interpreter.html",
|
|
18
|
+
"Subset of Interpreter.html",
|
|
19
|
+
"Superset of Interpreter.html",
|
|
20
|
+
"Rule For Interpreter.html",
|
|
21
|
+
"Set Up Interpreter.html",
|
|
22
|
+
"Do With Interpreter.html",
|
|
23
|
+
"Statistics and Annotations.html"
|
|
24
|
+
]
|
|
25
|
+
base_path = "test/core_seeds/"
|
|
26
|
+
|
|
27
|
+
seeds.each{|s|
|
|
28
|
+
last_executed_seed = File.join("test/core_seeds_result",
|
|
29
|
+
s)
|
|
30
|
+
s = File.join("test/core_seeds/", s)
|
|
31
|
+
core = GreenPepperCore.new
|
|
32
|
+
result = core.run [s, last_executed_seed]
|
|
33
|
+
message = "Failed to execute seed #{s}."
|
|
34
|
+
results = HtmlTableExecutionResults.get_all_results(result)
|
|
35
|
+
assert_equal 0, results.failures, message
|
|
36
|
+
assert_equal 0, results.errors, message
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'greenpepper/argumentparser'
|
|
3
|
+
|
|
4
|
+
include GreenPepper
|
|
5
|
+
|
|
6
|
+
class ArgumentParserTest < Test::Unit::TestCase
|
|
7
|
+
def test_check_validity_of_execution_context_with_input_argument
|
|
8
|
+
input = "input_doc"
|
|
9
|
+
output = input + "_output"
|
|
10
|
+
|
|
11
|
+
argument_parser = ArgumentParser.new input
|
|
12
|
+
|
|
13
|
+
assert_equal_execution_context argument_parser.execution_context, input,
|
|
14
|
+
output, nil, true, false, ""
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_check_validity_of_execution_context_with_input_and_output_arguments
|
|
18
|
+
input = "input_doc"
|
|
19
|
+
output = "output_doc"
|
|
20
|
+
|
|
21
|
+
argument_parser = ArgumentParser.new [input, output]
|
|
22
|
+
execution_context = argument_parser.execution_context
|
|
23
|
+
|
|
24
|
+
assert_equal_execution_context execution_context, input, output, nil, true,
|
|
25
|
+
false, ""
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_check_validity_of_execution_context_with_invalid_arguments
|
|
29
|
+
argument_parser = ArgumentParser.new "--pouet"
|
|
30
|
+
|
|
31
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
32
|
+
nil, true, false,
|
|
33
|
+
"--pouet option is not recognize\n#{ArgumentParser.usage}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_check_validity_of_execution_context_with_no_argument
|
|
37
|
+
argument_parser = ArgumentParser.new []
|
|
38
|
+
|
|
39
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
40
|
+
nil, true, false, ArgumentParser.usage
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_parse_unrecognized_standard_command
|
|
44
|
+
unrecognized_args = []
|
|
45
|
+
unrecognized_args.push "--stop"
|
|
46
|
+
unrecognized_args.push "--sud"
|
|
47
|
+
unrecognized_args.push "-f"
|
|
48
|
+
unrecognized_args.push "-l"
|
|
49
|
+
unrecognized_args.push "--locale"
|
|
50
|
+
unrecognized_args.push "-o"
|
|
51
|
+
unrecognized_args.push "-s"
|
|
52
|
+
unrecognized_args.push "--suite"
|
|
53
|
+
unrecognized_args.push "--lazy"
|
|
54
|
+
unrecognized_args.push "--debug"
|
|
55
|
+
|
|
56
|
+
unrecognized_args.each { |arg|
|
|
57
|
+
error_message = "#{arg} option is not recognize\n#{ArgumentParser.usage}"
|
|
58
|
+
|
|
59
|
+
argument_parser = ArgumentParser.new arg
|
|
60
|
+
|
|
61
|
+
assert_equal_execution_context argument_parser.execution_context, nil,
|
|
62
|
+
nil, nil, true, false, error_message
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_parse_command_help
|
|
67
|
+
argument_parser = ArgumentParser.new "--help"
|
|
68
|
+
|
|
69
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
70
|
+
nil, true, false, ArgumentParser.usage
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_parse_command_version
|
|
74
|
+
argument_parser = ArgumentParser.new "--version"
|
|
75
|
+
|
|
76
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
77
|
+
nil, true, false, "#{$APP_NAME} version : #{$VERSION}"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_parse_command_repository_with_no_other_arg
|
|
81
|
+
argument_parser = ArgumentParser.new "-r"
|
|
82
|
+
|
|
83
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
84
|
+
nil, true, false, ArgumentParser.usage
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_parse_command_repository_with_correct_arg
|
|
88
|
+
repository = "repository"
|
|
89
|
+
argument_parser = ArgumentParser.new ["-r", repository]
|
|
90
|
+
|
|
91
|
+
assert_equal_execution_context argument_parser.execution_context, nil, nil,
|
|
92
|
+
repository, true, false, ArgumentParser.usage
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_parse_command_no_html_results
|
|
96
|
+
input = 'input_file'
|
|
97
|
+
argument_parser = ArgumentParser.new [input, "--no-html-results"]
|
|
98
|
+
|
|
99
|
+
assert_equal_execution_context argument_parser.execution_context, input,
|
|
100
|
+
input + '_output', nil, false, false, ""
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_parse_command_no_exception_stack
|
|
104
|
+
input = 'input_file'
|
|
105
|
+
argument_parser = ArgumentParser.new [input, "--no-exception-stack"]
|
|
106
|
+
|
|
107
|
+
assert argument_parser.writer_context[:no_exception_stack]
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_xml_output_without_specified_output_file
|
|
111
|
+
input = 'input_file.html'
|
|
112
|
+
output = 'input_file_output.xml'
|
|
113
|
+
|
|
114
|
+
argument_parser = ArgumentParser.new [input, '--xml']
|
|
115
|
+
execution_context = argument_parser.execution_context
|
|
116
|
+
|
|
117
|
+
assert_equal_execution_context execution_context, input, output, nil, true,
|
|
118
|
+
true, ""
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_multiple_load_path_is_read_like_expected_when_last
|
|
122
|
+
input = "input_file.html"
|
|
123
|
+
output = "output_file.html"
|
|
124
|
+
load_path = "--loadpath"
|
|
125
|
+
path1, path2, path3 = "path1", "path2", "path3"
|
|
126
|
+
|
|
127
|
+
argument_parser = ArgumentParser.new [input, output,
|
|
128
|
+
load_path, path1, path2, path3]
|
|
129
|
+
execution_context = argument_parser.execution_context
|
|
130
|
+
|
|
131
|
+
assert_equal_execution_context execution_context, input, output, nil, true,
|
|
132
|
+
false, ""
|
|
133
|
+
assert_equal ["path1", "path2", "path3"], execution_context[:load_path]
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_multiple_load_path_is_read_like_expected_when_in_middle
|
|
137
|
+
input = "input_file.html"
|
|
138
|
+
output = "output_file.html"
|
|
139
|
+
load_path = "--loadpath"
|
|
140
|
+
path1, path2, path3 = "path1", "path2", "path3"
|
|
141
|
+
|
|
142
|
+
argument_parser = ArgumentParser.new [input, output, "--no-html-results",
|
|
143
|
+
load_path, path1, path2, path3, "--xml"]
|
|
144
|
+
execution_context = argument_parser.execution_context
|
|
145
|
+
|
|
146
|
+
assert_equal_execution_context execution_context, input, output, nil, false,
|
|
147
|
+
true, ""
|
|
148
|
+
assert_equal ["path1", "path2", "path3"], execution_context[:load_path]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def assert_equal_execution_context execution_context, input, output,
|
|
152
|
+
repository, html_results, xml, console
|
|
153
|
+
|
|
154
|
+
assert_equal input , execution_context[:input_document]
|
|
155
|
+
assert_equal output , execution_context[:output_document]
|
|
156
|
+
assert_equal repository , execution_context[:repository]
|
|
157
|
+
assert_equal html_results, execution_context[:html_results_output]
|
|
158
|
+
assert_equal xml , execution_context[:xml_output]
|
|
159
|
+
assert_equal console , execution_context[:console_output]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Author: Martin Provencher (mprovencher86@gmail.com)
|
|
3
|
+
date: November 12, 2009
|
|
4
|
+
=end
|
|
5
|
+
|
|
6
|
+
require '../common/test/helper/assertion'
|
|
7
|
+
require 'greenpepper/common/loadpath'
|
|
8
|
+
require 'greenpepper/core'
|
|
9
|
+
|
|
10
|
+
include GreenPepper
|
|
11
|
+
|
|
12
|
+
class LoadPathTest < Test::Unit::TestCase
|
|
13
|
+
def test_loading_2_paths_in_right_order
|
|
14
|
+
path1, path2 = "dummy_path_test_1", "dummy_path_test_2"
|
|
15
|
+
|
|
16
|
+
init_load_path = $LOAD_PATH.dup
|
|
17
|
+
LoadPath.load [path1, path2]
|
|
18
|
+
|
|
19
|
+
paths = $LOAD_PATH - init_load_path
|
|
20
|
+
assert_equal 2, paths.size
|
|
21
|
+
assert_equal path1, paths[0]
|
|
22
|
+
assert_equal path2, paths[1]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
author: Martin Provencher (mprovencher86@gmail.com)
|
|
3
|
+
date: Septembre 8, 2009
|
|
4
|
+
=end
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
require 'libxml'
|
|
8
|
+
require 'test/unit'
|
|
9
|
+
require 'test/helper/assertion'
|
|
10
|
+
require 'greenpepper/example/executionresults'
|
|
11
|
+
require 'greenpepper/writer/htmlresult'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
include GreenPepper
|
|
15
|
+
|
|
16
|
+
class StatTest < Test::Unit::TestCase
|
|
17
|
+
|
|
18
|
+
def setup
|
|
19
|
+
@index_column_offset = 20
|
|
20
|
+
|
|
21
|
+
@all_results = []
|
|
22
|
+
@all_results << SuccessExampleResult.new
|
|
23
|
+
@all_results << FailureExampleResult.new
|
|
24
|
+
@all_results << WriteIgnoredExampleResult.new(3)
|
|
25
|
+
@all_results << WriteExpectedExampleResult.new(1, 2)
|
|
26
|
+
@all_results << WriteExceptionExampleResult.new(Exception.new)
|
|
27
|
+
|
|
28
|
+
@results = HtmlTableExecutionResults.new
|
|
29
|
+
@all_results.each_with_index{|result, index|
|
|
30
|
+
@results.add index, index + @index_column_offset, result
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_check_add_stat_is_in_each
|
|
35
|
+
index = 0
|
|
36
|
+
@results.each{|result|
|
|
37
|
+
assert_equal result, @all_results[index]
|
|
38
|
+
assert_equal result.row, index
|
|
39
|
+
assert_equal result.column, index + @index_column_offset
|
|
40
|
+
index += 1
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_check_add_with_at
|
|
45
|
+
@all_results.each_with_index { |result, index|
|
|
46
|
+
assert_equal @all_results[index], @results.at(index, index + @index_column_offset)
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_invalid_index_for_at
|
|
51
|
+
assert_equal nil, @results.at(0,1)
|
|
52
|
+
assert_equal nil, @results.at(1000,0)
|
|
53
|
+
assert_equal nil, @results.at(0,200)
|
|
54
|
+
assert_equal nil, @results.at(1000,200)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_result_are_compiled_at_each_add
|
|
58
|
+
assert_equal 1, @results.successes
|
|
59
|
+
assert_equal 2, @results.failures
|
|
60
|
+
assert_equal 1, @results.errors
|
|
61
|
+
assert_equal 1, @results.ignored
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_result_are_removed_from_compilation_at_each_delete_at
|
|
65
|
+
@results.delete_at 1, 1 + @index_column_offset
|
|
66
|
+
@results.delete_at 4, 4 + @index_column_offset
|
|
67
|
+
|
|
68
|
+
assert_equal 1, @results.successes
|
|
69
|
+
assert_equal 1, @results.failures
|
|
70
|
+
assert_equal 0, @results.errors
|
|
71
|
+
assert_equal 1, @results.ignored
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_delete_at_function_on_valid_stat
|
|
75
|
+
assert_equal 5, @results.size
|
|
76
|
+
|
|
77
|
+
@results.delete_at 0, @index_column_offset
|
|
78
|
+
result = @results.at 0, @index_column_offset
|
|
79
|
+
assert_equal nil, result
|
|
80
|
+
|
|
81
|
+
assert_equal 4, @results.size
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_invalid_index_for_delete_at
|
|
85
|
+
indexes = []
|
|
86
|
+
indexes << [0, 1]
|
|
87
|
+
indexes << [1000, 0]
|
|
88
|
+
indexes << [0, 200]
|
|
89
|
+
indexes << [1000, 200]
|
|
90
|
+
|
|
91
|
+
assert_equal 5, @results.size
|
|
92
|
+
|
|
93
|
+
indexes.each{ |index|
|
|
94
|
+
@results.delete_at index[0], index[1]
|
|
95
|
+
assert_equal @results.at(index[0], index[1]), nil
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
assert_equal 5, @results.size
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_stat_to_s_is_human_readable
|
|
102
|
+
expected = "| EmptyStatClass |\n"
|
|
103
|
+
expected += "| NilClass | EmptyStatClass |\n"
|
|
104
|
+
expected += "| NilClass | NilClass |"
|
|
105
|
+
expected += " EmptyStatClass |\n"
|
|
106
|
+
expected += "| NilClass | NilClass |"
|
|
107
|
+
expected += " NilClass | EmptyStatClass |\n"
|
|
108
|
+
expected += "| NilClass | NilClass |"
|
|
109
|
+
expected += " NilClass | NilClass |"
|
|
110
|
+
expected += " EmptyStatClass |"
|
|
111
|
+
|
|
112
|
+
all_results = []
|
|
113
|
+
all_results << EmptyStatClass.new
|
|
114
|
+
all_results << EmptyStatClass.new
|
|
115
|
+
all_results << EmptyStatClass.new
|
|
116
|
+
all_results << EmptyStatClass.new
|
|
117
|
+
all_results << EmptyStatClass.new
|
|
118
|
+
|
|
119
|
+
results = HtmlTableExecutionResults.new
|
|
120
|
+
all_results.each_with_index{|result, index|
|
|
121
|
+
results.add index, index, result
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
assert_equal expected, results.to_s
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class FreeTextStatClass < Test::Unit::TestCase
|
|
130
|
+
def setup
|
|
131
|
+
@execution_results = FreeTextExecutionResults.new
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_all_stats_should_be_zero_at_creation_of_results_class
|
|
135
|
+
assert all_stats_are_at_zero?
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_add_given
|
|
139
|
+
@execution_results.add_result(GivenSuccess.new)
|
|
140
|
+
assert all_stats_are_at_zero?
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def test_add_when
|
|
144
|
+
@execution_results.add_result(WhenSuccess.new)
|
|
145
|
+
assert all_stats_are_at_zero?
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_add_ask
|
|
149
|
+
@execution_results.add_result(AskSuccess.new("answer"))
|
|
150
|
+
assert all_stats_are_at_zero?
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def test_add_check_success
|
|
154
|
+
@execution_results.add_result(CheckSuccess.new)
|
|
155
|
+
assert_equal 1, @execution_results.successes
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_add_check_failure
|
|
159
|
+
@execution_results.add_result(CheckFailure.new)
|
|
160
|
+
assert_equal 1, @execution_results.failures
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_add_then
|
|
164
|
+
@exp = [Expectation.new("1"), Expectation.new("2")]
|
|
165
|
+
@exp[0].received = "0"
|
|
166
|
+
@exp[1].received = "2"
|
|
167
|
+
@execution_results.add_result(ThenResults.new(/then (.*) and (.*)/, @exp))
|
|
168
|
+
assert_equal 1, @execution_results.failures
|
|
169
|
+
assert_equal 1, @execution_results.successes
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def test_add_keyword_error
|
|
173
|
+
@execution_results.add_result(KeywordError.new)
|
|
174
|
+
assert_equal 1, @execution_results.errors
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def all_stats_are_at_zero?
|
|
178
|
+
@execution_results.successes == 0 &&
|
|
179
|
+
@execution_results.failures == 0 &&
|
|
180
|
+
@execution_results.errors == 0 &&
|
|
181
|
+
@execution_results.ignored == 0
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
class EmptyStatClass < HtmlExampleResult
|
|
186
|
+
end
|