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.
Files changed (141) hide show
  1. data/README +0 -0
  2. data/Rakefile.rb +25 -28
  3. data/documentation/index.html +88 -0
  4. data/documentation/p/rcor/wiki/Tutorial/index.html +75 -0
  5. data/lib/concordion/binder.rb +26 -0
  6. data/lib/concordion/constants.rb +15 -0
  7. data/lib/{concordion_css.rb → concordion/css.rb} +9 -7
  8. data/lib/concordion/css_decorator.rb +59 -0
  9. data/lib/concordion/environment.rb +28 -0
  10. data/lib/concordion/error_condition.rb +27 -0
  11. data/lib/concordion/instrumenter.rb +31 -0
  12. data/lib/concordion/invoker.rb +148 -0
  13. data/lib/concordion/loader_helper.rb +17 -0
  14. data/lib/concordion/lookahead_handler.rb +16 -0
  15. data/lib/concordion/parse_result.rb +74 -0
  16. data/lib/concordion/parser.rb +43 -0
  17. data/lib/concordion/processor.rb +24 -0
  18. data/lib/concordion/reader.rb +11 -0
  19. data/lib/concordion/state.rb +77 -0
  20. data/lib/concordion/string_utility.rb +104 -0
  21. data/lib/concordion/string_writer.rb +13 -0
  22. data/lib/concordion/test_methods.rb +130 -0
  23. data/lib/concordion/utility.rb +72 -0
  24. data/lib/concordion/verifier.rb +52 -0
  25. data/lib/concordion/writer.rb +52 -0
  26. data/lib/concordion_test_case.rb +4 -16
  27. data/lib/goldmaster_test_case.rb +4 -4
  28. data/ruby-concordion.tmproj +249 -0
  29. data/test/concordion/css_decorator_test.rb +28 -0
  30. data/test/concordion/environment_test.rb +46 -0
  31. data/test/concordion/invoker_test.rb +20 -0
  32. data/test/concordion/parse_result_test.rb +51 -0
  33. data/test/concordion/reader_test.rb +12 -0
  34. data/test/concordion/state_test.rb +41 -0
  35. data/test/concordion/string_writer_test.rb +10 -0
  36. data/test/concordion/utility_test.rb +142 -0
  37. data/test/concordion/verifier_test.rb +38 -0
  38. data/test/concordion/writer_test.rb +29 -0
  39. data/{tests → test}/concordion.css +0 -0
  40. data/{tests/concordion → test}/goldmaster_test_case_test.rb +2 -8
  41. data/{tests → test/spec}/basic_assert.html +0 -0
  42. data/{tests → test/spec}/basic_assert_test.rb +2 -2
  43. data/{tests → test/spec}/basic_set.html +0 -0
  44. data/{tests → test/spec}/basic_set_test.rb +0 -1
  45. data/{tests → test/spec}/basic_text.html +0 -0
  46. data/{tests → test/spec}/basic_text_test.rb +0 -1
  47. data/{tests → test/spec}/failing.html +0 -0
  48. data/{tests → test/spec}/failing_test.rb +0 -1
  49. data/{tests → test/spec}/goldmasters/failing_with_subclass.html +0 -0
  50. data/{tests → test/spec}/goldmasters/failing_with_subclass_goldmaster.html +0 -0
  51. data/{tests → test/spec}/goldmasters/failing_with_subclass_test.rb +2 -2
  52. data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing.html +0 -0
  53. data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing_goldmaster.html +0 -0
  54. data/{tests → test/spec}/goldmasters/goldmaster_assert_true_failing_test.rb +0 -0
  55. data/{tests → test/spec}/goldmasters/goldmaster_failing.html +0 -0
  56. data/{tests → test/spec}/goldmasters/goldmaster_failing_goldmaster.html +0 -0
  57. data/{tests → test/spec}/goldmasters/goldmaster_failing_test.rb +0 -2
  58. data/{tests → test/spec}/goldmasters/goldmaster_malformed.html +0 -0
  59. data/{tests → test/spec}/goldmasters/goldmaster_malformed_goldmaster.html +0 -0
  60. data/{tests → test/spec}/goldmasters/goldmaster_malformed_test.rb +0 -0
  61. data/{tests → test/spec}/goldmasters/goldmaster_passing.html +0 -0
  62. data/{tests → test/spec}/goldmasters/goldmaster_passing_goldmaster.html +0 -0
  63. data/{tests → test/spec}/goldmasters/goldmaster_passing_test.rb +0 -0
  64. data/{tests → test/spec}/goldmasters/goldmaster_table.html +0 -0
  65. data/{tests → test/spec}/goldmasters/goldmaster_table_bug.html +0 -0
  66. data/{tests → test/spec}/goldmasters/goldmaster_table_bug_goldmaster.html +0 -0
  67. data/{tests → test/spec}/goldmasters/goldmaster_table_bug_test.rb +0 -0
  68. data/{tests → test/spec}/goldmasters/goldmaster_table_goldmaster.html +0 -0
  69. data/{tests → test/spec}/goldmasters/goldmaster_table_test.rb +1 -0
  70. data/{tests → test/spec}/image.html +0 -0
  71. data/{tests → test/spec}/image.jpg +0 -0
  72. data/{tests → test/spec}/image_test.rb +2 -2
  73. data/{tests → test/spec}/link_style_css.html +0 -0
  74. data/{tests → test/spec}/link_style_css_test.rb +1 -6
  75. data/{tests → test/spec}/lookahead_assert_true.html +0 -0
  76. data/{tests → test/spec}/lookahead_assert_true_test.rb +0 -0
  77. data/{tests → test/spec}/mixed.html +0 -0
  78. data/test/spec/mixed_test.rb +13 -0
  79. data/{tests → test/spec}/nested_element_lookahead.html +0 -0
  80. data/{tests → test/spec}/nested_element_lookahead_test.rb +0 -0
  81. data/{tests → test/spec}/numbers.html +0 -0
  82. data/{tests → test/spec}/numbers_test.rb +0 -0
  83. data/{tests → test/spec}/processes_elements_in_sorted_order.html +0 -0
  84. data/{tests → test/spec}/processes_elements_in_sorted_order_test.rb +0 -0
  85. data/{tests → test/spec}/return_result.html +0 -0
  86. data/{tests → test/spec}/return_result_test.rb +0 -0
  87. data/test/spec/structure/maps_to_module.html +11 -0
  88. data/test/spec/structure/maps_to_module_test.rb +13 -0
  89. data/{tests → test/spec}/tables/single_row_table.html +0 -0
  90. data/{tests → test/spec}/tables/single_row_table_test.rb +0 -0
  91. data/{tests → test/spec}/tables/table.html +0 -0
  92. data/{tests → test/spec}/tables/table_test.rb +1 -0
  93. data/{tests → test/spec}/tables/test_helper.rb +3 -7
  94. data/{tests → test/spec}/tables/verify_rows.html +0 -0
  95. data/{tests → test/spec}/tables/verify_rows_scsr.html +0 -0
  96. data/{tests → test/spec}/tables/verify_rows_scsr_test.rb +2 -1
  97. data/{tests → test/spec}/tables/verify_rows_simple.html +0 -0
  98. data/{tests → test/spec}/tables/verify_rows_simple_test.rb +0 -0
  99. data/{tests → test/spec}/tables/verify_rows_test.rb +1 -0
  100. data/{tests → test/spec}/user-reported/apostrophe.html +0 -0
  101. data/{tests → test/spec}/user-reported/apostrophe_test.rb +0 -1
  102. data/{tests → test/spec}/user-reported/ariel_example.html +0 -0
  103. data/{tests → test/spec}/user-reported/ariel_example_test.rb +0 -0
  104. data/{tests → test/spec}/user-reported/attr_assert.html +0 -0
  105. data/{tests → test/spec}/user-reported/attr_assert_test.rb +0 -1
  106. data/{tests → test/spec}/user-reported/basic_assert_true.html +0 -0
  107. data/{tests → test/spec}/user-reported/basic_assert_true_test.rb +1 -2
  108. data/{tests → test/spec}/user-reported/rubyish.html +0 -0
  109. data/{tests → test/spec}/user-reported/rubyish_test.rb +0 -1
  110. data/test/test_helper.rb +11 -0
  111. metadata +131 -114
  112. data/lib/concordion_binder.rb +0 -24
  113. data/lib/concordion_constants.rb +0 -13
  114. data/lib/concordion_css_decorator.rb +0 -58
  115. data/lib/concordion_environment.rb +0 -27
  116. data/lib/concordion_error_condition.rb +0 -26
  117. data/lib/concordion_instrumenter.rb +0 -30
  118. data/lib/concordion_invoker.rb +0 -137
  119. data/lib/concordion_lookahead_handler.rb +0 -17
  120. data/lib/concordion_parse_result.rb +0 -72
  121. data/lib/concordion_parser.rb +0 -47
  122. data/lib/concordion_processor.rb +0 -25
  123. data/lib/concordion_reader.rb +0 -10
  124. data/lib/concordion_state.rb +0 -78
  125. data/lib/concordion_string_utility.rb +0 -97
  126. data/lib/concordion_string_writer.rb +0 -13
  127. data/lib/concordion_test_methods.rb +0 -132
  128. data/lib/concordion_utility.rb +0 -70
  129. data/lib/concordion_verifier.rb +0 -50
  130. data/lib/concordion_writer.rb +0 -43
  131. data/lib/loader_helper.rb +0 -16
  132. data/tests/concordion/concordion_css_decorator_test.rb +0 -28
  133. data/tests/concordion/concordion_environment_test.rb +0 -44
  134. data/tests/concordion/concordion_parse_result_test.rb +0 -51
  135. data/tests/concordion/concordion_reader_test.rb +0 -15
  136. data/tests/concordion/concordion_state_test.rb +0 -38
  137. data/tests/concordion/concordion_string_writer_test.rb +0 -13
  138. data/tests/concordion/concordion_utility_test.rb +0 -135
  139. data/tests/concordion/concordion_verifier_test.rb +0 -38
  140. data/tests/concordion/concordion_writer_test.rb +0 -26
  141. data/tests/mixed_test.rb +0 -19
