rhodes-framework 1.0.10 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/Manifest.txt +159 -30
  2. data/Rakefile +3 -19
  3. data/lib/erb.rb +1 -1
  4. data/lib/rho/rho.rb +94 -107
  5. data/lib/rho/rhofsconnector.rb +4 -0
  6. data/lib/rho/rhoutils.rb +26 -0
  7. data/lib/rho/rhoviewhelpers.rb +1 -1
  8. data/lib/rhodes.rb +2 -2
  9. data/lib/rhoframework.rb +9 -9
  10. data/lib/rhom/rhom.rb +1 -1
  11. data/lib/rhom/rhom_db_adapter.rb +36 -15
  12. data/lib/rhom/rhom_db_adapterME.rb +2 -3
  13. data/lib/rhom/rhom_object.rb +14 -2
  14. data/lib/rhom/rhom_object_factory.rb +42 -11
  15. data/lib/version.rb +2 -2
  16. data/spec/README +1 -0
  17. data/spec/Rakefile +1 -0
  18. data/spec/{configs/account.rb → app/Account/config.rb} +0 -0
  19. data/spec/{configs/case.rb → app/Case/config.rb} +0 -0
  20. data/spec/app/Question/config.rb +3 -0
  21. data/spec/app/Settings/controller.rb +10 -0
  22. data/spec/app/Settings/index.erb +11 -0
  23. data/spec/app/SpecRunner/controller.rb +15 -0
  24. data/spec/app/SpecRunner/index.erb +14 -0
  25. data/spec/app/application.rb +4 -0
  26. data/spec/app/index.erb +17 -0
  27. data/spec/app/layout.erb +27 -0
  28. data/spec/app/loading.html +11 -0
  29. data/spec/app/mspec.rb +11 -0
  30. data/spec/app/mspec/expectations.rb +2 -0
  31. data/spec/app/mspec/expectations/expectations.rb +17 -0
  32. data/spec/app/mspec/expectations/should.rb +25 -0
  33. data/spec/app/mspec/fileutils.rb +1590 -0
  34. data/spec/app/mspec/guards.rb +16 -0
  35. data/spec/app/mspec/guards/background.rb +21 -0
  36. data/spec/app/mspec/guards/bug.rb +24 -0
  37. data/spec/app/mspec/guards/compliance.rb +37 -0
  38. data/spec/app/mspec/guards/conflict.rb +18 -0
  39. data/spec/app/mspec/guards/endian.rb +44 -0
  40. data/spec/app/mspec/guards/extensions.rb +20 -0
  41. data/spec/app/mspec/guards/guard.rb +166 -0
  42. data/spec/app/mspec/guards/noncompliance.rb +20 -0
  43. data/spec/app/mspec/guards/platform.rb +43 -0
  44. data/spec/app/mspec/guards/quarantine.rb +17 -0
  45. data/spec/app/mspec/guards/runner.rb +34 -0
  46. data/spec/app/mspec/guards/superuser.rb +17 -0
  47. data/spec/app/mspec/guards/support.rb +20 -0
  48. data/spec/app/mspec/guards/tty.rb +20 -0
  49. data/spec/app/mspec/guards/version.rb +38 -0
  50. data/spec/app/mspec/helpers.rb +11 -0
  51. data/spec/app/mspec/helpers/argv.rb +43 -0
  52. data/spec/app/mspec/helpers/bignum.rb +5 -0
  53. data/spec/app/mspec/helpers/const_lookup.rb +9 -0
  54. data/spec/app/mspec/helpers/environment.rb +23 -0
  55. data/spec/app/mspec/helpers/fixture.rb +20 -0
  56. data/spec/app/mspec/helpers/flunk.rb +5 -0
  57. data/spec/app/mspec/helpers/io.rb +17 -0
  58. data/spec/app/mspec/helpers/language_version.rb +20 -0
  59. data/spec/app/mspec/helpers/ruby_exe.rb +123 -0
  60. data/spec/app/mspec/helpers/scratch.rb +17 -0
  61. data/spec/app/mspec/helpers/tmp.rb +32 -0
  62. data/spec/app/mspec/matchers.rb +23 -0
  63. data/spec/app/mspec/matchers/base.rb +95 -0
  64. data/spec/app/mspec/matchers/be_an_instance_of.rb +26 -0
  65. data/spec/app/mspec/matchers/be_ancestor_of.rb +24 -0
  66. data/spec/app/mspec/matchers/be_close.rb +27 -0
  67. data/spec/app/mspec/matchers/be_empty.rb +20 -0
  68. data/spec/app/mspec/matchers/be_false.rb +20 -0
  69. data/spec/app/mspec/matchers/be_kind_of.rb +24 -0
  70. data/spec/app/mspec/matchers/be_nil.rb +20 -0
  71. data/spec/app/mspec/matchers/be_true.rb +20 -0
  72. data/spec/app/mspec/matchers/complain.rb +56 -0
  73. data/spec/app/mspec/matchers/eql.rb +26 -0
  74. data/spec/app/mspec/matchers/equal.rb +26 -0
  75. data/spec/app/mspec/matchers/equal_element.rb +78 -0
  76. data/spec/app/mspec/matchers/equal_utf16.rb +34 -0
  77. data/spec/app/mspec/matchers/have_constant.rb +30 -0
  78. data/spec/app/mspec/matchers/have_instance_method.rb +24 -0
  79. data/spec/app/mspec/matchers/have_method.rb +24 -0
  80. data/spec/app/mspec/matchers/have_private_instance_method.rb +24 -0
  81. data/spec/app/mspec/matchers/include.rb +32 -0
  82. data/spec/app/mspec/matchers/match_yaml.rb +47 -0
  83. data/spec/app/mspec/matchers/method.rb +14 -0
  84. data/spec/app/mspec/matchers/output.rb +67 -0
  85. data/spec/app/mspec/matchers/output_to_fd.rb +71 -0
  86. data/spec/app/mspec/matchers/raise_error.rb +48 -0
  87. data/spec/app/mspec/matchers/respond_to.rb +24 -0
  88. data/spec/app/mspec/matchers/stringsymboladapter.rb +8 -0
  89. data/spec/app/mspec/mocks.rb +3 -0
  90. data/spec/app/mspec/mocks/mock.rb +159 -0
  91. data/spec/app/mspec/mocks/object.rb +20 -0
  92. data/spec/app/mspec/mocks/proxy.rb +136 -0
  93. data/spec/app/mspec/pp.rb +893 -0
  94. data/spec/app/mspec/runner.rb +15 -0
  95. data/spec/app/mspec/runner/actions.rb +8 -0
  96. data/spec/app/mspec/runner/actions/debug.rb +17 -0
  97. data/spec/app/mspec/runner/actions/filter.rb +40 -0
  98. data/spec/app/mspec/runner/actions/gdb.rb +17 -0
  99. data/spec/app/mspec/runner/actions/tag.rb +133 -0
  100. data/spec/app/mspec/runner/actions/taglist.rb +56 -0
  101. data/spec/app/mspec/runner/actions/tagpurge.rb +56 -0
  102. data/spec/app/mspec/runner/actions/tally.rb +116 -0
  103. data/spec/app/mspec/runner/actions/timer.rb +22 -0
  104. data/spec/app/mspec/runner/context.rb +188 -0
  105. data/spec/app/mspec/runner/example.rb +34 -0
  106. data/spec/app/mspec/runner/exception.rb +43 -0
  107. data/spec/app/mspec/runner/filters.rb +4 -0
  108. data/spec/app/mspec/runner/filters/match.rb +22 -0
  109. data/spec/app/mspec/runner/filters/profile.rb +54 -0
  110. data/spec/app/mspec/runner/filters/regexp.rb +7 -0
  111. data/spec/app/mspec/runner/filters/tag.rb +29 -0
  112. data/spec/app/mspec/runner/formatters.rb +10 -0
  113. data/spec/app/mspec/runner/formatters/describe.rb +24 -0
  114. data/spec/app/mspec/runner/formatters/dotted.rb +98 -0
  115. data/spec/app/mspec/runner/formatters/file.rb +19 -0
  116. data/spec/app/mspec/runner/formatters/html.rb +81 -0
  117. data/spec/app/mspec/runner/formatters/method.rb +93 -0
  118. data/spec/app/mspec/runner/formatters/specdoc.rb +41 -0
  119. data/spec/app/mspec/runner/formatters/spinner.rb +99 -0
  120. data/spec/app/mspec/runner/formatters/summary.rb +11 -0
  121. data/spec/app/mspec/runner/formatters/unit.rb +21 -0
  122. data/spec/app/mspec/runner/formatters/yaml.rb +44 -0
  123. data/spec/app/mspec/runner/mspec.rb +361 -0
  124. data/spec/app/mspec/runner/object.rb +24 -0
  125. data/spec/app/mspec/runner/shared.rb +12 -0
  126. data/spec/app/mspec/runner/tag.rb +32 -0
  127. data/spec/app/mspec/utils/name_map.rb +129 -0
  128. data/spec/app/mspec/utils/options.rb +441 -0
  129. data/spec/app/mspec/utils/ruby_name.rb +8 -0
  130. data/spec/app/mspec/utils/script.rb +220 -0
  131. data/spec/app/mspec/utils/version.rb +53 -0
  132. data/spec/app/mspec/version.rb +5 -0
  133. data/spec/app/spec/fixtures/client_info.txt +2 -0
  134. data/spec/app/spec/fixtures/object_values.txt +90 -0
  135. data/spec/{rho_controller_spec.rb → app/spec/rho_controller_spec.rb} +4 -7
  136. data/spec/{rho_spec.rb → app/spec/rho_spec.rb} +15 -36
  137. data/spec/{rhom_object_factory_spec.rb → app/spec/rhom_object_factory_spec.rb} +108 -72
  138. data/spec/{rhom_spec.rb → app/spec/rhom_spec.rb} +8 -4
  139. data/spec/app/spec/spec_helper.rb +15 -0
  140. data/spec/app/spec/webview_spec.rb +27 -0
  141. data/spec/app/spec_runner.rb +26 -0
  142. data/spec/build.yml +28 -0
  143. data/spec/public/css/base.css +39 -0
  144. data/spec/public/css/blackberry.css +99 -0
  145. data/spec/public/css/iphone.css +392 -0
  146. data/spec/public/css/rho.css +3 -0
  147. data/spec/public/css/xhtml.css +114 -0
  148. data/spec/public/images/IUI_LICENSE.txt +21 -0
  149. data/spec/public/images/backButton.png +0 -0
  150. data/spec/public/images/blueButton.png +0 -0
  151. data/spec/public/images/cancel.png +0 -0
  152. data/spec/public/images/grayButton.png +0 -0
  153. data/spec/public/images/iui-logo-touch-icon.png +0 -0
  154. data/spec/public/images/listArrow.png +0 -0
  155. data/spec/public/images/listArrowSel.png +0 -0
  156. data/spec/public/images/listGroup.png +0 -0
  157. data/spec/public/images/loading.gif +0 -0
  158. data/spec/public/images/pinstripes.png +0 -0
  159. data/spec/public/images/right_button.png +0 -0
  160. data/spec/public/images/selection.png +0 -0
  161. data/spec/public/images/thumb.png +0 -0
  162. data/spec/public/images/toggle.png +0 -0
  163. data/spec/public/images/toggleOn.png +0 -0
  164. data/spec/public/images/toolButton.png +0 -0
  165. data/spec/public/images/toolButton_new.png +0 -0
  166. data/spec/public/images/toolbar.png +0 -0
  167. data/spec/public/images/whiteButton.png +0 -0
  168. data/spec/public/js/application.js +1 -0
  169. data/spec/public/js/jquery-1.2.6.min.js +32 -0
  170. data/spec/public/js/rho.js +4 -0
  171. data/spec/public/js/rhogeolocation-wm.js +59 -0
  172. data/spec/public/js/rhogeolocation.js +11 -0
  173. data/spec/rhoconfig.txt +19 -0
  174. metadata +169 -39
  175. data/History.txt +0 -37
  176. data/README.rdoc +0 -2
  177. data/lib/TestServe.rb +0 -9
  178. data/res/sqlite3/constants.rb +0 -49
  179. data/res/sqlite3/database.rb +0 -715
  180. data/res/sqlite3/driver/dl/api.rb +0 -154
  181. data/res/sqlite3/driver/dl/driver.rb +0 -307
  182. data/res/sqlite3/driver/native/driver.rb +0 -257
  183. data/res/sqlite3/errors.rb +0 -68
  184. data/res/sqlite3/pragmas.rb +0 -271
  185. data/res/sqlite3/resultset.rb +0 -176
  186. data/res/sqlite3/sqlite3_api.rb +0 -0
  187. data/res/sqlite3/statement.rb +0 -230
  188. data/res/sqlite3/translator.rb +0 -109
  189. data/res/sqlite3/value.rb +0 -57
  190. data/res/sqlite3/version.rb +0 -14
  191. data/rhodes.gemspec +0 -18
  192. data/spec/app_manifest.txt +0 -4
  193. data/spec/configs/contact.rb +0 -3
  194. data/spec/configs/employee.rb +0 -3
  195. data/spec/spec.opts +0 -1
  196. data/spec/spec_helper.rb +0 -49
  197. data/spec/stubs.rb +0 -39
  198. data/spec/syncdbtest.sqlite +0 -0
