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/README
ADDED
File without changes
|
data/Rakefile.rb
CHANGED
@@ -4,33 +4,30 @@ require 'rake/testtask'
|
|
4
4
|
require 'rake/packagetask'
|
5
5
|
require 'rake/gempackagetask'
|
6
6
|
require 'rake/clean'
|
7
|
-
require '
|
7
|
+
require 'rcov/rcovtask'
|
8
|
+
require 'lib/concordion/environment'
|
9
|
+
|
10
|
+
PKG_FILES = FileList['**/*'].exclude(/_test_output\.html$/)
|
11
|
+
PKG_VERSION = '0.9.9.5'
|
12
|
+
LIBS = Dir["test-lib","test","test/concordion","test/spec/goldmasters","test/spec","test/spec/structure","test/spec/tables","test/spec/user-reported"]
|
13
|
+
|
14
|
+
ENV['RCOR_OUTPUT_DIR'] ||= File.join(File.expand_path(File.dirname( __FILE__)),'documentation','spec-output')
|
8
15
|
|
9
|
-
|
16
|
+
directory ENV['RCOR_OUTPUT_DIR']
|
10
17
|
|
18
|
+
CLEAN.include(Concordion::Environment.clean_list + ["html"],ENV['RCOR_OUTPUT_DIR'])
|
11
19
|
|
12
20
|
Rake::RDocTask.new do |rd|
|
13
21
|
rd.main = "README"
|
14
22
|
rd.rdoc_files.include("README", "lib/**/*.rb")
|
15
23
|
end
|
16
24
|
|
17
|
-
Rake::TestTask.new do |t|
|
18
|
-
t.libs <<
|
19
|
-
t.
|
20
|
-
t.libs << "tests/goldmasters"
|
21
|
-
t.libs << "tests/tables"
|
22
|
-
t.libs << "tests/user-reported"
|
23
|
-
t.test_files = FileList['tests/**/*_test.rb']
|
25
|
+
Rake::TestTask.new :test => ENV['RCOR_OUTPUT_DIR'] do |t|
|
26
|
+
t.libs << LIBS
|
27
|
+
t.test_files = FileList['test/**/*_test.rb']
|
24
28
|
t.verbose = true
|
25
29
|
end
|
26
30
|
|
27
|
-
task :default => [:clean, :clobber_rdoc, :rdoc, :test]
|
28
|
-
|
29
|
-
task :commit_prep => [:test, :clean, :clobber_rdoc, :clobber_package]
|
30
|
-
|
31
|
-
PKG_FILES = FileList['**/*'].exclude(/_test_output\.html$/)
|
32
|
-
PKG_VERSION = '0.9.9.2'
|
33
|
-
|
34
31
|
spec = Gem::Specification.new do |s|
|
35
32
|
s.platform = Gem::Platform::RUBY
|
36
33
|
s.summary = "Ruby Concordion"
|
@@ -49,21 +46,21 @@ spec = Gem::Specification.new do |s|
|
|
49
46
|
s.files = PKG_FILES
|
50
47
|
end
|
51
48
|
|
52
|
-
Rake::GemPackageTask.new(spec)
|
49
|
+
Rake::GemPackageTask.new(spec) do |package|
|
53
50
|
package.need_zip = true
|
54
51
|
package.need_tar = true
|
55
|
-
|
56
|
-
|
52
|
+
end
|
57
53
|
|
58
|
-
require 'rcov/rcovtask'
|
59
54
|
Rcov::RcovTask.new do |t|
|
60
|
-
t.libs <<
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
t.test_files = FileList['tests/**/*_test.rb']
|
55
|
+
t.libs << LIBS
|
56
|
+
t.test_files = FileList['test/**/*_test.rb']
|
57
|
+
t.rcov_opts << '--sort coverage'
|
58
|
+
t.rcov_opts << '--no-validator-links'
|
59
|
+
t.rcov_opts << '-x gems/*,rcov*,/usr/lib/ruby/1.8/.*,test-lib'
|
67
60
|
t.verbose = true
|
68
|
-
|
61
|
+
end
|
62
|
+
|
63
|
+
task :default => [:clean, :clobber_rdoc, :rdoc, :test]
|
69
64
|
|
65
|
+
desc "Run this task before you commit"
|
66
|
+
task :commit_prep => [:test, :clean, :clobber_rdoc, :clobber_package]
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Ruby Concordion
|
8
|
+
</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>
|
12
|
+
<a name="What_is_it?">What is it?</a>
|
13
|
+
</h1>
|
14
|
+
<p>
|
15
|
+
<a name="What_is_it?">A active specification framework for</a> <a href="http://www.ruby-lang.org" rel="nofollow">Ruby</a>. Based largely on <a href="http://www.concordion.org" rel="nofollow">Concordion</a> for Java, but was influenced by <a href="http://www.fitnesse.org" rel="nofollow">FIT</a> as well.
|
16
|
+
</p>
|
17
|
+
<h1>
|
18
|
+
<a name="What_does_it_do?">What does it do?</a>
|
19
|
+
</h1>
|
20
|
+
<p>
|
21
|
+
<a name="What_does_it_do?">Paraphrasing the definition of Concordion:</a>
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
<a name="What_does_it_do?">Ruby Concordion is an open source framework for Ruby that lets you turn a plain English description of a requirement into an automated test -- an active specification.</a>
|
25
|
+
</p>
|
26
|
+
<h1>
|
27
|
+
<a name="Where_can_I_see_what_it_actually_does?">Where can I see what it actually does?</a>
|
28
|
+
</h1>
|
29
|
+
<p>
|
30
|
+
<a name="Where_can_I_see_what_it_actually_does?">See the</a> <a href="http://code.google.com/p/rcor/w/list" rel="nofollow">wiki</a> for more information on ruby-concordion. In particular the following pages provide good starting points for understanding concordion:
|
31
|
+
</p>
|
32
|
+
<ul>
|
33
|
+
<li>
|
34
|
+
<a href="/p/rcor/wiki/Tutorial">Tutorial</a>
|
35
|
+
</li>
|
36
|
+
<li>
|
37
|
+
<a href="/p/rcor/wiki/RCorOverview">RCorOverview</a>
|
38
|
+
</li>
|
39
|
+
<li>
|
40
|
+
<a href="/p/rcor/wiki/WhatRcorActuallyDoes">WhatRcorActuallyDoes</a>
|
41
|
+
</li>
|
42
|
+
<li>
|
43
|
+
<a href="/p/rcor/wiki/ComplexExample">ComplexExample</a>
|
44
|
+
</li>
|
45
|
+
</ul>
|
46
|
+
<p>
|
47
|
+
Since <a href="http://rubyonrails.org" rel="nofollow">Rails</a> is so widely used lately, a lot of people want to know about using RCor and Rails together. A short demo is available:
|
48
|
+
</p>
|
49
|
+
<ul>
|
50
|
+
<li>
|
51
|
+
<a href="/p/rcor/wiki/RailsAndRCor">RailsAndRCor</a>
|
52
|
+
</li>
|
53
|
+
</ul>
|
54
|
+
<h1>
|
55
|
+
<a name="Where_can_I_get_it?">Where can I get it?</a>
|
56
|
+
</h1>
|
57
|
+
<h3>
|
58
|
+
<a name="Preferred_Method" id="Preferred_Method">Preferred Method</a>
|
59
|
+
</h3>
|
60
|
+
<p>
|
61
|
+
<a name="Preferred_Method" id="Preferred_Method">Click</a> <a href="http://code.google.com/p/rcor/wiki/GemInstallation" rel="nofollow">here</a> for the preferred installation instructions.
|
62
|
+
</p>
|
63
|
+
<h3>
|
64
|
+
<a name="Packaged_Distributions" id="Packaged_Distributions">Packaged Distributions</a>
|
65
|
+
</h3>
|
66
|
+
<p>
|
67
|
+
<a name="Packaged_Distributions" id="Packaged_Distributions">See the</a> <a href="http://code.google.com/p/rcor/downloads/list" rel="nofollow">downloads</a> section for gem, tar and zip distributions.
|
68
|
+
</p>
|
69
|
+
<h3>
|
70
|
+
<a name="Source" id="Source">Source</a>
|
71
|
+
</h3>
|
72
|
+
<p>
|
73
|
+
<a name="Source" id="Source">Click</a> <a href="http://code.google.com/p/rcor/source/browse" rel="nofollow">here</a> to browse the source online.
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
You can checkout a read-only copy of the source using this command:
|
77
|
+
</p>
|
78
|
+
<p>
|
79
|
+
<strong>Anonymous Subversion Access</strong></p><p>This project's SVN repository can be checked out through anonymous access with the following command(s).</p><p><tt>svn checkout http://ruby-concordion.rubyforge.org/svn/</tt><br/>or<br/><tt>svn checkout svn://rubyforge.org/var/svn/ruby-concordion</tt>
|
80
|
+
</p>
|
81
|
+
<h1>
|
82
|
+
<a name="Where_can_I_get_help_or_complain_about_this_thing?">Where can I get help or complain about this thing?</a>
|
83
|
+
</h1>
|
84
|
+
<p>
|
85
|
+
<a name="Where_can_I_get_help_or_complain_about_this_thing?">RCor was written by</a> <a href="http://www.linkedin.com/in/bengoodspeed" rel="nofollow">Ben Goodspeed</a> of <a href="http://goodspeed-it.ca" rel="nofollow">Goodspeed IT Consulting</a>. If you have questions or comments, please post to ruby-concordion@googlegroups.com.
|
86
|
+
</p>
|
87
|
+
</body>
|
88
|
+
</html>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
index
|
8
|
+
</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>
|
12
|
+
<a name="Tutorial" id="Tutorial">Tutorial</a>
|
13
|
+
</h1>
|
14
|
+
<p>
|
15
|
+
<a name="Tutorial" id="Tutorial">Learn how to instrument html documents to make them active specifications with RCor.</a>
|
16
|
+
</p>
|
17
|
+
<h1>
|
18
|
+
<a name="Details" id="Details">Details</a>
|
19
|
+
</h1>
|
20
|
+
<p>
|
21
|
+
<a name="Details" id="Details">Here is the canonical Hello World example for rcor. Readers familiar with Concordion will note that the instrumentation is exactly the same for this example.</a>
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
<a name="Details" id="Details">We will create two files that correspond to the test: "basic_assert.html" and "basic_assert_test.rb".</a>
|
25
|
+
</p>
|
26
|
+
<h2>
|
27
|
+
<a name="The_Test:_basic_assert.html" id="The_Test:_basic_assert.html">The Test: basic_assert.html</a>
|
28
|
+
</h2>
|
29
|
+
<pre class="prettyprint">
|
30
|
+
<a name="The_Test:_basic_assert.html" id="The_Test:_basic_assert.html"><span class="pun"><</span><span class="tag">html</span><span class="pln"> </span><span class="atn">xmlns:concordion</span><span class="pun">=</span><span class="atv">"http://www.concordion.org/2007/concordion"</span><span class="pun">></span><span class="pln"><br /> </span><span class="pun"><</span><span class="tag">body</span><span class="pun">></span><span class="pln"><br /> The greeting should be: </span><span class="pun"><</span><span class="tag">p</span><span class="pln"> </span><span class="atn">concordion:assertEquals</span><span class="pun">=</span><span class="atv">"get_greeting"</span><span class="pun">></span><span class="pln">Hello World!</span><span class="pun"></</span><span class="tag">p</span><span class="pun">></span><span class="pln"><br /> </span><span class="pun"></</span><span class="tag">body</span><span class="pun">></span><span class="pln"><br /></span><span class="pun"></</span><span class="tag">html</span><span class="pun">></span></a>
|
31
|
+
</pre>
|
32
|
+
<p>
|
33
|
+
<a name="The_Test:_basic_assert.html" id="The_Test:_basic_assert.html">Here we're using the RCor command "assertEquals" to compare the actual results of our system to the expected results. In this case, we expect "Hello World!" when we invoke the system through "get_greeting" in the fixture class.</a>
|
34
|
+
</p>
|
35
|
+
<h2>
|
36
|
+
<a name="The_Fixture:_basic_assert_test.rb" id="The_Fixture:_basic_assert_test.rb">The Fixture: basic_assert_test.rb</a>
|
37
|
+
</h2>
|
38
|
+
<pre class="prettyprint">
|
39
|
+
<a name="The_Fixture:_basic_assert_test.rb" id="The_Fixture:_basic_assert_test.rb"><span class="kwd">class</span><span class="pln"> </span><span class="typ">BasicAssertTest</span><span class="pln"> </span><span class="pun"><</span><span class="pln"> </span><span class="typ">ConcordionTestCase</span><span class="pln"><br /> </span><span class="kwd">def</span><span class="pln"> get_greeting<br /> </span><span class="str">"Hello World!"</span><span class="pln"> </span><span class="com"># Normally this would call the code you're trying to test</span><span class="pln"><br /> </span><span class="kwd">end</span><span class="pln"><br />end</span></a>
|
40
|
+
</pre>
|
41
|
+
<p>
|
42
|
+
<a name="The_Fixture:_basic_assert_test.rb" id="The_Fixture:_basic_assert_test.rb">Then we create a script to run our hello world test: "run_the_spec.rb".</a>
|
43
|
+
</p>
|
44
|
+
<p>
|
45
|
+
<a name="The_Fixture:_basic_assert_test.rb" id="The_Fixture:_basic_assert_test.rb"><i>In practice the next file need not be created if your project has other tests (e.g. if you are using Rake and globs like <tt>*</tt><tt>_</tt>test.rb to find your project tests).</i></a>
|
46
|
+
</p>
|
47
|
+
<h2>
|
48
|
+
<a name="Runtime:_run_the_spec.rb" id="Runtime:_run_the_spec.rb">Runtime: run_the_spec.rb</a>
|
49
|
+
</h2>
|
50
|
+
<pre class="prettyprint">
|
51
|
+
<a name="Runtime:_run_the_spec.rb" id="Runtime:_run_the_spec.rb"><span class="com"># This is the simplest script to run an RCor spec, normally would be a Rake script.</span><span class="pln"><br /></span><span class="kwd">require</span><span class="pln"> </span><span class="str">'test/unit'</span><span class="pln"><br /></span><span class="kwd">require</span><span class="pln"> </span><span class="str">'rcor'</span><span class="pln"><br /></span><span class="kwd">require</span><span class="pln"> </span><span class="str">'basic_assert_test'</span></a>
|
52
|
+
</pre>
|
53
|
+
<p>
|
54
|
+
<a name="Runtime:_run_the_spec.rb" id="Runtime:_run_the_spec.rb">Result: running "run_the_spec.rb" will hand control to RCor and produce "basic_assert_test_output.html'.</a>
|
55
|
+
</p>
|
56
|
+
<p>
|
57
|
+
<a name="Runtime:_run_the_spec.rb" id="Runtime:_run_the_spec.rb">This file will be based on the input document, but will find RCor commands in the HTML and decorate them with either Success or Failure, depending on the behavior of the code you're testing.</a>
|
58
|
+
</p>
|
59
|
+
<p>
|
60
|
+
<a name="Runtime:_run_the_spec.rb" id="Runtime:_run_the_spec.rb">It looks like this:</a>
|
61
|
+
</p>
|
62
|
+
<h2>
|
63
|
+
<a name="Output_snippet_from:_basic_assert_test_output.html" id="Output_snippet_from:_basic_assert_test_output.html">Output snippet from: basic_assert_test_output.html</a>
|
64
|
+
</h2>
|
65
|
+
<pre class="prettyprint">
|
66
|
+
<a name="Output_snippet_from:_basic_assert_test_output.html" id="Output_snippet_from:_basic_assert_test_output.html"><span class="pln"> </span><span class="typ">The</span><span class="pln"> </span><span class="typ">Greeting</span><span class="pln"> should be</span><span class="pun">:</span><span class="pln"> </span><span class="pun"><</span><span class="pln">p concordion</span><span class="pun">:</span><span class="pln">assertequals</span><span class="pun">=</span><span class="str">"get_greeting"</span><span class="pln"> </span><span class="kwd">class</span><span class="pun">=</span><span class="str">"concordion_success"</span><span class="pun">></span><span class="typ">Hello</span><span class="pln"> </span><span class="typ">World</span><span class="pun">!<</span><span class="str">/p></span></a>
|
67
|
+
</pre>
|
68
|
+
<h2>
|
69
|
+
<a name="Want_to_know_more?">Want to know more?</a>
|
70
|
+
</h2>
|
71
|
+
<p>
|
72
|
+
<a name="Want_to_know_more?">Have a look at a more</a> <a href="/p/rcor/wiki/ComplexExample">ComplexExample</a>, or see <a href="/p/rcor/wiki/WhatRcorActuallyDoes">WhatRcorActuallyDoes</a>, or <a href="/p/rcor/wiki/VariationsOnAttributes">VariationsOnAttributes</a>.
|
73
|
+
</p>
|
74
|
+
</body>
|
75
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'concordion/utility'
|
2
|
+
|
3
|
+
module Concordion
|
4
|
+
class Binder
|
5
|
+
include Concordion::Utility
|
6
|
+
|
7
|
+
def initialize(concordion)
|
8
|
+
@concordion = concordion
|
9
|
+
end
|
10
|
+
def bind_if_set_command(cpr)
|
11
|
+
if cpr.is_set_command?
|
12
|
+
@concordion.set_variable(cpr.system_under_test, cpr.content)
|
13
|
+
true
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_assignment(cpr, sut_rv)
|
20
|
+
if has_assignment?(cpr.system_under_test)
|
21
|
+
@concordion.set_variable(concordion_assignment(cpr.system_under_test), sut_rv)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Concordion
|
2
|
+
|
3
|
+
module Constants
|
4
|
+
def concordion_command_attributes
|
5
|
+
["assertequals", "set", "execute", "verifyrows", "asserttrue", "assert_image"].collect do
|
6
|
+
|cmd| "concordion:#{cmd}"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def supported?(tagname)
|
11
|
+
['p', 'span', 'b', 'th', 'tr', 'div'].include?(tagname.downcase)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Concordion
|
4
|
+
module CSS
|
5
|
+
def self.css_filename
|
6
|
+
"concordion.css"
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def self.css_string
|
10
|
+
css = <<-eoscss
|
10
11
|
* {
|
11
12
|
font-family: Arial;
|
12
13
|
}
|
@@ -174,6 +175,7 @@ ins {
|
|
174
175
|
}
|
175
176
|
eoscss
|
176
177
|
|
177
|
-
|
178
|
+
css.strip
|
179
|
+
end
|
178
180
|
end
|
179
181
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'concordion/css'
|
2
|
+
require 'concordion/error_condition'
|
3
|
+
|
4
|
+
module Concordion
|
5
|
+
class CSSDecorator
|
6
|
+
|
7
|
+
def add_concordion_css_link(root, html, type)
|
8
|
+
if html.at("head").nil?
|
9
|
+
root.search("html").prepend('<head></head>')
|
10
|
+
end
|
11
|
+
if type == :link
|
12
|
+
link_to_css(html)
|
13
|
+
else
|
14
|
+
inline_css(html)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def append_to_head(html, s)
|
19
|
+
html.search("head").append(s)
|
20
|
+
end
|
21
|
+
def link_to_css(html)
|
22
|
+
append_to_head(html, "<link rel='stylesheet' type='text/css' href='#{css_filename}' />")
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def inline_css(html)
|
27
|
+
append_to_head(html, "<style type='text/css'>#{css}</style>")
|
28
|
+
end
|
29
|
+
|
30
|
+
def css
|
31
|
+
Concordion::CSS.css_string
|
32
|
+
end
|
33
|
+
|
34
|
+
def css_filename
|
35
|
+
Concordion::CSS.css_filename
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_css_file_to_output_dir(writer, type)
|
39
|
+
if !writer.output_file_exists?(css_filename) && type == :link
|
40
|
+
writer.calculate_filename_and_overwrite(css, css_filename)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def decorate_tag(rv, tag, cpr)
|
45
|
+
context = tag.to_html
|
46
|
+
expected = tag.inner_html
|
47
|
+
xpath = tag.xpath
|
48
|
+
|
49
|
+
if rv[:result]
|
50
|
+
tag[:class] = 'concordion_success'
|
51
|
+
return nil
|
52
|
+
end
|
53
|
+
|
54
|
+
tag[:class] = 'concordion_failure'
|
55
|
+
cpr.attribute_error(rv[:actual], rv[:expected])
|
56
|
+
Concordion::ErrorCondition.new(expected, rv[:actual], xpath, context, cpr.is_assert_true_command?)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Concordion
|
2
|
+
class Environment
|
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
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
module Concordion
|
6
|
+
class ErrorCondition
|
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
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Concordion
|
3
|
+
class Instrumenter
|
4
|
+
@@TH_CSS_QUERY_REGEXP = /tr:nth\(\d+\) > th:nth\((\d+)\)$/
|
5
|
+
@@TH_CSS_SINGLE_REGEXP = /tr:nth\(\d+\) > th$/
|
6
|
+
|
7
|
+
def instrument_from_headers(elem, attr, root)
|
8
|
+
header = @@TH_CSS_QUERY_REGEXP.match(elem.css_path)
|
9
|
+
if header
|
10
|
+
instrument_column(elem, attr, header.captures, @@TH_CSS_QUERY_REGEXP, root)
|
11
|
+
return true
|
12
|
+
end
|
13
|
+
|
14
|
+
single_header = @@TH_CSS_SINGLE_REGEXP.match(elem.css_path)
|
15
|
+
if single_header
|
16
|
+
instrument_column(elem, attr, 0, @@TH_CSS_SINGLE_REGEXP, root)
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def instrument_column(elem, attr, column_number, regex, root)
|
24
|
+
trimmed = elem.css_path.sub(regex, '')
|
25
|
+
td_css_query = trimmed + "tr > td:nth(#{column_number})"
|
26
|
+
|
27
|
+
value = elem.get_attribute(attr)
|
28
|
+
root.search(td_css_query).set(attr, value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'concordion/loader_helper'
|
2
|
+
require 'concordion/utility'
|
3
|
+
|
4
|
+
module Concordion
|
5
|
+
class Invoker
|
6
|
+
include Concordion::LoaderHelper
|
7
|
+
include Concordion::Utility
|
8
|
+
|
9
|
+
def initialize(conc)
|
10
|
+
@concordion = conc
|
11
|
+
end
|
12
|
+
|
13
|
+
def try_to_dereference(cpr)
|
14
|
+
rv = nil
|
15
|
+
begin
|
16
|
+
rv = @concordion.dereference(cpr.system_under_test)
|
17
|
+
rescue NoMethodError => e
|
18
|
+
method = method_from_no_method_error(e)
|
19
|
+
|
20
|
+
rv = dereference_error_message(e)
|
21
|
+
end
|
22
|
+
rv
|
23
|
+
end
|
24
|
+
|
25
|
+
def dereference_error_message(e)
|
26
|
+
rv = "["
|
27
|
+
clazz = e.to_s.split(":")[1]
|
28
|
+
if clazz == 'NilClass'
|
29
|
+
rv += "No more rows"
|
30
|
+
end
|
31
|
+
rv += "]"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def invoke_sut(cpr, test_context)
|
36
|
+
sut_rv = nil
|
37
|
+
if cpr.needs_dereference?
|
38
|
+
sut_rv = try_to_dereference(cpr)
|
39
|
+
else
|
40
|
+
|
41
|
+
sut_rv = try_to_invoke_sut(cpr,test_context)
|
42
|
+
end
|
43
|
+
|
44
|
+
sut_rv
|
45
|
+
end
|
46
|
+
|
47
|
+
def handle_args(cpr)
|
48
|
+
arg_vars = concordion_arguments(cpr.system_under_test)
|
49
|
+
arg_values = arg_vars.collect {|var|
|
50
|
+
if var == '#TEXT'
|
51
|
+
cpr.content
|
52
|
+
else
|
53
|
+
@concordion.get_variable(var)
|
54
|
+
end
|
55
|
+
}
|
56
|
+
|
57
|
+
arg_values
|
58
|
+
end
|
59
|
+
|
60
|
+
def arg_values_for(cpr)
|
61
|
+
arg_values = []
|
62
|
+
if has_arguments?(cpr.system_under_test)
|
63
|
+
arg_values = handle_args(cpr)
|
64
|
+
end
|
65
|
+
arg_values
|
66
|
+
end
|
67
|
+
|
68
|
+
def try_to_invoke_sut(cpr, test_context)
|
69
|
+
sut_rv = nil
|
70
|
+
begin
|
71
|
+
conc_method = concordion_method_name(cpr.system_under_test)
|
72
|
+
sut_rv = test_context.send(conc_method, *arg_values_for(cpr))
|
73
|
+
rescue NoMethodError => e
|
74
|
+
sut_rv = report_error(e, cpr)
|
75
|
+
end
|
76
|
+
sut_rv
|
77
|
+
end
|
78
|
+
|
79
|
+
def report_error(e, cpr="BUG IN CONNCORDION")
|
80
|
+
rv = nil
|
81
|
+
if e.to_s =~ /nil:NilClass/
|
82
|
+
rv = "[Parse failed for: #{cpr}, cause: (#{e})]"
|
83
|
+
else
|
84
|
+
method = method_from_no_method_error(e)
|
85
|
+
clazz = class_from_no_method_error(e)
|
86
|
+
rv = "[Missing method '#{method}' in fixture #{clazz} ]"
|
87
|
+
end
|
88
|
+
rv
|
89
|
+
end
|
90
|
+
|
91
|
+
def method_from_no_method_error(e)
|
92
|
+
error_message = except_str_from(e)
|
93
|
+
if error_message =~ /`/
|
94
|
+
error_message.split("`").last.split("'").first
|
95
|
+
else
|
96
|
+
error_message
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def except_str_from(e)
|
101
|
+
e.message
|
102
|
+
end
|
103
|
+
|
104
|
+
def class_from_no_method_error(e)
|
105
|
+
error_message = except_str_from(e)
|
106
|
+
if error_message =~ /</ and error_message =~ /:/
|
107
|
+
error_message.split("<").last.split(":").first
|
108
|
+
else
|
109
|
+
"Class not known"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def invoke_concordion(cpr, sut_rv)
|
114
|
+
cmd = commands[cpr.concordion_command]
|
115
|
+
if cpr.is_assert_image_command?
|
116
|
+
cmd.call(sut_rv, cpr.image_location)
|
117
|
+
elsif cpr.is_verify_command?
|
118
|
+
cmd.call(sut_rv, cpr.num_results_expected)
|
119
|
+
else
|
120
|
+
cmd.call(sut_rv, cpr.content)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def commands
|
127
|
+
cmds = {}
|
128
|
+
cmds["assertequals"] = Proc.new { |a, b|
|
129
|
+
result = (a.to_s == b)
|
130
|
+
{ :result => result, :actual => a, :expected => b } }
|
131
|
+
cmds["execute"] = Proc.new { |a,b|
|
132
|
+
result = true
|
133
|
+
result = false if a.to_s =~ /Missing method/
|
134
|
+
{:result => result, :actual => a, :expected => b } }
|
135
|
+
cmds["verifyrows"] = Proc.new { |a,b| { :result => a.size == b, :actual => a.size, :expected => b } }
|
136
|
+
cmds["asserttrue"] = Proc.new { |a, b|
|
137
|
+
result = a
|
138
|
+
result = false if a.instance_of?(String)
|
139
|
+
{ :result => result, :actual => false, :expected => true } }
|
140
|
+
cmds["assert_image"] = Proc.new { |actual_data, expected_image_url|
|
141
|
+
expected_data = File.read(path_for(expected_image_url))
|
142
|
+
{ :result => actual_data == expected_data, :actual => "[Image data of size #{actual_data.size} omitted]", :expected => "[Expected to match #{expected_image_url}]" }
|
143
|
+
}
|
144
|
+
cmds
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
module Concordion
|
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
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Concordion
|
2
|
+
|
3
|
+
class LookaheadHandler
|
4
|
+
def is_element_setter?(elem)
|
5
|
+
!elem.get_attribute('concordion:set').nil?
|
6
|
+
end
|
7
|
+
|
8
|
+
def handle_lookahead(cpr, test_context, processor)
|
9
|
+
cpr.tag.search("/*[@]").each {|child|
|
10
|
+
if is_element_setter?(child)
|
11
|
+
processor.process(child, test_context)
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|