@@ -1,5 +1,5 @@
1
+ require "concordion/string_writer"
1
2
  require 'concordion_test_case'
2
- require 'concordion_string_writer'
3
3
 
4
4
  require 'diff/lcs'
5
5
  module FailConditionally
@@ -16,7 +16,7 @@ class GoldmasterTestCase < ConcordionTestCase
16
16
  include FailConditionally
17
17
 
18
18
  def initialize(suite, conf = {})
19
- @writer = ConcordionStringWriter.new
19
+ @writer = Concordion::StringWriter.new
20
20
 
21
21
  config = ConcordionTestCase.default_config.merge(conf)
22
22
  @write_goldmaster = config[:write_goldmaster]
@@ -31,7 +31,7 @@ class GoldmasterTestCase < ConcordionTestCase
31
31
  end
32
32
 
33
33
  def writer
34
- ConcordionWriter.new
34
+ Concordion::Writer.new
35
35
  end
36
36
 
37
37
 
@@ -39,7 +39,7 @@ class GoldmasterTestCase < ConcordionTestCase
39
39
  fail_if_write_still_enabled(self.class, writer, @writer.data, snake_cased_goldmaster_name(self.class.to_s))
40
40
 
41
41
  unless is_trivial?
42
- goldmaster = ConcordionReader.new.read(snake_cased_goldmaster_name(self.class.to_s))
42
+ goldmaster = Concordion::Reader.new.read(snake_cased_goldmaster_name(self.class.to_s))
43
43
  assert @writer.data.size > 0
