rcor 0.8.1 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +1 -1
- data/lib/concordion.rb +1 -8
- data/lib/concordion_constants.rb +1 -1
- data/lib/concordion_css.rb +8 -1
- data/lib/concordion_css_decorator.rb +21 -4
- data/lib/concordion_error_condition.rb +26 -0
- data/lib/concordion_invoker.rb +103 -9
- data/lib/concordion_parse_result.rb +19 -1
- data/lib/concordion_parser.rb +1 -1
- data/lib/concordion_processor.rb +3 -2
- data/lib/concordion_string_utility.rb +36 -2
- data/lib/concordion_test_case.rb +12 -62
- data/lib/concordion_test_methods.rb +127 -0
- data/lib/concordion_utility.rb +15 -3
- data/lib/goldmaster_test_case.rb +22 -5
- data/lib/loader_helper.rb +16 -0
- data/nbproject/private/private.xml +0 -6
- data/nbproject/private/rake-d.txt +13 -0
- data/tests/apostrophe.html +7 -0
- data/tests/apostrophe_test.rb +18 -0
- data/tests/ariel_example.html +13 -0
- data/tests/ariel_example_test.rb +36 -0
- data/tests/attr_assert.html +2 -0
- data/tests/basic_assert_true_test.rb +5 -1
- data/tests/basic_set.html +3 -0
- data/tests/basic_text.html +8 -0
- data/tests/basic_text_test.rb +11 -0
- data/tests/concordion_parse_result_test.rb +16 -1
- data/tests/concordion_test.rb +0 -14
- data/tests/concordion_utility_test.rb +44 -0
- data/tests/failing.html +4 -0
- data/tests/failing_test.rb +10 -2
- data/tests/goldmaster_assert_true_failing.html +5 -0
- data/tests/goldmaster_assert_true_failing_goldmaster.html +169 -0
- data/tests/goldmaster_assert_true_failing_test.rb +14 -0
- data/tests/goldmaster_failing.html +40 -0
- data/tests/goldmaster_failing_goldmaster.html +48 -1
- data/tests/goldmaster_failing_test.rb +28 -2
- data/tests/goldmaster_malformed.html +7 -0
- data/tests/goldmaster_malformed_goldmaster.html +171 -0
- data/tests/goldmaster_malformed_test.rb +11 -0
- data/tests/goldmaster_passing_goldmaster.html +8 -1
- data/tests/goldmaster_table_bug.html +12 -0
- data/tests/goldmaster_table_bug_goldmaster.html +176 -0
- data/tests/goldmaster_table_bug_test.rb +24 -0
- data/tests/goldmaster_table_goldmaster.html +8 -1
- data/tests/image.html +5 -0
- data/tests/image.jpg +0 -0
- data/tests/image_test.rb +9 -0
- data/tests/mixed.html +5 -0
- data/tests/mixed_test.rb +19 -0
- data/tests/no_parens.html +15 -0
- data/tests/no_parens_test.rb +20 -0
- data/tests/numbers.html +5 -0
- data/tests/numbers_test.rb +11 -0
- data/tests/verify_rows_scsr_test.rb +2 -0
- data/tests/verify_rows_simple.html +14 -0
- data/tests/verify_rows_simple_test.rb +17 -0
- metadata +31 -4
- data/lib/concordion_invocation_string_builder.rb +0 -24
@@ -0,0 +1,127 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
require 'concordion_utility'
|
4
|
+
require 'concordion_reader'
|
5
|
+
require 'concordion_parser'
|
6
|
+
require 'concordion_processor'
|
7
|
+
require 'concordion_parse_result'
|
8
|
+
require 'concordion_test_case'
|
9
|
+
require 'concordion_writer'
|
10
|
+
require 'concordion_environment'
|
11
|
+
require 'concordion'
|
12
|
+
require 'concordion_css_decorator'
|
13
|
+
require 'concordion_utility'
|
14
|
+
|
15
|
+
|
16
|
+
module ConcordionConfigMethods
|
17
|
+
|
18
|
+
|
19
|
+
def default_config
|
20
|
+
concordion = Concordion.new
|
21
|
+
parser = ConcordionParser.new(ConcordionReader.new, concordion)
|
22
|
+
decorator = ConcordionCSSDecorator.new
|
23
|
+
processor = ConcordionProcessor.new(concordion, decorator)
|
24
|
+
{
|
25
|
+
:parser => parser,
|
26
|
+
:writer => ConcordionWriter.new(ConcordionEnvironment.output_dir),
|
27
|
+
:concordion => concordion,
|
28
|
+
:decorator => decorator,
|
29
|
+
:processor => processor,
|
30
|
+
:write_goldmaster => false,
|
31
|
+
:css_type => ConcordionEnvironment.css_type
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def bind_test_method_to(subclass, config)
|
36
|
+
subclass.class_eval do
|
37
|
+
define_method :test_spec do
|
38
|
+
filename = snake_cased_test_name(subclass.to_s)
|
39
|
+
parse_spec(filename,config)
|
40
|
+
failures = run_spec(filename, config)
|
41
|
+
report_spec(filename,config, failures)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
subclass
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
module ConcordionInternalTestMethods
|
51
|
+
@@EXPECTED_FAILURE_COUNT = 0
|
52
|
+
include ConcordionUtility
|
53
|
+
|
54
|
+
def parse_spec(filename,config)
|
55
|
+
config[:parser].parse(filename)
|
56
|
+
assert_concordion_document(config)
|
57
|
+
config[:decorator].add_concordion_css_link(config[:parser].root, config[:parser].html, config[:css_type])
|
58
|
+
end
|
59
|
+
|
60
|
+
def run_spec(filename, config)
|
61
|
+
failures = []
|
62
|
+
config[:parser].each_eligible_concordion_element do |elem|
|
63
|
+
failure = config[:processor].process(elem, self)
|
64
|
+
failures << failure unless failure.nil?
|
65
|
+
end
|
66
|
+
failures
|
67
|
+
end
|
68
|
+
|
69
|
+
def report_spec(filename, config, failures)
|
70
|
+
config[:decorator].add_css_file_to_output_dir(config[:writer], config[:css_type])
|
71
|
+
|
72
|
+
writer = config[:writer]
|
73
|
+
if self.class.method_defined?(:rcor_writer)
|
74
|
+
writer = rcor_writer()
|
75
|
+
end
|
76
|
+
|
77
|
+
outfilename = writer.calculate_filename_and_overwrite(config[:parser].root, filename)
|
78
|
+
assert_no_failures(outfilename, config, failures)
|
79
|
+
end
|
80
|
+
|
81
|
+
def assert_no_failures(outfilename, config, failures)
|
82
|
+
expected = @@EXPECTED_FAILURE_COUNT
|
83
|
+
|
84
|
+
if self.class.method_defined?(:expected_failure_count)
|
85
|
+
expected = expected_failure_count()
|
86
|
+
end
|
87
|
+
|
88
|
+
message = build_message "#{show_failures(failures)}\nWrote output to #{outfilename}.",
|
89
|
+
'Actual failure count <?> did not match expected <?>.',
|
90
|
+
failures.size, expected
|
91
|
+
assert_block message do
|
92
|
+
failures.size == expected
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def show_failures(failures)
|
97
|
+
rv = ""
|
98
|
+
failures.each_with_index do |failure, index|
|
99
|
+
rv += "[Error:#{index + 1}] #{failure}\n"
|
100
|
+
end
|
101
|
+
rv
|
102
|
+
end
|
103
|
+
|
104
|
+
def assert_concordion_document(config)
|
105
|
+
assert_equal "http://www.concordion.org/2007/concordion", config[:parser].html.get_attribute("xmlns:concordion")
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
module ConcordionTestMethods
|
111
|
+
include ConcordionInternalTestMethods
|
112
|
+
extend ConcordionConfigMethods
|
113
|
+
|
114
|
+
class << self
|
115
|
+
alias_method :original_included, :included
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.included(cmod)
|
119
|
+
original_included(cmod)
|
120
|
+
conf = default_config
|
121
|
+
cm = class << cmod
|
122
|
+
include ConcordionConfigMethods
|
123
|
+
end
|
124
|
+
|
125
|
+
bind_test_method_to(cmod, conf)
|
126
|
+
end
|
127
|
+
end
|
data/lib/concordion_utility.rb
CHANGED
@@ -25,9 +25,21 @@ module ConcordionUtility
|
|
25
25
|
|
26
26
|
def concordion_arguments(name)
|
27
27
|
return [] unless has_arguments?(name)
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
arg_string = nil
|
29
|
+
if name =~ /\(/
|
30
|
+
name_no_end_paren = name.gsub(")", '')
|
31
|
+
arg_string = name_no_end_paren.split("(")[1]
|
32
|
+
else
|
33
|
+
|
34
|
+
base = name.strip
|
35
|
+
if base =~ /=/
|
36
|
+
arg_string = nil
|
37
|
+
base = base.split("=")[1].strip
|
38
|
+
end
|
39
|
+
tokens = base.split(" ").compact
|
40
|
+
arg_string = tokens.slice(1, tokens.size - 1).join(" ")
|
41
|
+
end
|
42
|
+
|
31
43
|
arg_string.split(",").collect { |arg| arg.strip }
|
32
44
|
end
|
33
45
|
def concordion_variable_name(conc_call)
|
data/lib/goldmaster_test_case.rb
CHANGED
@@ -1,32 +1,49 @@
|
|
1
1
|
require 'concordion_test_case'
|
2
2
|
require 'concordion_string_writer'
|
3
|
+
|
4
|
+
require 'diff/lcs'
|
5
|
+
|
3
6
|
class GoldmasterTestCase < ConcordionTestCase
|
4
7
|
|
5
8
|
|
6
9
|
def initialize(suite, conf = {})
|
7
10
|
@writer = ConcordionStringWriter.new
|
8
11
|
|
9
|
-
config = ConcordionTestCase.default_config.merge(
|
12
|
+
config = ConcordionTestCase.default_config.merge(conf)
|
10
13
|
@write_goldmaster = config[:write_goldmaster]
|
11
14
|
super(suite, config)
|
12
15
|
end
|
13
16
|
|
17
|
+
def rcor_writer
|
18
|
+
@writer
|
19
|
+
end
|
14
20
|
def test_spec
|
15
21
|
trivial
|
16
22
|
end
|
17
23
|
|
18
24
|
|
19
25
|
def teardown
|
20
|
-
if
|
26
|
+
if self.class.method_defined?(:write_goldmaster!)
|
21
27
|
ConcordionWriter.new.write(@writer.data, snake_cased_goldmaster_name(self.class.to_s))
|
22
28
|
|
23
|
-
assert
|
29
|
+
assert false, "Disable write to goldmaster (erase write_goldmaster! in #{self.class})"
|
24
30
|
end
|
25
|
-
|
31
|
+
|
26
32
|
unless is_trivial?
|
27
33
|
goldmaster = ConcordionReader.new.read(snake_cased_goldmaster_name(self.class.to_s))
|
28
|
-
|
34
|
+
assert @writer.data.size > 0
|
35
|
+
|
36
|
+
diffs = Diff::LCS.diff(@writer.data, goldmaster)
|
37
|
+
pos = diffs[0].entries[0].position
|
38
|
+
context_exp = goldmaster.slice(pos - 50, 100)
|
39
|
+
context_act = @writer.data.slice(pos - 50, 100)
|
40
|
+
|
41
|
+
assert_equal @writer.data, goldmaster, "First difference at #{pos} bytes into goldmaster:\n(#{context_exp}) goldmaster vs\n(#{context_act}) actual"
|
29
42
|
end
|
30
43
|
|
31
44
|
end
|
45
|
+
|
46
|
+
def meths(o)
|
47
|
+
(o.methods - Object.methods).sort
|
48
|
+
end
|
32
49
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
module LoaderHelper
|
7
|
+
def path_for(filename)
|
8
|
+
return filename if File.exists?(filename)
|
9
|
+
|
10
|
+
$LOAD_PATH.each do |path|
|
11
|
+
candidate = "#{path}/#{filename}"
|
12
|
+
return candidate if File.exists?(candidate)
|
13
|
+
end
|
14
|
+
throw Exception.new("could not find '#{filename}' on load path")
|
15
|
+
end
|
16
|
+
end
|
@@ -1,10 +1,4 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
3
3
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
4
|
-
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
|
5
|
-
<file>file:/home/bg/src/rcor/rcor/trunk/Rakefile.rb</file>
|
6
|
-
<file>file:/home/bg/src/rcor/rcor/trunk/lib/concordion_css_decorator.rb</file>
|
7
|
-
<file>file:/home/bg/src/rcor/rcor/trunk/lib/concordion_environment.rb</file>
|
8
|
-
<file>file:/home/bg/src/rcor/rcor/trunk/tests/concordion_environment_test.rb</file>
|
9
|
-
</open-files>
|
10
4
|
</project-private>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
clean=Remove any temporary products.
|
2
|
+
clobber=Remove any generated file.
|
3
|
+
clobber_package=Remove package products
|
4
|
+
default=
|
5
|
+
gem=Build the gem file rcor-0.9.2.gem
|
6
|
+
package=Build all the packages
|
7
|
+
pkg=
|
8
|
+
pkg/rcor-0.9.2=
|
9
|
+
pkg/rcor-0.9.2.gem=
|
10
|
+
pkg/rcor-0.9.2.tgz=
|
11
|
+
pkg/rcor-0.9.2.zip=
|
12
|
+
repackage=Force a rebuild of the package files
|
13
|
+
test=Run tests
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<html xmlns:concordion="http://www.concordion.org/2007/concordion">
|
2
|
+
<body>
|
3
|
+
<p concordion:assertEquals="apostrophe()">Apostrophe's</p>
|
4
|
+
<p concordion:assertEquals="as_apostrophe_bs()">As ' Bs</p>
|
5
|
+
<p concordion:assertEquals="check(#TEXT)">A's</p>
|
6
|
+
</body>
|
7
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<html xmlns:concordion="http://www.concordion.org/2007/concordion">
|
2
|
+
<body>
|
3
|
+
<p>Given an <span concordion:execute="#author = setup_user (#TEXT)">author</span>
|
4
|
+
who has an
|
5
|
+
<span concordion:execute="#entity = setup_entity(#author,#TEXT)">entity</span>
|
6
|
+
with no versions,
|
7
|
+
</p>
|
8
|
+
<p concordion:execute="delete_users_entity(#author,#entity)"
|
9
|
+
>When the author deletes the entity,</p>
|
10
|
+
<p concordion:assertTrue="is_deleted?(#entity)">Then entity is
|
11
|
+
deleted from the system.</p>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'concordion_test_case'
|
3
|
+
require 'user'
|
4
|
+
|
5
|
+
class SomeEntity
|
6
|
+
attr_accessor :nombre, :deleted
|
7
|
+
def initialize(nombre)
|
8
|
+
@nombre = nombre
|
9
|
+
@deleted = false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ArielExampleTest < ConcordionTestCase
|
14
|
+
|
15
|
+
def setup_user(name)
|
16
|
+
User.new(name, "whatever")
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_entity(user, entity_name)
|
20
|
+
entity = SomeEntity.new(entity_name)
|
21
|
+
user.other = entity
|
22
|
+
|
23
|
+
entity
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_users_entity(user, entity)
|
27
|
+
if user.other.nombre == entity.nombre
|
28
|
+
user.other.deleted = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def is_deleted?(entity)
|
33
|
+
entity.deleted
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/tests/attr_assert.html
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# To change this template, choose Tools | Templates
|
2
2
|
# and open the template in the editor.
|
3
|
-
|
3
|
+
require 'concordion_test_case'
|
4
4
|
class BasicAssertTrueTest < ConcordionTestCase
|
5
5
|
def initialize(suite)
|
6
6
|
super(suite, {:expected_failure_count => 1})
|
7
7
|
end
|
8
|
+
def expected_failure_count
|
9
|
+
1
|
10
|
+
end
|
11
|
+
|
8
12
|
def is_boiling_point(temperature)
|
9
13
|
212 == temperature.to_i
|
10
14
|
end
|
data/tests/basic_set.html
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
<body>
|
3
3
|
Here's some text
|
4
4
|
<p concordion:set="#username">Chuck Norris</p>
|
5
|
+
<p concordion:set="#mnks">Monkeys</p>
|
6
|
+
<p concordion:set="#mnks">Monkeys</p>
|
7
|
+
|
5
8
|
<p concordion:assertEquals="greetingFor(#username)">Hello Chuck Norris, you nancy-boy.</p>
|
6
9
|
it should be in the output.
|
7
10
|
</body>
|
data/tests/basic_text.html
CHANGED
@@ -2,5 +2,13 @@
|
|
2
2
|
<body>
|
3
3
|
<p concordion:execute="set_name(#TEXT)">No</p>
|
4
4
|
<p concordion:assertEquals="double_down()">NoNo</p>
|
5
|
+
|
6
|
+
<p concordion:execute="#result = return_arg(#TEXT)">Working Text</p>
|
7
|
+
<p concordion:assertEquals="#result">Working Text</p>
|
8
|
+
|
9
|
+
<p concordion:execute="#result = concat(#TEXT,#TEXT)">Working Text 2</p>
|
10
|
+
<p concordion:assertEquals="#result">Working Text 2:Working Text 2</p>
|
11
|
+
|
12
|
+
|
5
13
|
</body>
|
6
14
|
</html>
|
data/tests/basic_text_test.rb
CHANGED
@@ -6,6 +6,17 @@ class BasicTextTest < ConcordionTestCase
|
|
6
6
|
@name = name
|
7
7
|
end
|
8
8
|
|
9
|
+
def return_arg(arg)
|
10
|
+
arg
|
11
|
+
end
|
12
|
+
|
13
|
+
def concat(a,b)
|
14
|
+
raise "second arg nil" if b.nil?
|
15
|
+
raise "first arg nil" if a.nil?
|
16
|
+
|
17
|
+
"#{a}:#{b}"
|
18
|
+
end
|
19
|
+
|
9
20
|
def double_down
|
10
21
|
"#{@name*2}"
|
11
22
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'concordion_parse_result'
|
3
|
-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mocha'
|
4
5
|
class ConcordionParseResultTest < Test::Unit::TestCase
|
5
6
|
|
6
7
|
def test_is_set_command
|
@@ -8,6 +9,11 @@ class ConcordionParseResultTest < Test::Unit::TestCase
|
|
8
9
|
assert !ConcordionParseResult.new("asdf",nil,nil,nil).is_set_command?
|
9
10
|
end
|
10
11
|
|
12
|
+
def test_is_assert_image_command
|
13
|
+
assert ConcordionParseResult.new("assert_image",nil,nil,nil).is_assert_image_command?
|
14
|
+
assert !ConcordionParseResult.new("set",nil,nil,nil).is_assert_image_command?
|
15
|
+
end
|
16
|
+
|
11
17
|
def test_is_execute_command
|
12
18
|
assert ConcordionParseResult.new("execute",nil,nil,nil).is_execute_command?
|
13
19
|
assert !ConcordionParseResult.new("asdf",nil,nil,nil).is_execute_command?
|
@@ -17,7 +23,16 @@ class ConcordionParseResultTest < Test::Unit::TestCase
|
|
17
23
|
assert ConcordionParseResult.new("verifyrows",nil,nil,nil).is_verify_command?
|
18
24
|
assert !ConcordionParseResult.new("monkeys",nil,nil,nil).is_verify_command?
|
19
25
|
end
|
26
|
+
def test_is_asserttrue_command
|
27
|
+
assert ConcordionParseResult.new("asserttrue",nil,nil,nil).is_assert_true_command?
|
28
|
+
assert !ConcordionParseResult.new("monkeys",nil,nil,nil).is_assert_true_command?
|
29
|
+
end
|
20
30
|
|
31
|
+
def test_image_location
|
32
|
+
tag = mock("tag")
|
33
|
+
tag.expects(:get_attribute).with('src').returns "foo"
|
34
|
+
assert_equal "foo", ConcordionParseResult.new(nil,nil,nil, tag).image_location
|
35
|
+
end
|
21
36
|
def test_assignment
|
22
37
|
assert_equal "#user", ConcordionParseResult.new("verifyrows"," #user = asdfasdf",nil,nil).assignment
|
23
38
|
assert_equal "#bob", ConcordionParseResult.new("monkeys","#bob=asdf",nil,nil).assignment
|
data/tests/concordion_test.rb
CHANGED
@@ -15,20 +15,6 @@ class ConcordionTest < Test::Unit::TestCase
|
|
15
15
|
assert_equal "bar", @concordion.get_variable("#foo")
|
16
16
|
end
|
17
17
|
|
18
|
-
def test_build_invocation_string
|
19
|
-
assert_equal "self.send('foo')", @concordion.build_invocation_string("foo()", "content")
|
20
|
-
@concordion.set_variable("#bar", "baz")
|
21
|
-
assert_equal "self.send('foo', 'baz')", @concordion.build_invocation_string("foo(#bar)", "content")
|
22
|
-
|
23
|
-
@concordion.set_variable("#purplemonkey", "dishwasher")
|
24
|
-
assert_equal "self.send('other', 'baz', 'dishwasher')", @concordion.build_invocation_string("other(#bar, #purplemonkey)", "content")
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_build_invocation_string_replaces_text
|
28
|
-
assert_equal "self.send('foo', 'ASDF')", @concordion.build_invocation_string("foo(#TEXT)", "ASDF")
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
18
|
def test_dereference
|
33
19
|
@concordion.set_variable("#result", @thingy)
|
34
20
|
|