concordion 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README +10 -0
- data/Rakefile.rb +69 -0
- data/html/classes/ConcordionBinder.html +176 -0
- data/html/classes/ConcordionBinder.src/M000042.html +18 -0
- data/html/classes/ConcordionBinder.src/M000043.html +23 -0
- data/html/classes/ConcordionBinder.src/M000044.html +20 -0
- data/html/classes/ConcordionCSS.html +146 -0
- data/html/classes/ConcordionCSS.src/M000100.html +18 -0
- data/html/classes/ConcordionCSS.src/M000101.html +20 -0
- data/html/classes/ConcordionCSSDecorator.html +242 -0
- data/html/classes/ConcordionCSSDecorator.src/M000011.html +25 -0
- data/html/classes/ConcordionCSSDecorator.src/M000012.html +18 -0
- data/html/classes/ConcordionCSSDecorator.src/M000013.html +18 -0
- data/html/classes/ConcordionCSSDecorator.src/M000014.html +18 -0
- data/html/classes/ConcordionCSSDecorator.src/M000015.html +18 -0
- data/html/classes/ConcordionCSSDecorator.src/M000016.html +18 -0
- data/html/classes/ConcordionCSSDecorator.src/M000017.html +20 -0
- data/html/classes/ConcordionCSSDecorator.src/M000018.html +29 -0
- data/html/classes/ConcordionConfigMethods.html +146 -0
- data/html/classes/ConcordionConfigMethods.src/M000123.html +30 -0
- data/html/classes/ConcordionConfigMethods.src/M000124.html +26 -0
- data/html/classes/ConcordionConstants.html +146 -0
- data/html/classes/ConcordionConstants.src/M000121.html +20 -0
- data/html/classes/ConcordionConstants.src/M000122.html +18 -0
- data/html/classes/ConcordionEnvironment.html +212 -0
- data/html/classes/ConcordionEnvironment.src/M000022.html +18 -0
- data/html/classes/ConcordionEnvironment.src/M000023.html +18 -0
- data/html/classes/ConcordionEnvironment.src/M000024.html +18 -0
- data/html/classes/ConcordionEnvironment.src/M000025.html +18 -0
- data/html/classes/ConcordionEnvironment.src/M000026.html +19 -0
- data/html/classes/ConcordionEnvironment.src/M000027.html +19 -0
- data/html/classes/ConcordionErrorCondition.html +179 -0
- data/html/classes/ConcordionErrorCondition.src/M000032.html +22 -0
- data/html/classes/ConcordionErrorCondition.src/M000033.html +25 -0
- data/html/classes/ConcordionInstrumenter.html +152 -0
- data/html/classes/ConcordionInstrumenter.src/M000045.html +30 -0
- data/html/classes/ConcordionInstrumenter.src/M000046.html +22 -0
- data/html/classes/ConcordionInternalTestMethods.html +213 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000094.html +25 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000095.html +23 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000096.html +26 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000097.html +29 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000098.html +22 -0
- data/html/classes/ConcordionInternalTestMethods.src/M000099.html +18 -0
- data/html/classes/ConcordionInvoker.html +327 -0
- data/html/classes/ConcordionInvoker.src/M000058.html +18 -0
- data/html/classes/ConcordionInvoker.src/M000059.html +26 -0
- data/html/classes/ConcordionInvoker.src/M000060.html +23 -0
- data/html/classes/ConcordionInvoker.src/M000061.html +26 -0
- data/html/classes/ConcordionInvoker.src/M000062.html +27 -0
- data/html/classes/ConcordionInvoker.src/M000063.html +22 -0
- data/html/classes/ConcordionInvoker.src/M000064.html +25 -0
- data/html/classes/ConcordionInvoker.src/M000065.html +26 -0
- data/html/classes/ConcordionInvoker.src/M000066.html +18 -0
- data/html/classes/ConcordionInvoker.src/M000067.html +18 -0
- data/html/classes/ConcordionInvoker.src/M000068.html +18 -0
- data/html/classes/ConcordionInvoker.src/M000069.html +26 -0
- data/html/classes/ConcordionInvoker.src/M000070.html +35 -0
- data/html/classes/ConcordionLookaheadHandler.html +152 -0
- data/html/classes/ConcordionLookaheadHandler.src/M000028.html +18 -0
- data/html/classes/ConcordionLookaheadHandler.src/M000029.html +22 -0
- data/html/classes/ConcordionParseResult.html +369 -0
- data/html/classes/ConcordionParseResult.src/M000076.html +21 -0
- data/html/classes/ConcordionParseResult.src/M000077.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000078.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000079.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000080.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000081.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000082.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000083.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000084.html +19 -0
- data/html/classes/ConcordionParseResult.src/M000085.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000086.html +18 -0
- data/html/classes/ConcordionParseResult.src/M000087.html +21 -0
- data/html/classes/ConcordionParseResult.src/M000088.html +22 -0
- data/html/classes/ConcordionParseResult.src/M000089.html +22 -0
- data/html/classes/ConcordionParser.html +214 -0
- data/html/classes/ConcordionParser.src/M000002.html +21 -0
- data/html/classes/ConcordionParser.src/M000003.html +20 -0
- data/html/classes/ConcordionParser.src/M000004.html +20 -0
- data/html/classes/ConcordionParser.src/M000005.html +26 -0
- data/html/classes/ConcordionProcessor.html +176 -0
- data/html/classes/ConcordionProcessor.src/M000019.html +19 -0
- data/html/classes/ConcordionProcessor.src/M000020.html +22 -0
- data/html/classes/ConcordionProcessor.src/M000021.html +18 -0
- data/html/classes/ConcordionReader.html +144 -0
- data/html/classes/ConcordionReader.src/M000001.html +18 -0
- data/html/classes/ConcordionState.html +299 -0
- data/html/classes/ConcordionState.src/M000052.html +18 -0
- data/html/classes/ConcordionState.src/M000053.html +23 -0
- data/html/classes/ConcordionState.src/M000054.html +18 -0
- data/html/classes/ConcordionState.src/M000055.html +18 -0
- data/html/classes/ConcordionState.src/M000056.html +25 -0
- data/html/classes/ConcordionState.src/M000057.html +28 -0
- data/html/classes/ConcordionStringUtility.html +259 -0
- data/html/classes/ConcordionStringUtility.src/M000102.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000103.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000104.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000105.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000106.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000107.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000108.html +43 -0
- data/html/classes/ConcordionStringUtility.src/M000109.html +18 -0
- data/html/classes/ConcordionStringUtility.src/M000110.html +18 -0
- data/html/classes/ConcordionStringWriter.html +165 -0
- data/html/classes/ConcordionStringWriter.src/M000030.html +19 -0
- data/html/classes/ConcordionStringWriter.src/M000031.html +18 -0
- data/html/classes/ConcordionTestCase.html +220 -0
- data/html/classes/ConcordionTestCase.src/M000006.html +19 -0
- data/html/classes/ConcordionTestCase.src/M000007.html +19 -0
- data/html/classes/ConcordionTestCase.src/M000008.html +19 -0
- data/html/classes/ConcordionTestCase.src/M000009.html +18 -0
- data/html/classes/ConcordionTestCase.src/M000010.html +18 -0
- data/html/classes/ConcordionTestMethods.html +151 -0
- data/html/classes/ConcordionTestMethods.src/M000092.html +24 -0
- data/html/classes/ConcordionUtility.html +229 -0
- data/html/classes/ConcordionUtility.src/M000114.html +18 -0
- data/html/classes/ConcordionUtility.src/M000115.html +34 -0
- data/html/classes/ConcordionUtility.src/M000116.html +22 -0
- data/html/classes/ConcordionUtility.src/M000117.html +18 -0
- data/html/classes/ConcordionUtility.src/M000118.html +22 -0
- data/html/classes/ConcordionUtility.src/M000119.html +18 -0
- data/html/classes/ConcordionUtility.src/M000120.html +25 -0
- data/html/classes/ConcordionVerifier.html +219 -0
- data/html/classes/ConcordionVerifier.src/M000071.html +20 -0
- data/html/classes/ConcordionVerifier.src/M000072.html +20 -0
- data/html/classes/ConcordionVerifier.src/M000073.html +23 -0
- data/html/classes/ConcordionVerifier.src/M000074.html +22 -0
- data/html/classes/ConcordionVerifier.src/M000075.html +28 -0
- data/html/classes/ConcordionWriter.html +244 -0
- data/html/classes/ConcordionWriter.src/M000034.html +18 -0
- data/html/classes/ConcordionWriter.src/M000035.html +20 -0
- data/html/classes/ConcordionWriter.src/M000036.html +18 -0
- data/html/classes/ConcordionWriter.src/M000037.html +18 -0
- data/html/classes/ConcordionWriter.src/M000038.html +21 -0
- data/html/classes/ConcordionWriter.src/M000039.html +22 -0
- data/html/classes/ConcordionWriter.src/M000040.html +18 -0
- data/html/classes/ConcordionWriter.src/M000041.html +18 -0
- data/html/classes/FailConditionally.html +131 -0
- data/html/classes/FailConditionally.src/M000090.html +22 -0
- data/html/classes/GoldmasterTestCase.html +208 -0
- data/html/classes/GoldmasterTestCase.src/M000047.html +22 -0
- data/html/classes/GoldmasterTestCase.src/M000048.html +18 -0
- data/html/classes/GoldmasterTestCase.src/M000049.html +18 -0
- data/html/classes/GoldmasterTestCase.src/M000050.html +18 -0
- data/html/classes/GoldmasterTestCase.src/M000051.html +31 -0
- data/html/classes/LoaderHelper.html +138 -0
- data/html/classes/LoaderHelper.src/M000093.html +24 -0
- data/html/classes/PluralToSingularUtility.html +131 -0
- data/html/classes/PluralToSingularUtility.src/M000091.html +18 -0
- data/html/classes/SnakeCaseUtility.html +161 -0
- data/html/classes/SnakeCaseUtility.src/M000111.html +23 -0
- data/html/classes/SnakeCaseUtility.src/M000112.html +20 -0
- data/html/classes/SnakeCaseUtility.src/M000113.html +18 -0
- data/html/created.rid +1 -0
- data/html/files/README.html +123 -0
- data/html/files/lib/concordion_binder_rb.html +108 -0
- data/html/files/lib/concordion_constants_rb.html +101 -0
- data/html/files/lib/concordion_css_decorator_rb.html +109 -0
- data/html/files/lib/concordion_css_rb.html +101 -0
- data/html/files/lib/concordion_environment_rb.html +101 -0
- data/html/files/lib/concordion_error_condition_rb.html +108 -0
- data/html/files/lib/concordion_instrumenter_rb.html +101 -0
- data/html/files/lib/concordion_invoker_rb.html +109 -0
- data/html/files/lib/concordion_lookahead_handler_rb.html +101 -0
- data/html/files/lib/concordion_parse_result_rb.html +108 -0
- data/html/files/lib/concordion_parser_rb.html +110 -0
- data/html/files/lib/concordion_processor_rb.html +108 -0
- data/html/files/lib/concordion_rb.html +108 -0
- data/html/files/lib/concordion_reader_rb.html +108 -0
- data/html/files/lib/concordion_state_rb.html +112 -0
- data/html/files/lib/concordion_string_utility_rb.html +101 -0
- data/html/files/lib/concordion_string_writer_rb.html +101 -0
- data/html/files/lib/concordion_test_case_rb.html +119 -0
- data/html/files/lib/concordion_test_methods_rb.html +125 -0
- data/html/files/lib/concordion_utility_rb.html +109 -0
- data/html/files/lib/concordion_verifier_rb.html +108 -0
- data/html/files/lib/concordion_writer_rb.html +101 -0
- data/html/files/lib/goldmaster_test_case_rb.html +110 -0
- data/html/files/lib/loader_helper_rb.html +108 -0
- data/html/files/lib/rcor_rb.html +108 -0
- data/html/fr_class_index.html +54 -0
- data/html/fr_file_index.html +52 -0
- data/html/fr_method_index.html +150 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/concordion.rb +2 -0
- data/lib/concordion_binder.rb +24 -0
- data/lib/concordion_constants.rb +13 -0
- data/lib/concordion_css.rb +179 -0
- data/lib/concordion_css_decorator.rb +58 -0
- data/lib/concordion_environment.rb +27 -0
- data/lib/concordion_error_condition.rb +26 -0
- data/lib/concordion_instrumenter.rb +30 -0
- data/lib/concordion_invoker.rb +137 -0
- data/lib/concordion_lookahead_handler.rb +17 -0
- data/lib/concordion_parse_result.rb +72 -0
- data/lib/concordion_parser.rb +47 -0
- data/lib/concordion_processor.rb +25 -0
- data/lib/concordion_reader.rb +10 -0
- data/lib/concordion_state.rb +78 -0
- data/lib/concordion_string_utility.rb +97 -0
- data/lib/concordion_string_writer.rb +13 -0
- data/lib/concordion_test_case.rb +47 -0
- data/lib/concordion_test_methods.rb +132 -0
- data/lib/concordion_utility.rb +70 -0
- data/lib/concordion_verifier.rb +50 -0
- data/lib/concordion_writer.rb +43 -0
- data/lib/goldmaster_test_case.rb +55 -0
- data/lib/loader_helper.rb +16 -0
- data/lib/rcor.rb +3 -0
- data/nbproject/private/config.properties +0 -0
- data/nbproject/private/private.properties +4 -0
- data/nbproject/private/private.xml +4 -0
- data/nbproject/private/rake-d.txt +21 -0
- data/nbproject/project.properties +11 -0
- data/nbproject/project.xml +16 -0
- data/test-lib/single_row_result.rb +9 -0
- data/test-lib/user.rb +8 -0
- data/tests/basic_assert.html +5 -0
- data/tests/basic_assert_test.rb +9 -0
- data/tests/basic_set.html +11 -0
- data/tests/basic_set_test.rb +8 -0
- data/tests/basic_text.html +14 -0
- data/tests/basic_text_test.rb +23 -0
- data/tests/concordion/concordion_css_decorator_test.rb +28 -0
- data/tests/concordion/concordion_environment_test.rb +44 -0
- data/tests/concordion/concordion_parse_result_test.rb +51 -0
- data/tests/concordion/concordion_reader_test.rb +15 -0
- data/tests/concordion/concordion_state_test.rb +38 -0
- data/tests/concordion/concordion_string_writer_test.rb +13 -0
- data/tests/concordion/concordion_utility_test.rb +135 -0
- data/tests/concordion/concordion_verifier_test.rb +38 -0
- data/tests/concordion/concordion_writer_test.rb +26 -0
- data/tests/concordion/goldmaster_test_case_test.rb +24 -0
- data/tests/concordion.css +2 -0
- data/tests/failing.html +9 -0
- data/tests/failing_test.rb +22 -0
- data/tests/goldmasters/failing_with_subclass.html +6 -0
- data/tests/goldmasters/failing_with_subclass_goldmaster.html +170 -0
- data/tests/goldmasters/failing_with_subclass_test.rb +24 -0
- data/tests/goldmasters/goldmaster_assert_true_failing.html +5 -0
- data/tests/goldmasters/goldmaster_assert_true_failing_goldmaster.html +169 -0
- data/tests/goldmasters/goldmaster_assert_true_failing_test.rb +14 -0
- data/tests/goldmasters/goldmaster_failing.html +45 -0
- data/tests/goldmasters/goldmaster_failing_goldmaster.html +209 -0
- data/tests/goldmasters/goldmaster_failing_test.rb +37 -0
- data/tests/goldmasters/goldmaster_malformed.html +7 -0
- data/tests/goldmasters/goldmaster_malformed_goldmaster.html +171 -0
- data/tests/goldmasters/goldmaster_malformed_test.rb +11 -0
- data/tests/goldmasters/goldmaster_passing.html +5 -0
- data/tests/goldmasters/goldmaster_passing_goldmaster.html +169 -0
- data/tests/goldmasters/goldmaster_passing_test.rb +9 -0
- data/tests/goldmasters/goldmaster_table.html +46 -0
- data/tests/goldmasters/goldmaster_table_bug.html +12 -0
- data/tests/goldmasters/goldmaster_table_bug_goldmaster.html +176 -0
- data/tests/goldmasters/goldmaster_table_bug_test.rb +24 -0
- data/tests/goldmasters/goldmaster_table_goldmaster.html +210 -0
- data/tests/goldmasters/goldmaster_table_test.rb +17 -0
- data/tests/image.html +5 -0
- data/tests/image.jpg +0 -0
- data/tests/image_test.rb +9 -0
- data/tests/link_style_css.html +5 -0
- data/tests/link_style_css_test.rb +16 -0
- data/tests/lookahead_assert_true.html +25 -0
- data/tests/lookahead_assert_true_test.rb +17 -0
- data/tests/mixed.html +5 -0
- data/tests/mixed_test.rb +19 -0
- data/tests/nested_element_lookahead.html +9 -0
- data/tests/nested_element_lookahead_test.rb +8 -0
- data/tests/numbers.html +5 -0
- data/tests/numbers_test.rb +11 -0
- data/tests/processes_elements_in_sorted_order.html +12 -0
- data/tests/processes_elements_in_sorted_order_test.rb +13 -0
- data/tests/return_result.html +7 -0
- data/tests/return_result_test.rb +17 -0
- data/tests/tables/single_row_table.html +13 -0
- data/tests/tables/single_row_table_test.rb +9 -0
- data/tests/tables/table.html +28 -0
- data/tests/tables/table_test.rb +9 -0
- data/tests/tables/test_helper.rb +9 -0
- data/tests/tables/verify_rows.html +46 -0
- data/tests/tables/verify_rows_scsr.html +27 -0
- data/tests/tables/verify_rows_scsr_test.rb +17 -0
- data/tests/tables/verify_rows_simple.html +14 -0
- data/tests/tables/verify_rows_simple_test.rb +17 -0
- data/tests/tables/verify_rows_test.rb +16 -0
- data/tests/user-reported/apostrophe.html +7 -0
- data/tests/user-reported/apostrophe_test.rb +18 -0
- data/tests/user-reported/ariel_example.html +13 -0
- data/tests/user-reported/ariel_example_test.rb +36 -0
- data/tests/user-reported/attr_assert.html +7 -0
- data/tests/user-reported/attr_assert_test.rb +13 -0
- data/tests/user-reported/basic_assert_true.html +6 -0
- data/tests/user-reported/basic_assert_true_test.rb +15 -0
- data/tests/user-reported/no_parens.html +15 -0
- data/tests/user-reported/no_parens_test.rb +20 -0
- metadata +403 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
class ConcordionEnvironment
|
3
|
+
def self.output_dir_key
|
4
|
+
'RCOR_OUTPUT_DIR'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.css_type_key
|
8
|
+
'RCOR_CSS_TYPE'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.with_dir(str)
|
12
|
+
File.join(output_dir, str)
|
13
|
+
end
|
14
|
+
def self.clean_list
|
15
|
+
[with_dir("*_test_output.html"), with_dir("concordion.css")] #TODO is this safe to delete? what if the user overwrites this file?
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.css_type
|
19
|
+
type = ENV[css_type_key]
|
20
|
+
type.nil? ? :inline : type.to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.output_dir
|
24
|
+
dir = ENV[output_dir_key]
|
25
|
+
dir.nil? ? "." : dir
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
class ConcordionErrorCondition
|
7
|
+
attr_reader :expected, :actual
|
8
|
+
def initialize(expected, actual, xpath, context = nil, assert_true_command = false)
|
9
|
+
@expected = expected
|
10
|
+
@actual = actual
|
11
|
+
@xpath = xpath
|
12
|
+
@context = context
|
13
|
+
@assert_true_command = assert_true_command
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
@expected = "true" if @assert_true_command
|
18
|
+
|
19
|
+
base = "expected (#{@expected}) but got (#{@actual}) in tag: #{@xpath}"
|
20
|
+
|
21
|
+
|
22
|
+
return base if @context.nil?
|
23
|
+
|
24
|
+
base + "\n\tcontext of error: #{@context}"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
class ConcordionInstrumenter
|
3
|
+
@@TH_CSS_QUERY_REGEXP = /tr:nth\(\d+\) > th:nth\((\d+)\)$/
|
4
|
+
@@TH_CSS_SINGLE_REGEXP = /tr:nth\(\d+\) > th$/
|
5
|
+
|
6
|
+
def instrument_from_headers(elem, attr, root)
|
7
|
+
header = @@TH_CSS_QUERY_REGEXP.match(elem.css_path)
|
8
|
+
if header
|
9
|
+
instrument_column(elem, attr, header.captures, @@TH_CSS_QUERY_REGEXP, root)
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
|
13
|
+
single_header = @@TH_CSS_SINGLE_REGEXP.match(elem.css_path)
|
14
|
+
if single_header
|
15
|
+
instrument_column(elem, attr, 0, @@TH_CSS_SINGLE_REGEXP, root)
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def instrument_column(elem, attr, column_number, regex, root)
|
23
|
+
trimmed = elem.css_path.sub(regex, '')
|
24
|
+
td_css_query = trimmed + "tr > td:nth(#{column_number})"
|
25
|
+
|
26
|
+
value = elem.get_attribute(attr)
|
27
|
+
root.search(td_css_query).set(attr, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'loader_helper'
|
2
|
+
require 'concordion_utility'
|
3
|
+
|
4
|
+
class ConcordionInvoker
|
5
|
+
include LoaderHelper
|
6
|
+
include ConcordionUtility
|
7
|
+
|
8
|
+
def initialize(conc)
|
9
|
+
@concordion = conc
|
10
|
+
end
|
11
|
+
|
12
|
+
def try_to_dereference(cpr)
|
13
|
+
rv = nil
|
14
|
+
begin
|
15
|
+
rv = @concordion.dereference(cpr.system_under_test)
|
16
|
+
rescue NoMethodError => e
|
17
|
+
method = method_from_no_method_error(e)
|
18
|
+
|
19
|
+
rv = dereference_error_message(e)
|
20
|
+
end
|
21
|
+
rv
|
22
|
+
end
|
23
|
+
|
24
|
+
def dereference_error_message(e)
|
25
|
+
rv = "["
|
26
|
+
clazz = e.to_s.split(":")[1]
|
27
|
+
if clazz == 'NilClass'
|
28
|
+
rv += "No more rows"
|
29
|
+
end
|
30
|
+
rv += "]"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def invoke_sut(cpr, test_context)
|
35
|
+
sut_rv = nil
|
36
|
+
if cpr.needs_dereference?
|
37
|
+
sut_rv = try_to_dereference(cpr)
|
38
|
+
else
|
39
|
+
|
40
|
+
sut_rv = try_to_invoke_sut(cpr,test_context)
|
41
|
+
end
|
42
|
+
|
43
|
+
sut_rv
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_args(cpr)
|
47
|
+
arg_vars = concordion_arguments(cpr.system_under_test)
|
48
|
+
arg_values = arg_vars.collect {|var|
|
49
|
+
if var == '#TEXT'
|
50
|
+
cpr.content
|
51
|
+
else
|
52
|
+
@concordion.get_variable(var)
|
53
|
+
end
|
54
|
+
}
|
55
|
+
|
56
|
+
arg_values
|
57
|
+
end
|
58
|
+
|
59
|
+
def arg_values_for(cpr)
|
60
|
+
arg_values = []
|
61
|
+
if has_arguments?(cpr.system_under_test)
|
62
|
+
arg_values = handle_args(cpr)
|
63
|
+
end
|
64
|
+
arg_values
|
65
|
+
end
|
66
|
+
|
67
|
+
def try_to_invoke_sut(cpr, test_context)
|
68
|
+
sut_rv = nil
|
69
|
+
begin
|
70
|
+
conc_method = concordion_method_name(cpr.system_under_test)
|
71
|
+
sut_rv = test_context.send(conc_method, *arg_values_for(cpr))
|
72
|
+
rescue NoMethodError => e
|
73
|
+
sut_rv = report_error(e)
|
74
|
+
end
|
75
|
+
sut_rv
|
76
|
+
end
|
77
|
+
|
78
|
+
def report_error(e)
|
79
|
+
rv = nil
|
80
|
+
if e.to_s =~ /nil:NilClass/
|
81
|
+
rv = "[Parse failed for: #{cpr}, cause: (#{e})]"
|
82
|
+
else
|
83
|
+
method = method_from_no_method_error(e)
|
84
|
+
clazz = class_from_no_method_error(e)
|
85
|
+
rv = "[Missing method '#{method}' in fixture #{clazz} ]"
|
86
|
+
end
|
87
|
+
rv
|
88
|
+
end
|
89
|
+
|
90
|
+
def method_from_no_method_error(e)
|
91
|
+
except_str_from(e).split("`")[1].split("'")[0]
|
92
|
+
end
|
93
|
+
|
94
|
+
def except_str_from(e)
|
95
|
+
e.exception.to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
def class_from_no_method_error(e)
|
99
|
+
except_str_from(e).split("<")[1].split(":")[0]
|
100
|
+
end
|
101
|
+
|
102
|
+
def invoke_concordion(cpr, sut_rv)
|
103
|
+
cmd = commands[cpr.concordion_command]
|
104
|
+
if cpr.is_assert_image_command?
|
105
|
+
cmd.call(sut_rv, cpr.image_location)
|
106
|
+
elsif cpr.is_verify_command?
|
107
|
+
cmd.call(sut_rv, cpr.num_results_expected)
|
108
|
+
else
|
109
|
+
cmd.call(sut_rv, cpr.content)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
def commands
|
116
|
+
cmds = {}
|
117
|
+
cmds["assertequals"] = Proc.new { |a, b|
|
118
|
+
result = (a.to_s == b)
|
119
|
+
{ :result => result, :actual => a, :expected => b } }
|
120
|
+
cmds["execute"] = Proc.new { |a,b|
|
121
|
+
result = true
|
122
|
+
result = false if a.to_s =~ /Missing method/
|
123
|
+
{:result => result, :actual => a, :expected => b } }
|
124
|
+
cmds["verifyrows"] = Proc.new { |a,b| { :result => a.size == b, :actual => a.size, :expected => b } }
|
125
|
+
cmds["asserttrue"] = Proc.new { |a, b|
|
126
|
+
result = a
|
127
|
+
result = false if a.instance_of?(String)
|
128
|
+
{ :result => result, :actual => false, :expected => true } }
|
129
|
+
cmds["assert_image"] = Proc.new { |actual_data, expected_image_url|
|
130
|
+
expected_data = File.read(path_for(expected_image_url))
|
131
|
+
{ :result => actual_data == expected_data, :actual => "[Image data of size #{actual_data.size} omitted]", :expected => "[Expected to match #{expected_image_url}]" }
|
132
|
+
}
|
133
|
+
cmds
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class ConcordionLookaheadHandler
|
3
|
+
|
4
|
+
|
5
|
+
def is_element_setter?(elem)
|
6
|
+
!elem.get_attribute('concordion:set').nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def handle_lookahead(cpr, test_context, processor)
|
10
|
+
cpr.tag.search("/*[@]").each {|child|
|
11
|
+
if is_element_setter?(child)
|
12
|
+
processor.process(child, test_context)
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'concordion_utility'
|
2
|
+
|
3
|
+
class ConcordionParseResult
|
4
|
+
include ConcordionUtility
|
5
|
+
attr_accessor :concordion_command, :system_under_test, :content, :tag
|
6
|
+
def initialize(cmd, sut, content, tag)
|
7
|
+
@concordion_command = cmd
|
8
|
+
@system_under_test = sut
|
9
|
+
@content = content
|
10
|
+
@tag = tag
|
11
|
+
end
|
12
|
+
def to_s
|
13
|
+
"Concordion command[#{@concordion_command}], System under test method[#{@system_under_test}], Tag Content[#{@content}] Image Location[#{image_location}]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_assert_image_command?
|
17
|
+
"assert_image" == @concordion_command
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_set_command?
|
21
|
+
"set" == @concordion_command
|
22
|
+
end
|
23
|
+
def is_verify_command?
|
24
|
+
"verifyrows" == @concordion_command
|
25
|
+
end
|
26
|
+
def is_execute_command?
|
27
|
+
"execute" == @concordion_command
|
28
|
+
end
|
29
|
+
def is_assert_true_command?
|
30
|
+
"asserttrue" == @concordion_command
|
31
|
+
end
|
32
|
+
|
33
|
+
def num_results_expected
|
34
|
+
@tag.search("tr").size - 1
|
35
|
+
end
|
36
|
+
|
37
|
+
def image_location
|
38
|
+
return nil if @tag.nil?
|
39
|
+
@tag.get_attribute('src')
|
40
|
+
end
|
41
|
+
|
42
|
+
def assignment
|
43
|
+
concordion_assignment(@system_under_test)
|
44
|
+
end
|
45
|
+
|
46
|
+
def needs_dereference?
|
47
|
+
@system_under_test =~ /^#/ && @system_under_test.index("=").nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
def verify_error(actual, expected)
|
51
|
+
if actual > expected
|
52
|
+
diff = actual - expected
|
53
|
+
@tag.inner_html += "<tr><td>[#{diff} Surplus Row(s) Returned By Fixture]</td></tr>"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def assertion_error(actual)
|
58
|
+
if is_assert_true_command?
|
59
|
+
@tag.inner_html += ": expected true but received #{actual}"
|
60
|
+
else
|
61
|
+
@tag.inner_html += " expected but received #{actual}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def attribute_error(actual, expected)
|
66
|
+
if is_verify_command?
|
67
|
+
verify_error(actual, expected)
|
68
|
+
else
|
69
|
+
assertion_error(actual)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
@@ -0,0 +1,25 @@
|
|
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
|
@@ -0,0 +1,78 @@
|
|
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
|
@@ -0,0 +1,97 @@
|
|
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
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'concordion_utility'
|
2
|
+
require 'concordion_reader'
|
3
|
+
require 'concordion_parser'
|
4
|
+
require 'concordion_processor'
|
5
|
+
require 'concordion_parse_result'
|
6
|
+
require 'concordion_test_case'
|
7
|
+
require 'concordion_writer'
|
8
|
+
require 'concordion_environment'
|
9
|
+
require 'concordion_state'
|
10
|
+
require 'concordion_css_decorator'
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
require 'concordion_test_methods'
|
14
|
+
|
15
|
+
|
16
|
+
class ConcordionTestCase < Test::Unit::TestCase
|
17
|
+
|
18
|
+
include ConcordionConfigMethods
|
19
|
+
extend ConcordionConfigMethods
|
20
|
+
include ConcordionInternalTestMethods
|
21
|
+
class << self
|
22
|
+
alias_method :original_inherited, :inherited
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.inherited(subclass)
|
26
|
+
original_inherited(subclass)
|
27
|
+
bind_test_method_to(subclass, default_config)
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(arg, conf = default_config())
|
31
|
+
super(arg)
|
32
|
+
@config = default_config.merge(conf)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_something_trivial_to_shut_runit_up
|
36
|
+
assert true
|
37
|
+
trivial
|
38
|
+
end
|
39
|
+
|
40
|
+
def trivial
|
41
|
+
@trivial = true
|
42
|
+
end
|
43
|
+
def is_trivial?
|
44
|
+
@trivial
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|