44
44
 
45
45
  diffs = Diff::LCS.diff(@writer.data, goldmaster)
@@ -0,0 +1,249 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>currentDocument</key>
6
+ <string>test/concordion/invoker_test.rb</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string>trunk</string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>sourceDirectory</key>
17
+ <string></string>
18
+ </dict>
19
+ </array>
20
+ <key>fileHierarchyDrawerWidth</key>
21
+ <integer>290</integer>
22
+ <key>metaData</key>
23
+ <dict>
24
+ <key>lib/concordion/invoker.rb</key>
25
+ <dict>
26
+ <key>caret</key>
27
+ <dict>
28
+ <key>column</key>
29
+ <integer>46</integer>
30
+ <key>line</key>
31
+ <integer>93</integer>
32
+ </dict>
33
+ <key>firstVisibleColumn</key>
34
+ <integer>0</integer>
35
+ <key>firstVisibleLine</key>
36
+ <integer>73</integer>
37
+ </dict>
38
+ <key>test/concordion/invoker_test.rb</key>
39
+ <dict>
40
+ <key>caret</key>
41
+ <dict>
42
+ <key>column</key>
43
+ <integer>114</integer>
44
+ <key>line</key>
45
+ <integer>7</integer>
46
+ </dict>
47
+ <key>columnSelection</key>
48
+ <false/>
49
+ <key>firstVisibleColumn</key>
50
+ <integer>0</integer>
51
+ <key>firstVisibleLine</key>
52
+ <integer>0</integer>
53
+ <key>selectFrom</key>
54
+ <dict>
55
+ <key>column</key>
56
+ <integer>19</integer>
57
+ <key>line</key>
58
+ <integer>7</integer>
59
+ </dict>
60
+ <key>selectTo</key>
61
+ <dict>
62
+ <key>column</key>
63
+ <integer>114</integer>
64
+ <key>line</key>
65
+ <integer>7</integer>
66
+ </dict>
67
+ </dict>
68
+ <key>test/spec/structure/maps_to_module_test.rb</key>
69
+ <dict>
70
+ <key>caret</key>
71
+ <dict>
72
+ <key>column</key>
73
+ <integer>0</integer>
74
+ <key>line</key>
75
+ <integer>0</integer>
76
+ </dict>
77
+ <key>columnSelection</key>
78
+ <false/>
79
+ <key>firstVisibleColumn</key>
80
+ <integer>0</integer>
81
+ <key>firstVisibleLine</key>
82
+ <integer>0</integer>
83
+ <key>selectFrom</key>
84
+ <dict>
85
+ <key>column</key>
86
+ <integer>0</integer>
87
+ <key>line</key>
88
+ <integer>2</integer>
89
+ </dict>
90
+ <key>selectTo</key>
91
+ <dict>
92
+ <key>column</key>
93
+ <integer>0</integer>
94
+ <key>line</key>
95
+ <integer>0</integer>
96
+ </dict>
97
+ </dict>
98
+ <key>test/spec/tables/table_test.rb</key>
99
+ <dict>
100
+ <key>caret</key>
101
+ <dict>
102
+ <key>column</key>
103
+ <integer>26</integer>
104
+ <key>line</key>
105
+ <integer>2</integer>
106
+ </dict>
107
+ <key>firstVisibleColumn</key>
108
+ <integer>0</integer>
109
+ <key>firstVisibleLine</key>
110
+ <integer>0</integer>
111
+ </dict>
112
+ <key>test/spec/tables/test_helper.rb</key>
113
+ <dict>
114
+ <key>caret</key>
115
+ <dict>
116
+ <key>column</key>
117
+ <integer>73</integer>
118
+ <key>line</key>
119
+ <integer>1</integer>
120
+ </dict>
121
+ <key>firstVisibleColumn</key>
122
+ <integer>0</integer>
123
+ <key>firstVisibleLine</key>
124
+ <integer>0</integer>
125
+ </dict>
126
+ <key>test/spec/tables/verify_rows_scsr_test.rb</key>
127
+ <dict>
128
+ <key>caret</key>
129
+ <dict>
130
+ <key>column</key>
131
+ <integer>20</integer>
132
+ <key>line</key>
133
+ <integer>0</integer>
134
+ </dict>
135
+ <key>firstVisibleColumn</key>
136
+ <integer>0</integer>
137
+ <key>firstVisibleLine</key>
138
+ <integer>0</integer>
139
+ </dict>
140
+ <key>test/spec/tables/verify_rows_simple_test.rb</key>
141
+ <dict>
142
+ <key>caret</key>
143
+ <dict>
144
+ <key>column</key>
145
+ <integer>0</integer>
146
+ <key>line</key>
147
+ <integer>17</integer>
148
+ </dict>
149
+ <key>firstVisibleColumn</key>
150
+ <integer>0</integer>
151
+ <key>firstVisibleLine</key>
152
+ <integer>0</integer>
153
+ </dict>
154
+ <key>test/spec/tables/verify_rows_test.rb</key>
155
+ <dict>
156
+ <key>caret</key>
157
+ <dict>
158
+ <key>column</key>
159
+ <integer>0</integer>
160
+ <key>line</key>
161
+ <integer>17</integer>
162
+ </dict>
163
+ <key>firstVisibleColumn</key>
164
+ <integer>0</integer>
165
+ <key>firstVisibleLine</key>
166
+ <integer>0</integer>
167
+ </dict>
168
+ <key>test/spec/user-reported/apostrophe_test.rb</key>
169
+ <dict>
170
+ <key>caret</key>
171
+ <dict>
172
+ <key>column</key>
173
+ <integer>0</integer>
174
+ <key>line</key>
175
+ <integer>0</integer>
176
+ </dict>
177
+ <key>firstVisibleColumn</key>
178
+ <integer>0</integer>
179
+ <key>firstVisibleLine</key>
180
+ <integer>0</integer>
181
+ </dict>
182
+ <key>test/spec/user-reported/ariel_example_test.rb</key>
183
+ <dict>
184
+ <key>caret</key>
185
+ <dict>
186
+ <key>column</key>
187
+ <integer>0</integer>
188
+ <key>line</key>
189
+ <integer>0</integer>
190
+ </dict>
191
+ <key>firstVisibleColumn</key>
192
+ <integer>0</integer>
193
+ <key>firstVisibleLine</key>
194
+ <integer>0</integer>
195
+ </dict>
196
+ <key>test/spec/user-reported/attr_assert_test.rb</key>
197
+ <dict>
198
+ <key>caret</key>
199
+ <dict>
200
+ <key>column</key>
201
+ <integer>0</integer>
202
+ <key>line</key>
203
+ <integer>12</integer>
204
+ </dict>
205
+ <key>firstVisibleColumn</key>
206
+ <integer>0</integer>
207
+ <key>firstVisibleLine</key>
208
+ <integer>0</integer>
209
+ </dict>
210
+ <key>test/spec/user-reported/basic_assert_true_test.rb</key>
211
+ <dict>
212
+ <key>caret</key>
213
+ <dict>
214
+ <key>column</key>
215
+ <integer>0</integer>
216
+ <key>line</key>
217
+ <integer>11</integer>
218
+ </dict>
219
+ <key>firstVisibleColumn</key>
220
+ <integer>0</integer>
221
+ <key>firstVisibleLine</key>
222
+ <integer>0</integer>
223
+ </dict>
224
+ <key>test/spec/user-reported/rubyish_test.rb</key>
225
+ <dict>
226
+ <key>caret</key>
227
+ <dict>
228
+ <key>column</key>
229
+ <integer>0</integer>
230
+ <key>line</key>
231
+ <integer>0</integer>
232
+ </dict>
233
+ <key>firstVisibleColumn</key>
234
+ <integer>0</integer>
235
+ <key>firstVisibleLine</key>
236
+ <integer>0</integer>
237
+ </dict>
238
+ </dict>
239
+ <key>openDocuments</key>
240
+ <array>
241
+ <string>lib/concordion/invoker.rb</string>
242
+ <string>test/concordion/invoker_test.rb</string>
243
+ </array>
244
+ <key>showFileHierarchyDrawer</key>
245
+ <true/>
246
+ <key>windowFrame</key>
247
+ <string>{{293, 55}, {1139, 823}}</string>
248
+ </dict>
249
+ </plist>
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/css_decorator'
3
+
4
+ module Concordion
5
+ class CssDecoratorTest < Test::Unit::TestCase
6
+ def test_does_not_write_if_file_exists
7
+ writer = mock("writer")
8
+ writer.expects(:output_file_exists?).with("concordion.css").once.returns(true)
9
+
10
+ Concordion::CSSDecorator.new.add_css_file_to_output_dir(writer, :link)
11
+ end
12
+
13
+ def test_writes_if_file_does_not_exist
14
+ writer = mock("writer")
15
+ writer.expects(:output_file_exists?).with("concordion.css").once.returns(false)
16
+ writer.expects(:calculate_filename_and_overwrite).with(anything, "concordion.css").once
17
+
18
+ Concordion::CSSDecorator.new.add_css_file_to_output_dir(writer, :link)
19
+ end
20
+
21
+ def test_does_not_write_if_not_link_eg_inline
22
+ writer = mock("writer")
23
+ writer.expects(:output_file_exists?).with("concordion.css").once.returns(false)
24
+
25
+ Concordion::CSSDecorator.new.add_css_file_to_output_dir(writer, :inline)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/environment'
3
+
4
+ module Concordion
5
+ class EnvironmentTest < Test::Unit::TestCase
6
+
7
+ def test_output_dir
8
+ restore_env do
9
+ ENV[Concordion::Environment.output_dir_key] = nil
10
+ assert_equal ".", Concordion::Environment.output_dir
11
+ ENV[Concordion::Environment.output_dir_key] = "foo/bar"
12
+ assert_equal "foo/bar", Concordion::Environment.output_dir
13
+ end
14
+ end
15
+
16
+ def test_clean_list
17
+ restore_env do
18
+ ENV[Concordion::Environment.output_dir_key] = nil
19
+ assert_equal ["./*_test_output.html", "./concordion.css"], Concordion::Environment.clean_list
20
+ ENV[Concordion::Environment.output_dir_key] = "foo/bar"
21
+ assert_equal ["foo/bar/*_test_output.html", "foo/bar/concordion.css"], Concordion::Environment.clean_list
22
+ end
23
+
24
+ end
25
+
26
+ def test_css_type_defaults_to_inline
27
+ restore_env do
28
+ ENV[Concordion::Environment.css_type_key] = "link"
29
+ assert_equal :link, Concordion::Environment.css_type
30
+
31
+ ENV[Concordion::Environment.css_type_key] = nil
32
+ assert_equal :inline, Concordion::Environment.css_type
33
+
34
+ end
35
+ end
36
+
37
+ private
38
+ def restore_env
39
+ orig_dir = ENV[Concordion::Environment.output_dir_key]
40
+ orig_type = ENV[Concordion::Environment.css_type_key]
41
+ yield
42
+ ENV[Concordion::Environment.output_dir_key] = orig_dir
43
+ ENV[Concordion::Environment.css_type_key] = orig_type.to_s
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/invoker'
3
+
4
+ module Concordion
5
+ class InvokerTest < Test::Unit::TestCase
6
+
7
+ def test_extracts_the_name_of_method_that_is_in_method_missing_for_rails_nil_class
8
+ full_error = "You have a nil object when you didn't expect it!\nThe error occurred while evaluating nil.foo"
9
+ e = NoMethodError.new full_error
10
+ assert_equal full_error, Invoker.new(mock()).method_from_no_method_error(e)
11
+ end
12
+
13
+ def test_extracts_the_name_of_class_that_is_in_method_missing_for_rails_nil_class
14
+ full_error = "You have a nil object when you didn't expect it!\nThe error occurred while evaluating nil.foo"
15
+ e = NoMethodError.new full_error
16
+ assert_equal "Class not known", Invoker.new(mock()).class_from_no_method_error(e)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/parse_result'
3
+
4
+ module Concordion
5
+ class ParseResultTest < Test::Unit::TestCase
6
+
7
+ def test_is_set_command
8
+ assert Concordion::ParseResult.new("set",nil,nil,nil).is_set_command?
9
+ assert !Concordion::ParseResult.new("asdf",nil,nil,nil).is_set_command?
10
+ end
11
+
12
+ def test_is_assert_image_command
13
+ assert Concordion::ParseResult.new("assert_image",nil,nil,nil).is_assert_image_command?
14
+ assert !Concordion::ParseResult.new("set",nil,nil,nil).is_assert_image_command?
15
+ end
16
+
17
+ def test_is_execute_command
18
+ assert Concordion::ParseResult.new("execute",nil,nil,nil).is_execute_command?
19
+ assert !Concordion::ParseResult.new("asdf",nil,nil,nil).is_execute_command?
20
+ end
21
+
22
+ def test_is_verify_command
23
+ assert Concordion::ParseResult.new("verifyrows",nil,nil,nil).is_verify_command?
24
+ assert !Concordion::ParseResult.new("monkeys",nil,nil,nil).is_verify_command?
25
+ end
26
+ def test_is_asserttrue_command
27
+ assert Concordion::ParseResult.new("asserttrue",nil,nil,nil).is_assert_true_command?
28
+ assert !Concordion::ParseResult.new("monkeys",nil,nil,nil).is_assert_true_command?
29
+ end
30
+
31
+ def test_image_location
32
+ tag = mock("tag")
33
+ tag.expects(:get_attribute).with('src').returns "foo"
34
+ assert_equal "foo", Concordion::ParseResult.new(nil,nil,nil, tag).image_location
35
+ end
36
+ def test_assignment
37
+ assert_equal "#user", Concordion::ParseResult.new("verifyrows"," #user = asdfasdf",nil,nil).assignment
38
+ assert_equal "#bob", Concordion::ParseResult.new("monkeys","#bob=asdf",nil,nil).assignment
39
+ end
40
+
41
+ def test_to_s
42
+ assert_equal "Concordion command[], System under test method[#asdf], Tag Content[] Image Location[]", Concordion::ParseResult.new(nil,"#asdf", nil,nil).to_s
43
+ end
44
+ def test_needs_dereference
45
+ assert Concordion::ParseResult.new(nil,"#asdf", nil,nil).needs_dereference?
46
+ assert !Concordion::ParseResult.new(nil,"asdf", nil,nil).needs_dereference?
47
+ assert !Concordion::ParseResult.new(nil,"as#df", nil,nil).needs_dereference?
48
+ assert !Concordion::ParseResult.new(nil,"#asdf = foo()", nil,nil).needs_dereference?
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/reader'
3
+
4
+ module Concordion
5
+ class ReaderTest < Test::Unit::TestCase
6
+ def test_foo
7
+ assert_raise RuntimeError do
8
+ Concordion::Reader.new.path_for("purple_monkey_dishwasher")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__) ,'..','test_helper')
2
+ require 'concordion/state'
3
+
4
+ module Concordion
5
+ class StateTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @concordion = Concordion::State.new
9
+ @thingy = Thingy.new()
10
+ end
11
+
12
+ def test_text_variable
13
+ assert_equal Concordion::State.TEXT_VAR, "#TEXT"
14
+ end
15
+
16
+ def test_set_variable
17
+ @concordion.set_variable("#foo", "bar")
18
+
19
+ assert_equal "bar", @concordion.get_variable("#foo")
20
+ end
21
+
22
+ def test_dereference
23
+ @concordion.set_variable("#result", @thingy)
24
+
25
+ assert_same @thingy, @concordion.dereference("#result")
26
+ end
27
+
28
+ def test_dereference_with_property
29
+ @concordion.set_variable("#result", @thingy)
30
+
31
+ assert_equal "bleh", @concordion.dereference("#result.prop")
32
+ end
33
+
34
+ class Thingy
35
+ attr_accessor :prop
36
+ def initialize
37
+ @prop = "bleh"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/string_writer'
3
+
4
+ module Concordion
5
+ class StringWriterTest < Test::Unit::TestCase
6
+ def test_foo
7
+ assert Concordion::StringWriter.new.output_file_exists?("this is a lie, i don't really exist, but thats ok for string writers")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,142 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/utility'
3
+
4
+ module Concordion
5
+ class UtilityTest < Test::Unit::TestCase
6
+ include Concordion::Utility
7
+
8
+ def test_supported
9
+ assert supported?('p')
10
+ assert supported?("p")
11
+ assert supported?("P")
12
+ assert !supported?("R")
13
+ end
14
+
15
+ def test_snakeCase
16
+ assert_equal "bob", snake_case("bob")
17
+ assert_equal "bob", snake_case("Bob")
18
+ assert_equal "camel_case", snake_case("CamelCase")
19
+ assert_equal "camel_case_var", snake_case("camelCaseVar")
20
+ end
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_modules_map_to_file_directories
30
+ assert_equal "foo/bob.html", snake_cased_test_name("Foo::bob")
31
+ assert_equal "foo/bob.html", snake_cased_test_name("Foo::Bob")
32
+ assert_equal "foo/bob.html", snake_cased_test_name("Foo::BobTest")
33
+ assert_equal "foo/bob_case.html", snake_cased_test_name("Foo::BobCaseTest")
34
+ end
35
+
36
+ def test_snake_cased_goldmaster_name
37
+ assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("bob")
38
+ assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("Bob")
39
+ assert_equal "bob_goldmaster.html", snake_cased_goldmaster_name("BobTest")
40
+ assert_equal "bob_case_goldmaster.html", snake_cased_goldmaster_name("BobCaseTest")
41
+ end
42
+
43
+ def test_conc_method_name_hard
44
+ assert_equal "greeting=", concordion_method_name("#result = greeting=(#TEXT)")
45
+ end
46
+
47
+ def test_escapes_single_quotes
48
+ assert_equal "A\\\\'s", escape_single_quotes("A's")
49
+ end
50
+
51
+ def test_conc_method_name_no_parens
52
+ assert_equal "invoke", concordion_method_name("invoke")
53
+ assert_equal "invoke", concordion_method_name("invoke #foo")
54
+
55
+ assert_equal "foo", concordion_method_name("#baz = foo #asdf, #fdsa")
56
+ assert_equal "greeting=", concordion_method_name("greeting= #TEXT")
57
+ end
58
+
59
+ def test_conc_method_name
60
+ assert_equal "invoke", concordion_method_name("invoke()")
61
+ assert_equal "invoke", concordion_method_name("invoke(")
62
+ assert_equal "invoke", concordion_method_name("invoke")
63
+ assert_equal "bleh", concordion_method_name("bleh(foo,bar)")
64
+ assert_equal "bleh", concordion_method_name("bleh ( foo , bar)")
65
+ assert_equal "foo", concordion_method_name("#baz = foo ( #asdf, #fdsa)")
66
+ assert_equal "greeting=", concordion_method_name("greeting=(#TEXT)")
67
+ end
68
+
69
+ def test_conc_var_name_no_parens
70
+ assert_equal "#result", concordion_variable_name("#result.first")
71
+ end
72
+ def test_conc_var_name
73
+ assert_equal "#result", concordion_variable_name("#result.first()")
74
+ assert_equal "#res", concordion_variable_name(" #res ")
75
+
76
+ end
77
+
78
+ def test_is_direct_method_call
79
+ assert is_direct_method_call?("invoke")
80
+ assert !is_direct_method_call?("invoke(#foo,#bar)")
81
+
82
+ end
83
+ def test_has_args_no_parens
84
+ assert !has_arguments?("invoke")
85
+ assert has_arguments?("invoke #foo")
86
+ assert has_arguments?("invoke #foo, #bar")
87
+
88
+ end
89
+
90
+ def test_has_args
91
+ assert has_arguments?("invoke(#foo,#bar)")
92
+ assert has_arguments?("invoke(#foo)")
93
+ assert !has_arguments?("invoke()")
94
+ end
95
+
96
+ def test_conc_args_no_parens
97
+ assert_equal [], concordion_arguments("invoke")
98
+ assert_equal ["#foo","#bar"], concordion_arguments("bleh #foo,#bar")
99
+ assert_equal ["#foo","#bar"], concordion_arguments("bleh #foo , #bar ")
100
+ assert_equal ["#foo","#bar"], concordion_arguments("#asdf = bleh #foo , #bar ")
101
+
102
+ end
103
+ def test_conc_args
104
+ assert_equal [], concordion_arguments("invoke()")
105
+ assert_equal ["#foo","#bar"], concordion_arguments("bleh(#foo,#bar)")
106
+ assert_equal ["#foo","#bar"], concordion_arguments("bleh ( #foo , #bar )")
107
+ assert_equal ["#foo","#bar"], concordion_arguments("#asdf = bleh ( #foo , #bar )")
108
+ end
109
+
110
+ def test_conc_assignment_no_parens
111
+ assert_equal "#foo", concordion_assignment(" #foo = getResult ")
112
+ end
113
+
114
+ def test_conc_assignment
115
+ assert_equal "#foo", concordion_assignment(" #foo = getResult() ")
116
+ assert_equal "#for", concordion_assignment("#for=")
117
+ end
118
+ def test_has_assignment
119
+ assert has_assignment?("=")
120
+ assert !has_assignment?("")
121
+ end
122
+
123
+ def test_has_property_ref
124
+ assert has_property_reference?("#res.foo")
125
+ assert !has_property_reference?("#res")
126
+
127
+ end
128
+
129
+ def test_property_ref
130
+ assert_equal "#foo", concordion_property_reference("#foo")
131
+ assert_equal "bar", concordion_property_reference(" #foo.bar ")
132
+ assert_equal "bar.baz", concordion_property_reference("#for.bar.baz")
133
+
134
+ end
135
+
136
+ def test_singular
137
+ assert_equal "bar", singular("bars")
138
+ assert_equal "foo", singular("foo")
139
+ end
140
+
141
+ end
142
+ end
@@ -0,0 +1,38 @@
1
+ require File.join(File.dirname(__FILE__),'..','test_helper')
2
+ require 'concordion/state'
3
+
4
+ module Concordion
5
+ class VerifierTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @concordion = Concordion::State.new
9
+ @verifier = Concordion::Verifier.new(@concordion)
10
+ end
11
+
12
+
13
+
14
+ def test_update_does_not_blow_up_if_verification_variable_unset
15
+ @verifier.verification_variable = nil
16
+ @verifier.update_verifier(1)
17
+ end
18
+
19
+ def test_update_verification
20
+ assert @concordion.get_variable("#user").nil?
21
+ @concordion.set_variable("#users", ["A", "B", "C"])
22
+ @verifier.verification_variable = "#users"
23
+ @verifier.update_verifier(2) # will be one larger because of the header row
24
+
25
+ assert_equal "B", @concordion.get_variable("#user")
26
+ end
27
+
28
+
29
+ def test_update_verification_automatically_sets_to_zero
30
+ assert @concordion.get_variable("#user").nil?
31
+ @concordion.set_variable("#users", ["A", "B", "C"])
32
+ @verifier.verification_variable = "#users"
33
+
34
+ assert_equal "A", @concordion.get_variable("#user")
35
+ end
36
+
37
+ end
38
+ end