concordion 0.9.9.2 → 0.9.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/Rakefile.rb +25 -28
- data/documentation/index.html +88 -0
- data/documentation/p/rcor/wiki/Tutorial/index.html +75 -0
- data/lib/concordion/binder.rb +26 -0
- data/lib/concordion/constants.rb +15 -0
- data/lib/{concordion_css.rb → concordion/css.rb} +9 -7
- data/lib/concordion/css_decorator.rb +59 -0
- data/lib/concordion/environment.rb +28 -0
- data/lib/concordion/error_condition.rb +27 -0
- data/lib/concordion/instrumenter.rb +31 -0
- data/lib/concordion/invoker.rb +148 -0
- data/lib/concordion/loader_helper.rb +17 -0
- data/lib/concordion/lookahead_handler.rb +16 -0
- data/lib/concordion/parse_result.rb +74 -0
- data/lib/concordion/parser.rb +43 -0
- data/lib/concordion/processor.rb +24 -0
- data/lib/concordion/reader.rb +11 -0
- data/lib/concordion/state.rb +77 -0
- data/lib/concordion/string_utility.rb +104 -0
- data/lib/concordion/string_writer.rb +13 -0
- data/lib/concordion/test_methods.rb +130 -0
- data/lib/concordion/utility.rb +72 -0
- data/lib/concordion/verifier.rb +52 -0
- data/lib/concordion/writer.rb +52 -0
- data/lib/concordion_test_case.rb +4 -16
- data/lib/goldmaster_test_case.rb +4 -4
- data/ruby-concordion.tmproj +249 -0
- data/test/concordion/css_decorator_test.rb +28 -0
- data/test/concordion/environment_test.rb +46 -0
- data/test/concordion/invoker_test.rb +20 -0
- data/test/concordion/parse_result_test.rb +51 -0
- data/test/concordion/reader_test.rb +12 -0
- data/test/concordion/state_test.rb +41 -0
- data/test/concordion/string_writer_test.rb +10 -0
- data/test/concordion/utility_test.rb +142 -0
- data/test/concordion/verifier_test.rb +38 -0
- data/test/concordion/writer_test.rb +29 -0
- data/{tests → test}/concordion.css +0 -0
- data/{tests/concordion → test}/goldmaster_test_case_test.rb +2 -8
- data/{tests → test/spec}/basic_assert.html +0 -0
- data/{tests → test/spec}/basic_assert_test.rb +2 -2
- data/{tests → test/spec}/basic_set.html +0 -0
- data/{tests → test/spec}/basic_set_test.rb +0 -1
- data/{tests → test/spec}/basic_text.html +0 -0
- data/{tests → test/spec}/basic_text_test.rb +0 -1
- data/{tests → test/spec}/failing.html +0 -0
- data/{tests → test/spec}/failing_test.rb +0 -1
- data/{tests → test/spec}/goldmasters/failing_with_subclass.html +0 -0
- data/{tests → test/spec}/goldmasters/failing_with_subclass_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/failing_with_subclass_test.rb +2 -2
- data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing_test.rb +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_failing.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_failing_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_failing_test.rb +0 -2
- data/{tests → test/spec}/goldmasters/goldmaster_malformed.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_malformed_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_malformed_test.rb +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_passing.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_passing_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_passing_test.rb +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table_bug.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table_bug_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table_bug_test.rb +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table_goldmaster.html +0 -0
- data/{tests → test/spec}/goldmasters/goldmaster_table_test.rb +1 -0
- data/{tests → test/spec}/image.html +0 -0
- data/{tests → test/spec}/image.jpg +0 -0
- data/{tests → test/spec}/image_test.rb +2 -2
- data/{tests → test/spec}/link_style_css.html +0 -0
- data/{tests → test/spec}/link_style_css_test.rb +1 -6
- data/{tests → test/spec}/lookahead_assert_true.html +0 -0
- data/{tests → test/spec}/lookahead_assert_true_test.rb +0 -0
- data/{tests → test/spec}/mixed.html +0 -0
- data/test/spec/mixed_test.rb +13 -0
- data/{tests → test/spec}/nested_element_lookahead.html +0 -0
- data/{tests → test/spec}/nested_element_lookahead_test.rb +0 -0
- data/{tests → test/spec}/numbers.html +0 -0
- data/{tests → test/spec}/numbers_test.rb +0 -0
- data/{tests → test/spec}/processes_elements_in_sorted_order.html +0 -0
- data/{tests → test/spec}/processes_elements_in_sorted_order_test.rb +0 -0
- data/{tests → test/spec}/return_result.html +0 -0
- data/{tests → test/spec}/return_result_test.rb +0 -0
- data/test/spec/structure/maps_to_module.html +11 -0
- data/test/spec/structure/maps_to_module_test.rb +13 -0
- data/{tests → test/spec}/tables/single_row_table.html +0 -0
- data/{tests → test/spec}/tables/single_row_table_test.rb +0 -0
- data/{tests → test/spec}/tables/table.html +0 -0
- data/{tests → test/spec}/tables/table_test.rb +1 -0
- data/{tests → test/spec}/tables/test_helper.rb +3 -7
- data/{tests → test/spec}/tables/verify_rows.html +0 -0
- data/{tests → test/spec}/tables/verify_rows_scsr.html +0 -0
- data/{tests → test/spec}/tables/verify_rows_scsr_test.rb +2 -1
- data/{tests → test/spec}/tables/verify_rows_simple.html +0 -0
- data/{tests → test/spec}/tables/verify_rows_simple_test.rb +0 -0
- data/{tests → test/spec}/tables/verify_rows_test.rb +1 -0
- data/{tests → test/spec}/user-reported/apostrophe.html +0 -0
- data/{tests → test/spec}/user-reported/apostrophe_test.rb +0 -1
- data/{tests → test/spec}/user-reported/ariel_example.html +0 -0
- data/{tests → test/spec}/user-reported/ariel_example_test.rb +0 -0
- data/{tests → test/spec}/user-reported/attr_assert.html +0 -0
- data/{tests → test/spec}/user-reported/attr_assert_test.rb +0 -1
- data/{tests → test/spec}/user-reported/basic_assert_true.html +0 -0
- data/{tests → test/spec}/user-reported/basic_assert_true_test.rb +1 -2
- data/{tests → test/spec}/user-reported/rubyish.html +0 -0
- data/{tests → test/spec}/user-reported/rubyish_test.rb +0 -1
- data/test/test_helper.rb +11 -0
- metadata +131 -114
- data/lib/concordion_binder.rb +0 -24
- data/lib/concordion_constants.rb +0 -13
- data/lib/concordion_css_decorator.rb +0 -58
- data/lib/concordion_environment.rb +0 -27
- data/lib/concordion_error_condition.rb +0 -26
- data/lib/concordion_instrumenter.rb +0 -30
- data/lib/concordion_invoker.rb +0 -137
- data/lib/concordion_lookahead_handler.rb +0 -17
- data/lib/concordion_parse_result.rb +0 -72
- data/lib/concordion_parser.rb +0 -47
- data/lib/concordion_processor.rb +0 -25
- data/lib/concordion_reader.rb +0 -10
- data/lib/concordion_state.rb +0 -78
- data/lib/concordion_string_utility.rb +0 -97
- data/lib/concordion_string_writer.rb +0 -13
- data/lib/concordion_test_methods.rb +0 -132
- data/lib/concordion_utility.rb +0 -70
- data/lib/concordion_verifier.rb +0 -50
- data/lib/concordion_writer.rb +0 -43
- data/lib/loader_helper.rb +0 -16
- data/tests/concordion/concordion_css_decorator_test.rb +0 -28
- data/tests/concordion/concordion_environment_test.rb +0 -44
- data/tests/concordion/concordion_parse_result_test.rb +0 -51
- data/tests/concordion/concordion_reader_test.rb +0 -15
- data/tests/concordion/concordion_state_test.rb +0 -38
- data/tests/concordion/concordion_string_writer_test.rb +0 -13
- data/tests/concordion/concordion_utility_test.rb +0 -135
- data/tests/concordion/concordion_verifier_test.rb +0 -38
- data/tests/concordion/concordion_writer_test.rb +0 -26
- data/tests/mixed_test.rb +0 -19
data/lib/concordion_parser.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
require 'hpricot'
|
4
|
-
require 'concordion_instrumenter'
|
5
|
-
|
6
|
-
class ConcordionParser
|
7
|
-
@@ALL_ATTRIBUTED_ELEMENTS = "/html/body//*[@*]"
|
8
|
-
|
9
|
-
include ConcordionUtility
|
10
|
-
|
11
|
-
attr_accessor :root, :body, :html
|
12
|
-
|
13
|
-
def initialize(reader, concordion)
|
14
|
-
@reader = reader
|
15
|
-
@concordion = concordion
|
16
|
-
@verifier = concordion.verifier
|
17
|
-
@instrumenter = ConcordionInstrumenter.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse(filename)
|
21
|
-
@root = Hpricot.parse(@reader.read(filename))
|
22
|
-
@body = @root.at("body")
|
23
|
-
@html = @root.at("html")
|
24
|
-
end
|
25
|
-
def each_concordion_element(&block)
|
26
|
-
@root.search(@@ALL_ATTRIBUTED_ELEMENTS).each {|elem|
|
27
|
-
yield elem
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def each_eligible_concordion_element(&block)
|
34
|
-
each_concordion_element do |elem|
|
35
|
-
if concordion_cmd_attr_exists?(elem)
|
36
|
-
attr = concordion_cmd_attr_for(elem)
|
37
|
-
@verifier.update_row(elem)
|
38
|
-
if !@instrumenter.instrument_from_headers(elem, attr, @root)
|
39
|
-
yield elem
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
data/lib/concordion_processor.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'concordion_utility'
|
2
|
-
|
3
|
-
class ConcordionProcessor
|
4
|
-
include ConcordionUtility
|
5
|
-
|
6
|
-
def initialize(concordion, decorator)
|
7
|
-
@concordion = concordion
|
8
|
-
@decorator = decorator
|
9
|
-
end
|
10
|
-
|
11
|
-
def process(tag, test_context)
|
12
|
-
attr = concordion_cmd_attr_for(tag)
|
13
|
-
instrumented_value = tag.get_attribute(attr)
|
14
|
-
cpr = create_parse_result(tag, attr, instrumented_value)
|
15
|
-
rv = @concordion.evaluate(cpr, test_context, self)
|
16
|
-
@decorator.decorate_tag(rv, tag, cpr)
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_parse_result(tag, attr, value)
|
20
|
-
ConcordionParseResult.new(instrumentation(attr), value, tag.inner_text, tag)
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
data/lib/concordion_reader.rb
DELETED
data/lib/concordion_state.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'concordion_utility'
|
2
|
-
require 'concordion_lookahead_handler'
|
3
|
-
require 'concordion_verifier'
|
4
|
-
require 'concordion_invoker'
|
5
|
-
require 'concordion_binder'
|
6
|
-
|
7
|
-
# Concordion State manages memory for Concordion specs as they are being parsed (e.g. when #var is declared in a spec, this class holds the memory reference).
|
8
|
-
|
9
|
-
|
10
|
-
class ConcordionState
|
11
|
-
include ConcordionUtility
|
12
|
-
|
13
|
-
@@TEXT_VAR = "#TEXT"
|
14
|
-
def self.TEXT_VAR
|
15
|
-
@@TEXT_VAR
|
16
|
-
end
|
17
|
-
attr_reader :verification_variable, :verifier
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@memory = {}
|
21
|
-
@lookahead_handler = ConcordionLookaheadHandler.new
|
22
|
-
@verifier = ConcordionVerifier.new(self)
|
23
|
-
@invoker = ConcordionInvoker.new(self)
|
24
|
-
@binder = ConcordionBinder.new(self)
|
25
|
-
set_variable(@@TEXT_VAR, @@TEXT_VAR)
|
26
|
-
end
|
27
|
-
|
28
|
-
def set_variable(variable, value)
|
29
|
-
@memory[variable] = value
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_variable(variable)
|
33
|
-
@memory[variable]
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
# Deferences concordion method calls.
|
38
|
-
# For example if memory held:
|
39
|
-
# * #foo => 12
|
40
|
-
# * #bar => 4
|
41
|
-
# Then the following mappings hold:
|
42
|
-
# * #foo => 12
|
43
|
-
# * #foo.to_f => 12.0
|
44
|
-
# * method(#foo, #bar) => method(12, 4)
|
45
|
-
|
46
|
-
def dereference(conc_call)
|
47
|
-
var_name = concordion_variable_name(conc_call)
|
48
|
-
var = get_variable(var_name)
|
49
|
-
|
50
|
-
if !has_property_reference?(conc_call)
|
51
|
-
return var
|
52
|
-
end
|
53
|
-
|
54
|
-
var.send(concordion_property_reference(conc_call))
|
55
|
-
end
|
56
|
-
|
57
|
-
# Evaluate an expression
|
58
|
-
# 1. Lookahead in the tag to see if needed variables are bound later.
|
59
|
-
# 2. Bind a value to the variable from the spec, if needed. Returns early if bound successfully.
|
60
|
-
# 3. Update the current value of the iterator for verification commands, if needed.
|
61
|
-
# 4. Invoke the system under test
|
62
|
-
# 5. Bind a value to the variable on the left hand side of an equation, if needed.
|
63
|
-
# 6. Hand the system under test return value to the concordion invoker, which makes the assertion.
|
64
|
-
def evaluate(cpr, test_context, processor)
|
65
|
-
@lookahead_handler.handle_lookahead(cpr, test_context, processor)
|
66
|
-
|
67
|
-
return { :result => true } if @binder.bind_if_set_command(cpr)
|
68
|
-
|
69
|
-
@verifier.update_if_verify_command(cpr)
|
70
|
-
|
71
|
-
sut_rv = @invoker.invoke_sut(cpr, test_context)
|
72
|
-
@binder.handle_assignment(cpr, sut_rv)
|
73
|
-
conc_rv = @invoker.invoke_concordion(cpr, sut_rv)
|
74
|
-
|
75
|
-
conc_rv
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
|
2
|
-
module SnakeCaseUtility
|
3
|
-
|
4
|
-
def snake_case(str)
|
5
|
-
s = str.gsub( /([A-Z])/, '_\1')
|
6
|
-
if s.index("_") == 0
|
7
|
-
s = s.slice(1, s.length)
|
8
|
-
end
|
9
|
-
|
10
|
-
s.downcase
|
11
|
-
end
|
12
|
-
|
13
|
-
def snake_cased_test_name(str)
|
14
|
-
s = snake_case(str)
|
15
|
-
s = s.gsub(/_test$/, '')
|
16
|
-
"#{s}.html"
|
17
|
-
end
|
18
|
-
|
19
|
-
def snake_cased_goldmaster_name(str)
|
20
|
-
snake_cased_test_name(str).gsub(".html", "_goldmaster.html")
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
module PluralToSingularUtility
|
26
|
-
|
27
|
-
def singular(str)
|
28
|
-
str.sub(/s$/, "")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module ConcordionStringUtility
|
33
|
-
include SnakeCaseUtility
|
34
|
-
include PluralToSingularUtility
|
35
|
-
|
36
|
-
def has_arguments?(name)
|
37
|
-
!(ends_in_empty_parens?(name) || is_direct_method_call?(name))
|
38
|
-
end
|
39
|
-
|
40
|
-
def is_direct_method_call?(name)
|
41
|
-
name =~ /^[\w]+$/
|
42
|
-
end
|
43
|
-
|
44
|
-
def ends_in_empty_parens?(name)
|
45
|
-
name =~ /\(\)$/
|
46
|
-
end
|
47
|
-
|
48
|
-
def concordion_assignment(name)
|
49
|
-
name.split("=")[0].strip
|
50
|
-
end
|
51
|
-
|
52
|
-
def has_assignment?(name)
|
53
|
-
name =~ /=/
|
54
|
-
end
|
55
|
-
|
56
|
-
def attr_writer_method?(name)
|
57
|
-
name =~ /=$/
|
58
|
-
end
|
59
|
-
|
60
|
-
def concordion_method_name(name)
|
61
|
-
if name =~ /\(/
|
62
|
-
base = name.split("(")[0].strip
|
63
|
-
else
|
64
|
-
|
65
|
-
|
66
|
-
base = name.strip
|
67
|
-
if base =~ /\s/
|
68
|
-
|
69
|
-
if base =~ /=/ && base =~ /^#/
|
70
|
-
base = base.split("=")[1].strip
|
71
|
-
end
|
72
|
-
elements = base.split(/\s/)
|
73
|
-
base = elements[0]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
if !has_assignment?(base)
|
78
|
-
return base
|
79
|
-
end
|
80
|
-
|
81
|
-
if attr_writer_method?(base)
|
82
|
-
return base if base.count("=") == 1
|
83
|
-
return assignment(base) + "="
|
84
|
-
end
|
85
|
-
|
86
|
-
assignment(base)
|
87
|
-
end
|
88
|
-
|
89
|
-
def assignment(base)
|
90
|
-
base.split("=")[1].strip
|
91
|
-
end
|
92
|
-
|
93
|
-
def escape_single_quotes(s)
|
94
|
-
s.gsub(/[']/, '\\\\\\\\\'')
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,132 +0,0 @@
|
|
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 = ConcordionState.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
|
-
if self.class.method_defined?(:css_type)
|
58
|
-
config[:decorator].add_concordion_css_link(config[:parser].root, config[:parser].html, css_type)
|
59
|
-
else
|
60
|
-
config[:decorator].add_concordion_css_link(config[:parser].root, config[:parser].html, config[:css_type])
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def run_spec(filename, config)
|
66
|
-
failures = []
|
67
|
-
config[:parser].each_eligible_concordion_element do |elem|
|
68
|
-
failure = config[:processor].process(elem, self)
|
69
|
-
failures << failure unless failure.nil?
|
70
|
-
end
|
71
|
-
failures
|
72
|
-
end
|
73
|
-
|
74
|
-
def report_spec(filename, config, failures)
|
75
|
-
config[:decorator].add_css_file_to_output_dir(config[:writer], config[:css_type])
|
76
|
-
|
77
|
-
writer = config[:writer]
|
78
|
-
if self.class.method_defined?(:rcor_writer)
|
79
|
-
writer = rcor_writer()
|
80
|
-
end
|
81
|
-
|
82
|
-
outfilename = writer.calculate_filename_and_overwrite(config[:parser].root, filename)
|
83
|
-
assert_no_failures(outfilename, config, failures)
|
84
|
-
end
|
85
|
-
|
86
|
-
def assert_no_failures(outfilename, config, failures)
|
87
|
-
expected = @@EXPECTED_FAILURE_COUNT
|
88
|
-
|
89
|
-
if self.class.method_defined?(:expected_failure_count)
|
90
|
-
expected = expected_failure_count()
|
91
|
-
end
|
92
|
-
|
93
|
-
message = build_message "#{show_failures(failures)}\nWrote output to #{outfilename}.",
|
94
|
-
'Actual failure count <?> did not match expected <?>.',
|
95
|
-
failures.size, expected
|
96
|
-
assert_block message do
|
97
|
-
failures.size == expected
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def show_failures(failures)
|
102
|
-
rv = ""
|
103
|
-
failures.each_with_index do |failure, index|
|
104
|
-
rv += "[Error:#{index + 1}] #{failure}\n"
|
105
|
-
end
|
106
|
-
rv
|
107
|
-
end
|
108
|
-
|
109
|
-
def assert_concordion_document(config)
|
110
|
-
assert_equal "http://www.concordion.org/2007/concordion", config[:parser].html.get_attribute("xmlns:concordion")
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
module ConcordionTestMethods
|
116
|
-
include ConcordionInternalTestMethods
|
117
|
-
extend ConcordionConfigMethods
|
118
|
-
|
119
|
-
class << self
|
120
|
-
alias_method :original_included, :included
|
121
|
-
end
|
122
|
-
|
123
|
-
def self.included(cmod)
|
124
|
-
original_included(cmod)
|
125
|
-
conf = default_config
|
126
|
-
cm = class << cmod
|
127
|
-
include ConcordionConfigMethods
|
128
|
-
end
|
129
|
-
|
130
|
-
bind_test_method_to(cmod, conf)
|
131
|
-
end
|
132
|
-
end
|
data/lib/concordion_utility.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'concordion_constants'
|
3
|
-
require 'concordion_string_utility'
|
4
|
-
|
5
|
-
|
6
|
-
module ConcordionUtility
|
7
|
-
include ConcordionConstants
|
8
|
-
include ConcordionStringUtility
|
9
|
-
|
10
|
-
def instrumentation(attr)
|
11
|
-
attr.split(":")[1]
|
12
|
-
end
|
13
|
-
|
14
|
-
def concordion_arguments(name)
|
15
|
-
return [] unless has_arguments?(name)
|
16
|
-
arg_string = nil
|
17
|
-
if name =~ /\(/
|
18
|
-
name_no_end_paren = name.gsub(")", '')
|
19
|
-
arg_string = name_no_end_paren.split("(")[1]
|
20
|
-
else
|
21
|
-
|
22
|
-
base = name.strip
|
23
|
-
if base =~ /=/
|
24
|
-
arg_string = nil
|
25
|
-
base = base.split("=")[1].strip
|
26
|
-
end
|
27
|
-
tokens = base.split(" ").compact
|
28
|
-
arg_string = tokens.slice(1, tokens.size - 1).join(" ")
|
29
|
-
end
|
30
|
-
|
31
|
-
arg_string.split(",").collect { |arg| arg.strip }
|
32
|
-
end
|
33
|
-
def concordion_variable_name(conc_call)
|
34
|
-
if has_property_reference?(conc_call)
|
35
|
-
return conc_call.split(".")[0].strip
|
36
|
-
end
|
37
|
-
|
38
|
-
conc_call.strip
|
39
|
-
end
|
40
|
-
|
41
|
-
def has_property_reference?(conc_call)
|
42
|
-
conc_call =~ /\./
|
43
|
-
end
|
44
|
-
|
45
|
-
def concordion_property_reference(conc_call)
|
46
|
-
if !has_property_reference?(conc_call)
|
47
|
-
return conc_call
|
48
|
-
end
|
49
|
-
idx = conc_call.index(".")
|
50
|
-
conc_call.slice(idx + 1, conc_call.length - idx).strip
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def concordion_cmd_attr_exists?(elem)
|
56
|
-
!concordion_cmd_attr_for(elem).nil?
|
57
|
-
end
|
58
|
-
|
59
|
-
def concordion_cmd_attr_for(elem)
|
60
|
-
concordion_command_attributes.each {|attr|
|
61
|
-
instrumented_value = elem.get_attribute(attr)
|
62
|
-
if !instrumented_value.nil?
|
63
|
-
return attr
|
64
|
-
end
|
65
|
-
}
|
66
|
-
|
67
|
-
nil
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
data/lib/concordion_verifier.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'concordion_utility'
|
2
|
-
|
3
|
-
class ConcordionVerifier
|
4
|
-
include ConcordionUtility
|
5
|
-
|
6
|
-
@@ROW_REGEXP = /tr:nth\((\d+)\)/
|
7
|
-
attr_accessor :verification_variable
|
8
|
-
def initialize(concordion)
|
9
|
-
@concordion = concordion
|
10
|
-
@verification_variable = nil
|
11
|
-
@last_row = -1
|
12
|
-
end
|
13
|
-
|
14
|
-
def update_if_verify_command(cpr)
|
15
|
-
if cpr.is_verify_command?
|
16
|
-
@verification_variable = cpr.assignment
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def update_verifier(idx)
|
21
|
-
return if verification_variable.nil?
|
22
|
-
arr = @concordion.get_variable(verification_variable)
|
23
|
-
index = idx < 1 ? 0 : idx - 1
|
24
|
-
|
25
|
-
value = arr[index]
|
26
|
-
@concordion.set_variable(singular(verification_variable), value)
|
27
|
-
end
|
28
|
-
|
29
|
-
def verification_variable=(value)
|
30
|
-
@verification_variable = value
|
31
|
-
|
32
|
-
unless @verification_variable.nil?
|
33
|
-
update_verifier(0)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
def update_row(elem)
|
37
|
-
on_row = @@ROW_REGEXP.match(elem.css_path)
|
38
|
-
if on_row
|
39
|
-
current_row = on_row.captures[0]
|
40
|
-
if current_row != @last_row
|
41
|
-
update_verifier(current_row.to_i)
|
42
|
-
@last_row = current_row
|
43
|
-
end
|
44
|
-
else
|
45
|
-
@last_row = -1
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
data/lib/concordion_writer.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
class ConcordionWriter
|
2
|
-
@@DEFAULT = "."
|
3
|
-
def initialize(output_dir = @@DEFAULT)
|
4
|
-
@output_dir = output_dir.nil? ? @@DEFAULT : output_dir
|
5
|
-
end
|
6
|
-
|
7
|
-
def write(data, filename)
|
8
|
-
f = File.new(filename, "w")
|
9
|
-
f.puts data
|
10
|
-
f.close
|
11
|
-
end
|
12
|
-
|
13
|
-
def output_file_exists?(filename)
|
14
|
-
exists?(base_filename(filename))
|
15
|
-
end
|
16
|
-
|
17
|
-
def exists?(filename)
|
18
|
-
File.exists?(filename)
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete_if_exists(filename)
|
22
|
-
if exists?(filename)
|
23
|
-
File.delete(filename)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def calculate_filename_and_overwrite(data, filename)
|
29
|
-
outfile = output_filename_for(filename)
|
30
|
-
delete_if_exists(outfile)
|
31
|
-
write(data, outfile)
|
32
|
-
|
33
|
-
outfile
|
34
|
-
end
|
35
|
-
|
36
|
-
def base_filename(filename)
|
37
|
-
File.join(@output_dir, filename)
|
38
|
-
end
|
39
|
-
def output_filename_for(name)
|
40
|
-
base_filename(name.sub(".html", "_test_output.html"))
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/lib/loader_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
-
raise RuntimeError.new("could not find '#{filename}' on the system load path")
|
15
|
-
end
|
16
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'concordion_css_decorator'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'mocha'
|
5
|
-
|
6
|
-
class ConcordionCssDecoratorTest < Test::Unit::TestCase
|
7
|
-
def test_does_not_write_if_file_exists
|
8
|
-
writer = mock("writer")
|
9
|
-
writer.expects(:output_file_exists?).with("concordion.css").once.returns(true)
|
10
|
-
|
11
|
-
ConcordionCSSDecorator.new.add_css_file_to_output_dir(writer, :link)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_writes_if_file_does_not_exist
|
15
|
-
writer = mock("writer")
|
16
|
-
writer.expects(:output_file_exists?).with("concordion.css").once.returns(false)
|
17
|
-
writer.expects(:calculate_filename_and_overwrite).with(anything, "concordion.css").once
|
18
|
-
|
19
|
-
ConcordionCSSDecorator.new.add_css_file_to_output_dir(writer, :link)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_does_not_write_if_not_link_eg_inline
|
23
|
-
writer = mock("writer")
|
24
|
-
writer.expects(:output_file_exists?).with("concordion.css").once.returns(false)
|
25
|
-
|
26
|
-
ConcordionCSSDecorator.new.add_css_file_to_output_dir(writer, :inline)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'concordion_environment'
|
3
|
-
|
4
|
-
class ConcordionEnvironmentTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_output_dir
|
7
|
-
restore_env do
|
8
|
-
ENV[ConcordionEnvironment.output_dir_key] = nil
|
9
|
-
assert_equal ".", ConcordionEnvironment.output_dir
|
10
|
-
ENV[ConcordionEnvironment.output_dir_key] = "foo/bar"
|
11
|
-
assert_equal "foo/bar", ConcordionEnvironment.output_dir
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_clean_list
|
16
|
-
restore_env do
|
17
|
-
ENV[ConcordionEnvironment.output_dir_key] = nil
|
18
|
-
assert_equal ["./*_test_output.html", "./concordion.css"], ConcordionEnvironment.clean_list
|
19
|
-
ENV[ConcordionEnvironment.output_dir_key] = "foo/bar"
|
20
|
-
assert_equal ["foo/bar/*_test_output.html", "foo/bar/concordion.css"], ConcordionEnvironment.clean_list
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_css_type_defaults_to_inline
|
26
|
-
restore_env do
|
27
|
-
ENV[ConcordionEnvironment.css_type_key] = "link"
|
28
|
-
assert_equal :link, ConcordionEnvironment.css_type
|
29
|
-
|
30
|
-
ENV[ConcordionEnvironment.css_type_key] = nil
|
31
|
-
assert_equal :inline, ConcordionEnvironment.css_type
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def restore_env
|
38
|
-
orig_dir = ENV[ConcordionEnvironment.output_dir_key]
|
39
|
-
orig_type = ENV[ConcordionEnvironment.css_type_key]
|
40
|
-
yield
|
41
|
-
ENV[ConcordionEnvironment.output_dir_key] = orig_dir
|
42
|
-
ENV[ConcordionEnvironment.css_type_key] = orig_type.to_s
|
43
|
-
end
|
44
|
-
end
|