@@ -0,0 +1,23 @@
1
+ require 'mspec/matchers/base'
2
+ require 'mspec/matchers/be_ancestor_of'
3
+ require 'mspec/matchers/be_close'
4
+ require 'mspec/matchers/be_empty'
5
+ require 'mspec/matchers/be_false'
6
+ require 'mspec/matchers/be_kind_of'
7
+ require 'mspec/matchers/be_nil'
8
+ require 'mspec/matchers/be_true'
9
+ require 'mspec/matchers/complain'
10
+ require 'mspec/matchers/eql'
11
+ require 'mspec/matchers/equal'
12
+ require 'mspec/matchers/equal_element'
13
+ require 'mspec/matchers/equal_utf16'
14
+ require 'mspec/matchers/have_constant'
15
+ require 'mspec/matchers/have_instance_method'
16
+ require 'mspec/matchers/have_method'
17
+ require 'mspec/matchers/have_private_instance_method'
18
+ require 'mspec/matchers/include'
19
+ require 'mspec/matchers/match_yaml'
20
+ require 'mspec/matchers/raise_error'
21
+ require 'mspec/matchers/output'
22
+ require 'mspec/matchers/output_to_fd'
23
+ require 'mspec/matchers/respond_to'
@@ -0,0 +1,95 @@
1
+ class PositiveOperatorMatcher
2
+ def initialize(actual)
3
+ @actual = actual
4
+ end
5
+
6
+ def ==(expected)
7
+ unless @actual == expected
8
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
9
+ "to equal #{expected.pretty_inspect}")
10
+ end
11
+ end
12
+
13
+ def <(expected)
14
+ unless @actual < expected
15
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
16
+ "to be less than #{expected.pretty_inspect}")
17
+ end
18
+ end
19
+
20
+ def <=(expected)
21
+ unless @actual <= expected
22
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
23
+ "to be less than or equal to #{expected.pretty_inspect}")
24
+ end
25
+ end
26
+
27
+ def >(expected)
28
+ unless @actual > expected
29
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
30
+ "to be greater than #{expected.pretty_inspect}")
31
+ end
32
+ end
33
+
34
+ def >=(expected)
35
+ unless @actual >= expected
36
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
37
+ "to be greater than or equal to #{expected.pretty_inspect}")
38
+ end
39
+ end
40
+
41
+ def =~(expected)
42
+ unless @actual =~ expected
43
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
44
+ "to match #{expected.pretty_inspect}")
45
+ end
46
+ end
47
+ end
48
+
49
+ class NegativeOperatorMatcher
50
+ def initialize(actual)
51
+ @actual = actual
52
+ end
53
+
54
+ def ==(expected)
55
+ if @actual == expected
56
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
57
+ "not to equal #{expected.pretty_inspect}")
58
+ end
59
+ end
60
+
61
+ def <(expected)
62
+ if @actual < expected
63
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
64
+ "not to be less than #{expected.pretty_inspect}")
65
+ end
66
+ end
67
+
68
+ def <=(expected)
69
+ if @actual <= expected
70
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
71
+ "not to be less than or equal to #{expected.pretty_inspect}")
72
+ end
73
+ end
74
+
75
+ def >(expected)
76
+ if @actual > expected
77
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
78
+ "not to be greater than #{expected.pretty_inspect}")
79
+ end
80
+ end
81
+
82
+ def >=(expected)
83
+ if @actual >= expected
84
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
85
+ "not to be greater than or equal to #{expected.pretty_inspect}")
86
+ end
87
+ end
88
+
89
+ def =~(expected)
90
+ if @actual =~ expected
91
+ Expectation.fail_with("Expected #{@actual.pretty_inspect}",
92
+ "not to match #{expected.pretty_inspect}")
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,26 @@
1
+ class BeAnInstanceOfMatcher
2
+ def initialize(expected)
3
+ @expected = expected
4
+ end
5
+
6
+ def matches?(actual)
7
+ @actual = actual
8
+ @actual.instance_of?(@expected)
9
+ end
10
+
11
+ def failure_message
12
+ ["Expected #{@actual.inspect} (#{@actual.class})",
13
+ "to be an instance of #{@expected}"]
14
+ end
15
+
16
+ def negative_failure_message
17
+ ["Expected #{@actual.inspect} (#{@actual.class})",
18
+ "not to be an instance of #{@expected}"]
19
+ end
20
+ end
21
+
22
+ class Object
23
+ def be_an_instance_of(expected)
24
+ BeAnInstanceOfMatcher.new(expected)
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ class BeAncestorOfMatcher
2
+ def initialize(expected)
3
+ @expected = expected
4
+ end
5
+
6
+ def matches?(actual)
7
+ @actual = actual
8
+ @expected.ancestors.include? @actual
9
+ end
10
+
11
+ def failure_message
12
+ ["Expected #{@actual}", "to be an ancestor of #{@expected}"]
13
+ end
14
+
15
+ def negative_failure_message
16
+ ["Expected #{@actual}", "not to be an ancestor of #{@expected}"]
17
+ end
18
+ end
19
+
20
+ class Object
21
+ def be_ancestor_of(expected)
22
+ BeAncestorOfMatcher.new(expected)
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
2
+
3
+ class BeCloseMatcher
4
+ def initialize(expected, tolerance)
5
+ @expected = expected
6
+ @tolerance = tolerance
7
+ end
8
+
9
+ def matches?(actual)
10
+ @actual = actual
11
+ (@actual - @expected).abs < @tolerance
12
+ end
13
+
14
+ def failure_message
15
+ ["Expected #{@expected}", "to be within +/- #{@tolerance} of #{@actual}"]
16
+ end
17
+
18
+ def negative_failure_message
19
+ ["Expected #{@expected}", "not to be within +/- #{@tolerance} of #{@actual}"]
20
+ end
21
+ end
22
+
23
+ class Object
24
+ def be_close(expected, tolerance)
25
+ BeCloseMatcher.new(expected, tolerance)
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ class BeEmptyMatcher
2
+ def matches?(actual)
3
+ @actual = actual
4
+ @actual.empty?
5
+ end
6
+
7
+ def failure_message
8
+ ["Expected #{@actual.inspect}", "to be empty"]
9
+ end
10
+
11
+ def negative_failure_message
12
+ ["Expected #{@actual.inspect}", "not to be empty"]
13
+ end
14
+ end
15
+
16
+ class Object
17
+ def be_empty
18
+ BeEmptyMatcher.new
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ class BeFalseMatcher
2
+ def matches?(actual)
3
+ @actual = actual
4
+ @actual == false
5
+ end
6
+
7
+ def failure_message
8
+ ["Expected #{@actual.inspect}", "to be false"]
9
+ end
10
+
11
+ def negative_failure_message
12
+ ["Expected #{@actual.inspect}", "not to be false"]
13
+ end
14
+ end
15
+
16
+ class Object
17
+ def be_false
18
+ BeFalseMatcher.new
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ class BeKindOfMatcher
2
+ def initialize(expected)
3
+ @expected = expected
4
+ end
5
+
6
+ def matches?(actual)
7
+ @actual = actual
8
+ @actual.is_a?(@expected)
9
+ end
10
+
11
+ def failure_message
12
+ ["Expected #{@actual.inspect} (#{@actual.class})", "to be kind of #{@expected}"]
13
+ end
14
+
15
+ def negative_failure_message
16
+ ["Expected #{@actual.inspect} (#{@actual.class})", "not to be kind of #{@expected}"]
17
+ end
18
+ end
19
+
20
+ class Object
21
+ def be_kind_of(expected)
22
+ BeKindOfMatcher.new(expected)
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ class BeNilMatcher
2
+ def matches?(actual)
3
+ @actual = actual
4
+ @actual.nil?
5
+ end
6
+
7
+ def failure_message
8
+ ["Expected #{@actual.inspect}", "to be nil"]
9
+ end
10
+
11
+ def negative_failure_message
12
+ ["Expected #{@actual.inspect}", "not to be nil"]
13
+ end
14
+ end
15
+
16
+ class Object
17
+ def be_nil
18
+ BeNilMatcher.new
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ class BeTrueMatcher
2
+ def matches?(actual)
3
+ @actual = actual
4
+ @actual == true
5
+ end
6
+
7
+ def failure_message
8
+ ["Expected #{@actual.inspect}", "to be true"]
9
+ end
10
+
11
+ def negative_failure_message
12
+ ["Expected #{@actual.inspect}", "not to be true"]
13
+ end
14
+ end
15
+
16
+ class Object
17
+ def be_true
18
+ BeTrueMatcher.new
19
+ end
20
+ end
@@ -0,0 +1,56 @@
1
+ require 'mspec/helpers/io'
2
+
3
+ class ComplainMatcher
4
+ def initialize(complaint)
5
+ @complaint = complaint
6
+ end
7
+
8
+ def matches?(proc)
9
+ @saved_err = $stderr
10
+ @stderr = $stderr = IOStub.new
11
+ @verbose = $VERBOSE
12
+ $VERBOSE = false
13
+
14
+ proc.call
15
+
16
+ unless @complaint.nil?
17
+ case @complaint
18
+ when Regexp
19
+ return false unless $stderr =~ @complaint
20
+ else
21
+ return false unless $stderr == @complaint
22
+ end
23
+ end
24
+
25
+ return $stderr.empty? ? false : true
26
+ ensure
27
+ $VERBOSE = @verbose
28
+ $stderr = @saved_err
29
+ end
30
+
31
+ def failure_message
32
+ if @complaint.nil?
33
+ ["Expected a warning", "but received none"]
34
+ elsif @complaint.kind_of? Regexp
35
+ ["Expected warning to match:", @complaint.inspect]
36
+ else
37
+ ["Expected warning: #{@complaint.inspect}", "but got: #{@stderr.chomp.inspect}"]
38
+ end
39
+ end
40
+
41
+ def negative_failure_message
42
+ if @complaint.nil?
43
+ ["Unexpected warning: ", @stderr.chomp.inspect]
44
+ elsif @complaint.kind_of? Regexp
45
+ ["Expected warning not to match:", @complaint.inspect]
46
+ else
47
+ ["Expected warning: #{@complaint.inspect}", "but got: #{@stderr.chomp.inspect}"]
48
+ end
49
+ end
50
+ end
51
+
52
+ class Object
53
+ def complain(complaint=nil)
54
+ ComplainMatcher.new(complaint)
55
+ end
56
+ end
@@ -0,0 +1,26 @@
1
+ class EqlMatcher
2
+ def initialize(expected)
3
+ @expected = expected
4
+ end
5
+
6
+ def matches?(actual)
7
+ @actual = actual
8
+ @actual.eql?(@expected)
9
+ end
10
+
11
+ def failure_message
12
+ ["Expected #{@actual.pretty_inspect}",
13
+ "to have same value and type as #{@expected.pretty_inspect}"]
14
+ end
15
+
16
+ def negative_failure_message
17
+ ["Expected #{@actual.pretty_inspect}",
18
+ "not to have same value or type as #{@expected.pretty_inspect}"]
19
+ end
20
+ end
21
+
22
+ class Object
23
+ def eql(expected)
24
+ EqlMatcher.new(expected)
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ class EqualMatcher
2
+ def initialize(expected)
3
+ @expected = expected
4
+ end
5
+
6
+ def matches?(actual)
7
+ @actual = actual
8
+ @actual.equal?(@expected)
9
+ end
10
+
11
+ def failure_message
12
+ ["Expected #{@actual.pretty_inspect}",
13
+ "to be identical to #{@expected.pretty_inspect}"]
14
+ end
15
+
16
+ def negative_failure_message
17
+ ["Expected #{@actual.pretty_inspect}",
18
+ "not to be identical to #{@expected.pretty_inspect}"]
19
+ end
20
+ end
21
+
22
+ class Object
23
+ def equal(expected)
24
+ EqualMatcher.new(expected)
25
+ end
26
+ end
@@ -0,0 +1,78 @@
1
+ class EqualElementMatcher
2
+ def initialize(element, attributes = nil, content = nil, options = {})
3
+ @element = element
4
+ @attributes = attributes
5
+ @content = content
6
+ @options = options
7
+ end
8
+
9
+ def matches?(actual)
10
+ @actual = actual
11
+
12
+ matched = true
13
+
14
+ if @options[:not_closed]
15
+ matched &&= actual =~ /^#{Regexp.quote("<" + @element)}.*#{Regexp.quote(">" + (@content || ''))}$/
16
+ else
17
+ matched &&= actual =~ /^#{Regexp.quote("<" + @element)}/
18
+ matched &&= actual =~ /#{Regexp.quote("</" + @element + ">")}$/
19
+ matched &&= actual =~ /#{Regexp.quote(">" + @content + "</")}/ if @content
20
+ end
21
+
22
+ if @attributes
23
+ if @attributes.empty?
24
+ matched &&= actual.scan(/\w+\=\"(.*)\"/).size == 0
25
+ else
26
+ @attributes.each do |key, value|
27
+ if value == true
28
+ matched &&= (actual.scan(/#{Regexp.quote(key)}(\s|>)/).size == 1)
29
+ else
30
+ matched &&= (actual.scan(%Q{ #{key}="#{value}"}).size == 1)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ !!matched
37
+ end
38
+
39
+ def failure_message
40
+ ["Expected #{@actual.pretty_inspect}",
41
+ "to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
42
+ end
43
+
44
+ def negative_failure_message
45
+ ["Expected #{@actual.pretty_inspect}",
46
+ "not to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
47
+ end
48
+
49
+ def attributes_for_failure_message
50
+ if @attributes
51
+ if @attributes.empty?
52
+ "no attributes"
53
+ else
54
+ @attributes.inject([]) { |memo, n| memo << %Q{#{n[0]}="#{n[1]}"} }.join(" ")
55
+ end
56
+ else
57
+ "any attributes"
58
+ end
59
+ end
60
+
61
+ def content_for_failure_message
62
+ if @content
63
+ if @content.empty?
64
+ "no content"
65
+ else
66
+ "#{@content.inspect} as content"
67
+ end
68
+ else
69
+ "any content"
70
+ end
71
+ end
72
+ end
73
+
74
+ class Object
75
+ def equal_element(*args)
76
+ EqualElementMatcher.new(*args)
77
+ end
78
+ end