rcor 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile.rb +39 -0
- data/lib/concordion.rb +66 -0
- data/lib/concordion_binder.rb +24 -0
- data/lib/concordion_constants.rb +13 -0
- data/lib/concordion_css.rb +172 -0
- data/lib/concordion_css_decorator.rb +52 -0
- data/lib/concordion_environment.rb +28 -0
- data/lib/concordion_instrumenter.rb +30 -0
- data/lib/concordion_invocation_string_builder.rb +24 -0
- data/lib/concordion_invoker.rb +33 -0
- data/lib/concordion_lookahead_handler.rb +17 -0
- data/lib/concordion_parse_result.rb +31 -0
- data/lib/concordion_parser.rb +47 -0
- data/lib/concordion_processor.rb +24 -0
- data/lib/concordion_reader.rb +18 -0
- data/lib/concordion_string_utility.rb +63 -0
- data/lib/concordion_string_writer.rb +13 -0
- data/lib/concordion_test_case.rb +97 -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 +32 -0
- data/lib/rcor.rb +2 -0
- data/nbproject/private/config.properties +0 -0
- data/nbproject/private/private.properties +4 -0
- data/nbproject/private/private.xml +10 -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/attr_assert.html +5 -0
- data/tests/attr_assert_test.rb +13 -0
- data/tests/basic_assert.html +5 -0
- data/tests/basic_assert_test.rb +9 -0
- data/tests/basic_assert_true.html +6 -0
- data/tests/basic_assert_true_test.rb +11 -0
- data/tests/basic_set.html +8 -0
- data/tests/basic_set_test.rb +8 -0
- data/tests/basic_text.html +6 -0
- data/tests/basic_text_test.rb +12 -0
- data/tests/concordion.css +2 -0
- data/tests/concordion_css_decorator_test.rb +28 -0
- data/tests/concordion_environment_test.rb +44 -0
- data/tests/concordion_parse_result_test.rb +33 -0
- data/tests/concordion_test.rb +49 -0
- data/tests/concordion_utility_test.rb +88 -0
- data/tests/concordion_verifier_test.rb +38 -0
- data/tests/concordion_writer_test.rb +26 -0
- data/tests/failing.html +5 -0
- data/tests/failing_test.rb +15 -0
- data/tests/goldmaster_failing.html +5 -0
- data/tests/goldmaster_failing_goldmaster.html +162 -0
- data/tests/goldmaster_failing_test.rb +11 -0
- data/tests/goldmaster_passing.html +5 -0
- data/tests/goldmaster_passing_goldmaster.html +162 -0
- data/tests/goldmaster_passing_test.rb +9 -0
- data/tests/goldmaster_table.html +46 -0
- data/tests/goldmaster_table_goldmaster.html +203 -0
- data/tests/goldmaster_table_test.rb +17 -0
- data/tests/lookahead_assert_true.html +25 -0
- data/tests/lookahead_assert_true_test.rb +17 -0
- data/tests/nested_element_lookahead.html +9 -0
- data/tests/nested_element_lookahead_test.rb +8 -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/single_row_table.html +13 -0
- data/tests/single_row_table_test.rb +9 -0
- data/tests/table.html +28 -0
- data/tests/table_test.rb +9 -0
- data/tests/test_helper.rb +9 -0
- data/tests/verify_rows.html +46 -0
- data/tests/verify_rows_scsr.html +27 -0
- data/tests/verify_rows_scsr_test.rb +15 -0
- data/tests/verify_rows_test.rb +16 -0
- metadata +142 -0
@@ -0,0 +1,43 @@
|
|
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
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'concordion_test_case'
|
2
|
+
require 'concordion_string_writer'
|
3
|
+
class GoldmasterTestCase < ConcordionTestCase
|
4
|
+
|
5
|
+
|
6
|
+
def initialize(suite, conf = {})
|
7
|
+
@writer = ConcordionStringWriter.new
|
8
|
+
|
9
|
+
config = ConcordionTestCase.default_config.merge({:writer => @writer}).merge(conf)
|
10
|
+
@write_goldmaster = config[:write_goldmaster]
|
11
|
+
super(suite, config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_spec
|
15
|
+
trivial
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
if @write_goldmaster
|
21
|
+
ConcordionWriter.new.write(@writer.data, snake_cased_goldmaster_name(self.class.to_s))
|
22
|
+
|
23
|
+
assert !@write_goldmaster, "Disable write to goldmaster"
|
24
|
+
end
|
25
|
+
|
26
|
+
unless is_trivial?
|
27
|
+
goldmaster = ConcordionReader.new.read(snake_cased_goldmaster_name(self.class.to_s))
|
28
|
+
assert_equal @writer.data, goldmaster
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/rcor.rb
ADDED
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
3
|
+
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
4
|
+
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
|
5
|
+
<file>file:/home/bg/src/rcor/rcor/trunk/Rakefile.rb</file>
|
6
|
+
<file>file:/home/bg/src/rcor/rcor/trunk/lib/concordion_css_decorator.rb</file>
|
7
|
+
<file>file:/home/bg/src/rcor/rcor/trunk/lib/concordion_environment.rb</file>
|
8
|
+
<file>file:/home/bg/src/rcor/rcor/trunk/tests/concordion_environment_test.rb</file>
|
9
|
+
</open-files>
|
10
|
+
</project-private>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
file.reference.rcor-lib=lib
|
2
|
+
file.reference.rcor-test-lib=test-lib
|
3
|
+
file.reference.rcor-tests=tests
|
4
|
+
javac.classpath=
|
5
|
+
main.file=
|
6
|
+
platform.active=Ruby
|
7
|
+
ruby.includejava=false
|
8
|
+
source.encoding=windows-1252
|
9
|
+
src.lib.dir=lib
|
10
|
+
src.test-lib.dir=test-lib
|
11
|
+
test.tests.dir=tests
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://www.netbeans.org/ns/project/1">
|
3
|
+
<type>org.netbeans.modules.ruby.rubyproject</type>
|
4
|
+
<configuration>
|
5
|
+
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
|
6
|
+
<name>rcor</name>
|
7
|
+
<source-roots>
|
8
|
+
<root id="src.test-lib.dir"/>
|
9
|
+
<root id="src.lib.dir"/>
|
10
|
+
</source-roots>
|
11
|
+
<test-roots>
|
12
|
+
<root id="test.tests.dir"/>
|
13
|
+
</test-roots>
|
14
|
+
</data>
|
15
|
+
</configuration>
|
16
|
+
</project>
|
data/test-lib/user.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
class BasicAssertTrueTest < ConcordionTestCase
|
5
|
+
def initialize(suite)
|
6
|
+
super(suite, {:expected_failure_count => 1})
|
7
|
+
end
|
8
|
+
def is_boiling_point(temperature)
|
9
|
+
212 == temperature.to_i
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<html xmlns:concordion="http://www.concordion.org/2007/concordion">
|
2
|
+
<body>
|
3
|
+
Here's some text
|
4
|
+
<p concordion:set="#username">Chuck Norris</p>
|
5
|
+
<p concordion:assertEquals="greetingFor(#username)">Hello Chuck Norris, you nancy-boy.</p>
|
6
|
+
it should be in the output.
|
7
|
+
</body>
|
8
|
+
</html>
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,44 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'concordion_parse_result'
|
3
|
+
|
4
|
+
class ConcordionParseResultTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_is_set_command
|
7
|
+
assert ConcordionParseResult.new("set",nil,nil,nil).is_set_command?
|
8
|
+
assert !ConcordionParseResult.new("asdf",nil,nil,nil).is_set_command?
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_is_execute_command
|
12
|
+
assert ConcordionParseResult.new("execute",nil,nil,nil).is_execute_command?
|
13
|
+
assert !ConcordionParseResult.new("asdf",nil,nil,nil).is_execute_command?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_is_verify_command
|
17
|
+
assert ConcordionParseResult.new("verifyrows",nil,nil,nil).is_verify_command?
|
18
|
+
assert !ConcordionParseResult.new("monkeys",nil,nil,nil).is_verify_command?
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_assignment
|
22
|
+
assert_equal "#user", ConcordionParseResult.new("verifyrows"," #user = asdfasdf",nil,nil).assignment
|
23
|
+
assert_equal "#bob", ConcordionParseResult.new("monkeys","#bob=asdf",nil,nil).assignment
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_needs_dereference
|
27
|
+
assert ConcordionParseResult.new(nil,"#asdf", nil,nil).needs_dereference?
|
28
|
+
assert !ConcordionParseResult.new(nil,"asdf", nil,nil).needs_dereference?
|
29
|
+
assert !ConcordionParseResult.new(nil,"as#df", nil,nil).needs_dereference?
|
30
|
+
assert !ConcordionParseResult.new(nil,"#asdf = foo()", nil,nil).needs_dereference?
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'test_helper'
|
3
|
+
require 'concordion'
|
4
|
+
|
5
|
+
class ConcordionTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@concordion = Concordion.new
|
9
|
+
@thingy = Thingy.new()
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_set_variable
|
13
|
+
@concordion.set_variable("#foo", "bar")
|
14
|
+
|
15
|
+
assert_equal "bar", @concordion.get_variable("#foo")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_build_invocation_string
|
19
|
+
assert_equal "self.send('foo')", @concordion.build_invocation_string("foo()", "content")
|
20
|
+
@concordion.set_variable("#bar", "baz")
|
21
|
+
assert_equal "self.send('foo', 'baz')", @concordion.build_invocation_string("foo(#bar)", "content")
|
22
|
+
|
23
|
+
@concordion.set_variable("#purplemonkey", "dishwasher")
|
24
|
+
assert_equal "self.send('other', 'baz', 'dishwasher')", @concordion.build_invocation_string("other(#bar, #purplemonkey)", "content")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_build_invocation_string_replaces_text
|
28
|
+
assert_equal "self.send('foo', 'ASDF')", @concordion.build_invocation_string("foo(#TEXT)", "ASDF")
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_dereference
|
33
|
+
@concordion.set_variable("#result", @thingy)
|
34
|
+
|
35
|
+
assert_same @thingy, @concordion.dereference("#result")
|
36
|
+
end
|
37
|
+
def test_dereference_with_property
|
38
|
+
@concordion.set_variable("#result", @thingy)
|
39
|
+
|
40
|
+
assert_equal "bleh", @concordion.dereference("#result.prop")
|
41
|
+
end
|
42
|
+
|
43
|
+
class Thingy
|
44
|
+
attr_accessor :prop
|
45
|
+
def initialize
|
46
|
+
@prop = "bleh"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'concordion_utility'
|
3
|
+
|
4
|
+
class ConcordionUtilityTest < Test::Unit::TestCase
|
5
|
+
include ConcordionUtility
|
6
|
+
|
7
|
+
def test_supported
|
8
|
+
assert supported?('p')
|
9
|
+
assert supported?("p")
|
10
|
+
assert supported?("P")
|
11
|
+
assert !supported?("R")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_snakeCase
|
15
|
+
assert_equal "bob", snake_case("bob")
|
16
|
+
assert_equal "bob", snake_case("Bob")
|
17
|
+
assert_equal "camel_case", snake_case("CamelCase")
|
18
|
+
assert_equal "camel_case_var", snake_case("camelCaseVar")
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_snake_cased_test_name
|
23
|
+
assert_equal "bob.html", snake_cased_test_name("bob")
|
24
|
+
assert_equal "bob.html", snake_cased_test_name("Bob")
|
25
|
+
assert_equal "bob.html", snake_cased_test_name("BobTest")
|
26
|
+
assert_equal "bob_case.html", snake_cased_test_name("BobCaseTest")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_snake_cased_goldmaster_name
|
30
|
+
assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("bob")
|
31
|
+
assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("Bob")
|
32
|
+
assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("BobTest")
|
33
|
+
assert_equal "bob_case_goldmaster.html", snake_cased_goldmaster_name("BobCaseTest")
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def test_conc_method_name
|
38
|
+
assert_equal "invoke", concordion_method_name("invoke()")
|
39
|
+
assert_equal "invoke", concordion_method_name("invoke(")
|
40
|
+
assert_equal "invoke", concordion_method_name("invoke")
|
41
|
+
assert_equal "bleh", concordion_method_name("bleh(foo,bar)")
|
42
|
+
assert_equal "bleh", concordion_method_name("bleh ( foo , bar)")
|
43
|
+
assert_equal "foo", concordion_method_name("#baz = foo ( #asdf, #fdsa)")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_conc_var_name
|
47
|
+
assert_equal "#result", concordion_variable_name("#result.first()")
|
48
|
+
assert_equal "#res", concordion_variable_name(" #res ")
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_has_args
|
53
|
+
assert has_arguments?("invoke(#foo,#bar)")
|
54
|
+
assert !has_arguments?("invoke()")
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_conc_args
|
58
|
+
assert_equal [], concordion_arguments("invoke()")
|
59
|
+
assert_equal ["#foo","#bar"], concordion_arguments("bleh(#foo,#bar)")
|
60
|
+
assert_equal ["#foo","#bar"], concordion_arguments("bleh ( #foo , #bar )")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_conc_assignment
|
64
|
+
assert_equal "#foo", concordion_assignment(" #foo = getResult() ")
|
65
|
+
assert_equal "#for", concordion_assignment("#for=")
|
66
|
+
end
|
67
|
+
def test_has_assignment
|
68
|
+
assert has_assignment?("=")
|
69
|
+
assert !has_assignment?("")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_has_property_ref
|
73
|
+
assert has_property_reference?("#res.foo")
|
74
|
+
assert !has_property_reference?("#res")
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_property_ref
|
79
|
+
assert_equal "bar", concordion_property_reference(" #foo.bar ")
|
80
|
+
assert_equal "bar.baz", concordion_property_reference("#for.bar.baz")
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_singular
|
85
|
+
assert_equal "bar", singular("bars")
|
86
|
+
assert_equal "foo", singular("foo")
|
87
|
+
end
|
88
|
+
end
|