has_finder 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (432) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +431 -0
  4. data/README.txt +1 -0
  5. data/Rakefile +4 -0
  6. data/config/hoe.rb +70 -0
  7. data/config/requirements.rb +17 -0
  8. data/lib/has_finder.rb +1 -0
  9. data/lib/has_finder/has_finder.rb +84 -0
  10. data/lib/has_finder/metaid.rb +15 -0
  11. data/lib/has_finder/version.rb +9 -0
  12. data/log/debug.log +0 -0
  13. data/nbproject/private/private.xml +4 -0
  14. data/nbproject/private/rake-t.txt +1 -0
  15. data/nbproject/project.properties +4 -0
  16. data/nbproject/project.xml +15 -0
  17. data/script/destroy +14 -0
  18. data/script/generate +14 -0
  19. data/setup.rb +1585 -0
  20. data/spec/rails/README +182 -0
  21. data/spec/rails/Rakefile +10 -0
  22. data/spec/rails/app/controllers/application.rb +7 -0
  23. data/spec/rails/app/helpers/application_helper.rb +3 -0
  24. data/spec/rails/app/models/being.rb +3 -0
  25. data/spec/rails/config/boot.rb +45 -0
  26. data/spec/rails/config/database.yml +36 -0
  27. data/spec/rails/config/environment.rb +62 -0
  28. data/spec/rails/config/environments/development.rb +21 -0
  29. data/spec/rails/config/environments/production.rb +18 -0
  30. data/spec/rails/config/environments/test.rb +19 -0
  31. data/spec/rails/config/routes.rb +23 -0
  32. data/spec/rails/db/migrate/001_create_beings.rb +12 -0
  33. data/spec/rails/db/schema.rb +17 -0
  34. data/spec/rails/doc/README_FOR_APP +2 -0
  35. data/spec/rails/log/development.log +432 -0
  36. data/spec/rails/log/production.log +0 -0
  37. data/spec/rails/log/server.log +0 -0
  38. data/spec/rails/log/test.log +5820 -0
  39. data/spec/rails/nbproject/private/config.properties +0 -0
  40. data/spec/rails/nbproject/private/private.properties +1 -0
  41. data/spec/rails/nbproject/private/rake-t.txt +54 -0
  42. data/spec/rails/nbproject/project.properties +4 -0
  43. data/spec/rails/nbproject/project.xml +9 -0
  44. data/spec/rails/previous_failures.txt +0 -0
  45. data/spec/rails/public/404.html +30 -0
  46. data/spec/rails/public/500.html +30 -0
  47. data/spec/rails/public/dispatch.cgi +10 -0
  48. data/spec/rails/public/dispatch.fcgi +24 -0
  49. data/spec/rails/public/dispatch.rb +10 -0
  50. data/spec/rails/public/favicon.ico +0 -0
  51. data/spec/rails/public/images/rails.png +0 -0
  52. data/spec/rails/public/index.html +277 -0
  53. data/spec/rails/public/javascripts/application.js +2 -0
  54. data/spec/rails/public/javascripts/controls.js +833 -0
  55. data/spec/rails/public/javascripts/dragdrop.js +942 -0
  56. data/spec/rails/public/javascripts/effects.js +1088 -0
  57. data/spec/rails/public/javascripts/prototype.js +2515 -0
  58. data/spec/rails/public/robots.txt +1 -0
  59. data/spec/rails/script/about +3 -0
  60. data/spec/rails/script/breakpointer +3 -0
  61. data/spec/rails/script/console +3 -0
  62. data/spec/rails/script/destroy +3 -0
  63. data/spec/rails/script/generate +3 -0
  64. data/spec/rails/script/performance/benchmarker +3 -0
  65. data/spec/rails/script/performance/profiler +3 -0
  66. data/spec/rails/script/plugin +3 -0
  67. data/spec/rails/script/process/inspector +3 -0
  68. data/spec/rails/script/process/reaper +3 -0
  69. data/spec/rails/script/process/spawner +3 -0
  70. data/spec/rails/script/runner +3 -0
  71. data/spec/rails/script/server +3 -0
  72. data/spec/rails/script/spec +4 -0
  73. data/spec/rails/script/spec_server +45 -0
  74. data/spec/rails/spec/fixtures/beings.yml +12 -0
  75. data/spec/rails/spec/models/being_spec.rb +98 -0
  76. data/spec/rails/spec/spec.opts +6 -0
  77. data/spec/rails/spec/spec_helper.rb +15 -0
  78. data/spec/rails/test/test_helper.rb +28 -0
  79. data/spec/rails/tmp/sessions/ruby_sess.5edc9bf3b65456d0 +0 -0
  80. data/spec/rails/vendor/plugins/rspec/CHANGES +797 -0
  81. data/spec/rails/vendor/plugins/rspec/MIT-LICENSE +20 -0
  82. data/spec/rails/vendor/plugins/rspec/README +70 -0
  83. data/spec/rails/vendor/plugins/rspec/Rakefile +304 -0
  84. data/spec/rails/vendor/plugins/rspec/UPGRADE +31 -0
  85. data/spec/rails/vendor/plugins/rspec/bin/spec +3 -0
  86. data/spec/rails/vendor/plugins/rspec/bin/spec_translator +8 -0
  87. data/spec/rails/vendor/plugins/rspec/examples/auto_spec_description_example.rb +19 -0
  88. data/spec/rails/vendor/plugins/rspec/examples/before_and_after_example.rb +39 -0
  89. data/spec/rails/vendor/plugins/rspec/examples/behave_as_example.rb +45 -0
  90. data/spec/rails/vendor/plugins/rspec/examples/custom_expectation_matchers.rb +54 -0
  91. data/spec/rails/vendor/plugins/rspec/examples/custom_formatter.rb +11 -0
  92. data/spec/rails/vendor/plugins/rspec/examples/dynamic_spec.rb +9 -0
  93. data/spec/rails/vendor/plugins/rspec/examples/file_accessor.rb +18 -0
  94. data/spec/rails/vendor/plugins/rspec/examples/file_accessor_spec.rb +38 -0
  95. data/spec/rails/vendor/plugins/rspec/examples/greeter_spec.rb +30 -0
  96. data/spec/rails/vendor/plugins/rspec/examples/helper_method_example.rb +11 -0
  97. data/spec/rails/vendor/plugins/rspec/examples/io_processor.rb +8 -0
  98. data/spec/rails/vendor/plugins/rspec/examples/io_processor_spec.rb +21 -0
  99. data/spec/rails/vendor/plugins/rspec/examples/legacy_spec.rb +10 -0
  100. data/spec/rails/vendor/plugins/rspec/examples/mocking_example.rb +27 -0
  101. data/spec/rails/vendor/plugins/rspec/examples/multi_threaded_behaviour_runner.rb +25 -0
  102. data/spec/rails/vendor/plugins/rspec/examples/not_yet_implemented_spec.rb +12 -0
  103. data/spec/rails/vendor/plugins/rspec/examples/partial_mock_example.rb +28 -0
  104. data/spec/rails/vendor/plugins/rspec/examples/predicate_example.rb +27 -0
  105. data/spec/rails/vendor/plugins/rspec/examples/priority.txt +1 -0
  106. data/spec/rails/vendor/plugins/rspec/examples/shared_behaviours_example.rb +39 -0
  107. data/spec/rails/vendor/plugins/rspec/examples/spec_helper.rb +1 -0
  108. data/spec/rails/vendor/plugins/rspec/examples/stack.rb +36 -0
  109. data/spec/rails/vendor/plugins/rspec/examples/stack_spec.rb +97 -0
  110. data/spec/rails/vendor/plugins/rspec/examples/stubbing_example.rb +69 -0
  111. data/spec/rails/vendor/plugins/rspec/examples/test_case_adapter_example.rb +26 -0
  112. data/spec/rails/vendor/plugins/rspec/examples/test_case_spec.rb +65 -0
  113. data/spec/rails/vendor/plugins/rspec/failing_examples/diffing_spec.rb +36 -0
  114. data/spec/rails/vendor/plugins/rspec/failing_examples/failure_in_setup.rb +10 -0
  115. data/spec/rails/vendor/plugins/rspec/failing_examples/failure_in_teardown.rb +10 -0
  116. data/spec/rails/vendor/plugins/rspec/failing_examples/mocking_example.rb +33 -0
  117. data/spec/rails/vendor/plugins/rspec/failing_examples/mocking_with_flexmock.rb +26 -0
  118. data/spec/rails/vendor/plugins/rspec/failing_examples/mocking_with_mocha.rb +25 -0
  119. data/spec/rails/vendor/plugins/rspec/failing_examples/partial_mock_example.rb +20 -0
  120. data/spec/rails/vendor/plugins/rspec/failing_examples/predicate_example.rb +29 -0
  121. data/spec/rails/vendor/plugins/rspec/failing_examples/raising_example.rb +47 -0
  122. data/spec/rails/vendor/plugins/rspec/failing_examples/spec_helper.rb +1 -0
  123. data/spec/rails/vendor/plugins/rspec/failing_examples/syntax_error_example.rb +7 -0
  124. data/spec/rails/vendor/plugins/rspec/failing_examples/team_spec.rb +46 -0
  125. data/spec/rails/vendor/plugins/rspec/failing_examples/timeout_behaviour.rb +7 -0
  126. data/spec/rails/vendor/plugins/rspec/init.rb +3 -0
  127. data/spec/rails/vendor/plugins/rspec/lib/autotest/discover.rb +3 -0
  128. data/spec/rails/vendor/plugins/rspec/lib/autotest/rspec.rb +67 -0
  129. data/spec/rails/vendor/plugins/rspec/lib/spec.rb +13 -0
  130. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl.rb +10 -0
  131. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb +210 -0
  132. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/behaviour_callbacks.rb +78 -0
  133. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb +220 -0
  134. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb +42 -0
  135. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb +28 -0
  136. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/configuration.rb +119 -0
  137. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/description.rb +69 -0
  138. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/example.rb +127 -0
  139. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/example_matcher.rb +40 -0
  140. data/spec/rails/vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb +74 -0
  141. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations.rb +56 -0
  142. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb +61 -0
  143. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/errors.rb +6 -0
  144. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions.rb +2 -0
  145. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb +66 -0
  146. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions/string_and_symbol.rb +17 -0
  147. data/spec/rails/vendor/plugins/rspec/lib/spec/expectations/handler.rb +43 -0
  148. data/spec/rails/vendor/plugins/rspec/lib/spec/extensions.rb +1 -0
  149. data/spec/rails/vendor/plugins/rspec/lib/spec/extensions/object.rb +6 -0
  150. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers.rb +166 -0
  151. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/be.rb +206 -0
  152. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/be_close.rb +37 -0
  153. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/change.rb +120 -0
  154. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/eql.rb +43 -0
  155. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/equal.rb +43 -0
  156. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/has.rb +44 -0
  157. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/have.rb +145 -0
  158. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/include.rb +70 -0
  159. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/match.rb +41 -0
  160. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb +72 -0
  161. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb +100 -0
  162. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/respond_to.rb +45 -0
  163. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/satisfy.rb +47 -0
  164. data/spec/rails/vendor/plugins/rspec/lib/spec/matchers/throw_symbol.rb +72 -0
  165. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks.rb +208 -0
  166. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb +27 -0
  167. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb +183 -0
  168. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb +84 -0
  169. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/errors.rb +10 -0
  170. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/extensions/object.rb +3 -0
  171. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb +231 -0
  172. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/methods.rb +35 -0
  173. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/mock.rb +29 -0
  174. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/order_group.rb +29 -0
  175. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/proxy.rb +163 -0
  176. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/space.rb +28 -0
  177. data/spec/rails/vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb +30 -0
  178. data/spec/rails/vendor/plugins/rspec/lib/spec/rake/spectask.rb +175 -0
  179. data/spec/rails/vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb +52 -0
  180. data/spec/rails/vendor/plugins/rspec/lib/spec/runner.rb +165 -0
  181. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb +56 -0
  182. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb +102 -0
  183. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/command_line.rb +22 -0
  184. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/drb_command_line.rb +21 -0
  185. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/extensions/kernel.rb +50 -0
  186. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/extensions/object.rb +32 -0
  187. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter.rb +9 -0
  188. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb +68 -0
  189. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb +102 -0
  190. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/failing_behaviours_formatter.rb +25 -0
  191. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/failing_examples_formatter.rb +22 -0
  192. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb +316 -0
  193. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb +30 -0
  194. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/rdoc_formatter.rb +24 -0
  195. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
  196. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb +28 -0
  197. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/heckle_runner.rb +72 -0
  198. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/heckle_runner_unsupported.rb +10 -0
  199. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/option_parser.rb +226 -0
  200. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/options.rb +158 -0
  201. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/reporter.rb +114 -0
  202. data/spec/rails/vendor/plugins/rspec/lib/spec/runner/spec_parser.rb +50 -0
  203. data/spec/rails/vendor/plugins/rspec/lib/spec/test_case_adapter.rb +10 -0
  204. data/spec/rails/vendor/plugins/rspec/lib/spec/translator.rb +106 -0
  205. data/spec/rails/vendor/plugins/rspec/lib/spec/version.rb +22 -0
  206. data/spec/rails/vendor/plugins/rspec/plugins/mock_frameworks/flexmock.rb +27 -0
  207. data/spec/rails/vendor/plugins/rspec/plugins/mock_frameworks/mocha.rb +21 -0
  208. data/spec/rails/vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb +18 -0
  209. data/spec/rails/vendor/plugins/rspec/rake_tasks/examples.rake +7 -0
  210. data/spec/rails/vendor/plugins/rspec/rake_tasks/examples_specdoc.rake +9 -0
  211. data/spec/rails/vendor/plugins/rspec/rake_tasks/examples_with_rcov.rake +9 -0
  212. data/spec/rails/vendor/plugins/rspec/rake_tasks/failing_examples_with_html.rake +9 -0
  213. data/spec/rails/vendor/plugins/rspec/rake_tasks/verify_rcov.rake +7 -0
  214. data/spec/rails/vendor/plugins/rspec/spec.opts +13 -0
  215. data/spec/rails/vendor/plugins/rspec/spec/README.jruby +14 -0
  216. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/behaviour_eval_spec.rb +49 -0
  217. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/behaviour_factory_spec.rb +30 -0
  218. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/behaviour_spec.rb +624 -0
  219. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/composite_proc_builder_spec.rb +57 -0
  220. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/configuration_spec.rb +50 -0
  221. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/description_spec.rb +81 -0
  222. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/example_class_spec.rb +24 -0
  223. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/example_instance_spec.rb +162 -0
  224. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/example_should_raise_spec.rb +137 -0
  225. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/predicate_matcher_spec.rb +21 -0
  226. data/spec/rails/vendor/plugins/rspec/spec/spec/dsl/shared_behaviour_spec.rb +228 -0
  227. data/spec/rails/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb +107 -0
  228. data/spec/rails/vendor/plugins/rspec/spec/spec/expectations/extensions/object_spec.rb +46 -0
  229. data/spec/rails/vendor/plugins/rspec/spec/spec/expectations/fail_with_spec.rb +71 -0
  230. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb +39 -0
  231. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb +209 -0
  232. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/change_spec.rb +232 -0
  233. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/description_generation_spec.rb +159 -0
  234. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/eql_spec.rb +28 -0
  235. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb +28 -0
  236. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb +48 -0
  237. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/handler_spec.rb +88 -0
  238. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb +37 -0
  239. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/have_spec.rb +272 -0
  240. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/include_spec.rb +45 -0
  241. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb +37 -0
  242. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/matcher_methods_spec.rb +78 -0
  243. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/mock_constraint_matchers_spec.rb +24 -0
  244. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb +158 -0
  245. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb +147 -0
  246. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb +54 -0
  247. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/satisfy_spec.rb +36 -0
  248. data/spec/rails/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb +51 -0
  249. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb +29 -0
  250. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/argument_expectation_spec.rb +19 -0
  251. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/at_least_spec.rb +97 -0
  252. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/at_most_spec.rb +93 -0
  253. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
  254. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/bug_report_7611_spec.rb +19 -0
  255. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/bug_report_7805_spec.rb +22 -0
  256. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb +31 -0
  257. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/bug_report_8302_spec.rb +26 -0
  258. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +114 -0
  259. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/mock_ordering_spec.rb +84 -0
  260. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/mock_space_spec.rb +54 -0
  261. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb +377 -0
  262. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/multiple_return_value_spec.rb +113 -0
  263. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb +40 -0
  264. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb +53 -0
  265. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb +33 -0
  266. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb +52 -0
  267. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +66 -0
  268. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +148 -0
  269. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb +52 -0
  270. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/record_messages_spec.rb +26 -0
  271. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb +159 -0
  272. data/spec/rails/vendor/plugins/rspec/spec/spec/mocks/twice_counts_spec.rb +67 -0
  273. data/spec/rails/vendor/plugins/rspec/spec/spec/package/bin_spec_spec.rb +12 -0
  274. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/behaviour_runner_spec.rb +206 -0
  275. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb +33 -0
  276. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/context_matching_spec.rb +27 -0
  277. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb +81 -0
  278. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/empty_file.txt +0 -0
  279. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/example_matcher_spec.rb +127 -0
  280. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/examples.txt +2 -0
  281. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb +31 -0
  282. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/extensions/kernel_spec.rb +36 -0
  283. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/failed.txt +3 -0
  284. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +27 -0
  285. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +28 -0
  286. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.4.html +333 -0
  287. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +344 -0
  288. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5.html +338 -0
  289. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html +338 -0
  290. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb +56 -0
  291. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +21 -0
  292. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +36 -0
  293. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +78 -0
  294. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +19 -0
  295. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/rdoc_formatter_spec.rb +46 -0
  296. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb +11 -0
  297. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +21 -0
  298. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb +56 -0
  299. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb +63 -0
  300. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/heckler_spec.rb +14 -0
  301. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +45 -0
  302. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/object_ext_spec.rb +11 -0
  303. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb +348 -0
  304. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/options_spec.rb +142 -0
  305. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +56 -0
  306. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb +153 -0
  307. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/spec.opts +2 -0
  308. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb +93 -0
  309. data/spec/rails/vendor/plugins/rspec/spec/spec/runner/spec_spaced.opts +2 -0
  310. data/spec/rails/vendor/plugins/rspec/spec/spec/spec_classes.rb +111 -0
  311. data/spec/rails/vendor/plugins/rspec/spec/spec/translator_spec.rb +216 -0
  312. data/spec/rails/vendor/plugins/rspec/spec/spec_helper.rb +43 -0
  313. data/spec/rails/vendor/plugins/rspec_on_rails/MIT-LICENSE +31 -0
  314. data/spec/rails/vendor/plugins/rspec_on_rails/README +1 -0
  315. data/spec/rails/vendor/plugins/rspec_on_rails/Rakefile +9 -0
  316. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES +1 -0
  317. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb +31 -0
  318. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt +0 -0
  319. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec +4 -0
  320. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server +45 -0
  321. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts +6 -0
  322. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb +26 -0
  323. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE +33 -0
  324. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb +42 -0
  325. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb +23 -0
  326. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb +11 -0
  327. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb +12 -0
  328. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE +18 -0
  329. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb +30 -0
  330. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb +11 -0
  331. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +161 -0
  332. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb +303 -0
  333. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +25 -0
  334. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb +4 -0
  335. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb +22 -0
  336. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb +26 -0
  337. data/spec/rails/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb +22 -0
  338. data/spec/rails/vendor/plugins/rspec_on_rails/init.rb +9 -0
  339. data/spec/rails/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb +81 -0
  340. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/dsl.rb +2 -0
  341. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/dsl/configuration.rb +23 -0
  342. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/matchers.rb +3 -0
  343. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb +12 -0
  344. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails.rb +57 -0
  345. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl.rb +40 -0
  346. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/assigns_hash_proxy.rb +42 -0
  347. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour.rb +8 -0
  348. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/base.rb +82 -0
  349. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/controller.rb +246 -0
  350. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/functional.rb +90 -0
  351. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/helper.rb +100 -0
  352. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/model.rb +21 -0
  353. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb +185 -0
  354. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/ivar_proxy.rb +62 -0
  355. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb +7 -0
  356. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/base.rb +11 -0
  357. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb +10 -0
  358. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb +5 -0
  359. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/base.rb +26 -0
  360. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/base.rb +29 -0
  361. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/object.rb +5 -0
  362. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb +29 -0
  363. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/assert_select.rb +131 -0
  364. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb +55 -0
  365. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb +106 -0
  366. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb +63 -0
  367. data/spec/rails/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb +26 -0
  368. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/assigns_hash_proxy_spec.rb +55 -0
  369. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/behaviour_factory_spec.rb +53 -0
  370. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_isolation_spec.rb +43 -0
  371. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/controller_spec_spec.rb +124 -0
  372. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb +62 -0
  373. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/ivar_proxy_spec.rb +64 -0
  374. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/model_spec_spec.rb +14 -0
  375. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/shared_behaviour_spec.rb +16 -0
  376. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/test_unit_assertion_accessibility_spec.rb +28 -0
  377. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb +165 -0
  378. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb +17 -0
  379. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb +718 -0
  380. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb +42 -0
  381. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb +183 -0
  382. data/spec/rails/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb +112 -0
  383. data/spec/rails/vendor/plugins/rspec_on_rails/spec/spec_helper.rb +40 -0
  384. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb +36 -0
  385. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/controllers/redirect_spec_controller.rb +59 -0
  386. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb +18 -0
  387. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/controllers/rjs_spec_controller.rb +58 -0
  388. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/helpers/explicit_helper.rb +10 -0
  389. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/helpers/more_explicit_helper.rb +5 -0
  390. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/helpers/plugin_application_helper.rb +6 -0
  391. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/helpers/view_spec_helper.rb +13 -0
  392. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_a_partial.rhtml +0 -0
  393. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml +1 -0
  394. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml +1 -0
  395. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml +0 -0
  396. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml +1 -0
  397. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_template.rhtml +1 -0
  398. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml +0 -0
  399. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.js.rjs +1 -0
  400. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml +0 -0
  401. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rjs +1 -0
  402. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml +1 -0
  403. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_div.rjs +1 -0
  404. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_page_element.rjs +1 -0
  405. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/insert_html.rjs +1 -0
  406. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace.rjs +1 -0
  407. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html.rjs +1 -0
  408. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs +1 -0
  409. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_effect.rjs +1 -0
  410. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs +1 -0
  411. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/no_tags.rhtml +1 -0
  412. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml +1 -0
  413. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml +1 -0
  414. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_included_partial.rhtml +2 -0
  415. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_included_partial_collection_with_spacer_template.rhtml +1 -0
  416. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml +1 -0
  417. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_spacer.rhtml +1 -0
  418. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml +3 -0
  419. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/entry_form.rhtml +2 -0
  420. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/explicit_helper.rhtml +2 -0
  421. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/multiple_helpers.rhtml +3 -0
  422. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/partial_collection_including_template.rhtml +2 -0
  423. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/partial_including_template.rhtml +2 -0
  424. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/partial_with_array.rhtml +1 -0
  425. data/spec/rails/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/show.rhtml +2 -0
  426. data/spec/rails/vendor/plugins/rspec_on_rails/tasks/rspec.rake +90 -0
  427. data/tasks/deployment.rake +27 -0
  428. data/tasks/environment.rake +7 -0
  429. data/tasks/website.rake +9 -0
  430. data/test/test_has_finder.rb +11 -0
  431. data/test/test_helper.rb +2 -0
  432. metadata +490 -0
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ Spec::Runner.configuration.global_fixtures = :people
3
+
4
+ describe "HelperBehaviour", :behaviour_type => :helper do
5
+ helper_name :explicit
6
+
7
+ it "should have direct access to methods defined in helpers" do
8
+ method_in_explicit_helper.should =~ /text from a method/
9
+ end
10
+ end
11
+
12
+
13
+ describe "HelperBehaviour#eval_erb", :behaviour_type => :helper do
14
+ helper_name :explicit
15
+
16
+ it "should support methods that accept blocks" do
17
+ eval_erb("<% prepend 'foo' do %>bar<% end %>").should == "foobar"
18
+ end
19
+ end
20
+
21
+ describe "HelperBehaviour.fixtures", :behaviour_type => :helper do
22
+ helper_name :explicit
23
+ fixtures :animals
24
+
25
+ it "loads fixtures" do
26
+ pig = animals(:pig)
27
+ pig.class.should == Animal
28
+ end
29
+
30
+ it "loads global fixtures" do
31
+ lachie = people(:lachie)
32
+ lachie.class.should == Person
33
+ end
34
+ end
35
+
36
+ describe ExplicitHelper, :behaviour_type => :helper do
37
+ it "should not require naming the helper if describe is passed a type" do
38
+ method_in_explicit_helper.should match(/text from a method/)
39
+ end
40
+ end
41
+
42
+ module Spec
43
+ module Rails
44
+ module DSL
45
+ describe HelperBehaviour do
46
+ it "should tell you its behaviour_type is :helper" do
47
+ behaviour = HelperBehaviour.new("") {}
48
+ behaviour.behaviour_type.should == :helper
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ module Bug11223
56
+ # see http://rubyforge.org/tracker/index.php?func=detail&aid=11223&group_id=797&atid=3149
57
+ describe 'Accessing flash from helper spec', :behaviour_type => :helper do
58
+ it 'should not raise an error' do
59
+ lambda { flash['test'] }.should_not raise_error
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,64 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "IvarProxy setup", :shared => true do
4
+ before do
5
+ @object = Object.new
6
+ @proxy = Spec::Rails::DSL::IvarProxy.new(@object)
7
+ end
8
+ end
9
+
10
+ describe "IvarProxy" do
11
+ it_should_behave_like "IvarProxy setup"
12
+
13
+ it "has [] accessor" do
14
+ @proxy['foo'] = 'bar'
15
+ @object.instance_variable_get(:@foo).should == 'bar'
16
+ @proxy['foo'].should == 'bar'
17
+ end
18
+
19
+ it "iterates through each element like a Hash" do
20
+ values = {
21
+ 'foo' => 1,
22
+ 'bar' => 2,
23
+ 'baz' => 3
24
+ }
25
+ @proxy['foo'] = values['foo']
26
+ @proxy['bar'] = values['bar']
27
+ @proxy['baz'] = values['baz']
28
+
29
+ @proxy.each do |key, value|
30
+ key.should == key
31
+ value.should == values[key]
32
+ end
33
+ end
34
+
35
+ it "detects the presence of a key" do
36
+ @proxy['foo'] = 'bar'
37
+ @proxy.has_key?('foo').should == true
38
+ @proxy.has_key?('bar').should == false
39
+ end
40
+ end
41
+
42
+ describe "IvarProxy", "#delete" do
43
+ it_should_behave_like "IvarProxy setup"
44
+
45
+ it "deletes the element with key" do
46
+ @proxy['foo'] = 'bar'
47
+ @proxy.delete('foo').should == 'bar'
48
+ @proxy['foo'].should be_nil
49
+ end
50
+
51
+ it "deletes nil instance variables" do
52
+ @proxy['foo'] = nil
53
+ @object.instance_variables.should include("@foo")
54
+ @proxy.delete('foo').should == nil
55
+ @proxy['foo'].should be_nil
56
+ @object.instance_variables.should_not include("@foo")
57
+ end
58
+
59
+ it "returns nil when key does not exist" do
60
+ @proxy['foo'].should be_nil
61
+ @proxy.delete('foo').should == nil
62
+ @proxy['foo'].should be_nil
63
+ end
64
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Spec
4
+ module Rails
5
+ module DSL
6
+ describe ModelBehaviour do
7
+ it "should tell you its behaviour_type is :model" do
8
+ behaviour = ModelBehaviour.new("") {}
9
+ behaviour.behaviour_type.should == :model
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "A shared view behaviour", :shared => true do
4
+ it "should have some tag with some text" do
5
+ response.should have_tag('div', 'This is text from a method in the ViewSpecHelper')
6
+ end
7
+ end
8
+
9
+ describe "A view behaviour", :behaviour_type => :view do
10
+ it_should_behave_like "A shared view behaviour"
11
+
12
+ before(:each) do
13
+ render "view_spec/show"
14
+ end
15
+ end
16
+
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ ['model','view','helper'].each do |context|
4
+ describe "A #{context} spec should be able to access 'test/unit' assertions", :behaviour_type => context.to_sym do
5
+
6
+ it "like assert_equal" do
7
+ assert_equal 1, 1
8
+ lambda {
9
+ assert_equal 1, 2
10
+ }.should raise_error(Test::Unit::AssertionFailedError)
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+ ['integration', 'isolation'].each do |mode|
17
+ describe "A controller spec in #{mode} mode should be able to access 'test/unit' assertions", :behaviour_type => :controller do
18
+ controller_name :controller_spec
19
+ integrate_views if mode == 'integration'
20
+
21
+ it "like assert_equal" do
22
+ assert_equal 1, 1
23
+ lambda {
24
+ assert_equal 1, 2
25
+ }.should raise_error(Test::Unit::AssertionFailedError)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,165 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "A view with an implicit helper", :behaviour_type => :view do
4
+ before(:each) do
5
+ render "view_spec/show"
6
+ end
7
+
8
+ it "should include the helper" do
9
+ response.should have_tag('div', :content => "This is text from a method in the ViewSpecHelper")
10
+ end
11
+
12
+ it "should include the application helper" do
13
+ response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
14
+ end
15
+ end
16
+
17
+ describe "A view requiring an explicit helper", :behaviour_type => :view do
18
+ before(:each) do
19
+ render "view_spec/explicit_helper", :helper => 'explicit'
20
+ end
21
+
22
+ it "should include the helper if specified" do
23
+ response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
24
+ end
25
+
26
+ it "should include the application helper" do
27
+ response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
28
+ end
29
+ end
30
+
31
+ describe "A view requiring multiple explicit helpers", :behaviour_type => :view do
32
+ before(:each) do
33
+ render "view_spec/multiple_helpers", :helpers => ['explicit', 'more_explicit']
34
+ end
35
+
36
+ it "should included all specified helpers" do
37
+ response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
38
+ response.should have_tag('div', :content => "This is text from a method in the MoreExplicitHelper")
39
+ end
40
+
41
+ it "should include the application helper" do
42
+ response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
43
+ end
44
+ end
45
+
46
+ describe "A view that includes a partial", :behaviour_type => :view do
47
+ def render!
48
+ render "view_spec/partial_including_template"
49
+ end
50
+
51
+ it "should render the enclosing template" do
52
+ render!
53
+ response.should have_tag('div', "method_in_included_partial in ViewSpecHelper")
54
+ end
55
+
56
+ it "should render the partial" do
57
+ render!
58
+ response.should have_tag('div', "method_in_partial_including_template in ViewSpecHelper")
59
+ end
60
+
61
+ it "should include the application helper" do
62
+ render!
63
+ response.should have_tag('div', "This is text from a method in the ApplicationHelper")
64
+ end
65
+
66
+ it "should support mocking the render call" do
67
+ template.should_receive(:render).with(:partial => 'included_partial')
68
+ render!
69
+ end
70
+ end
71
+
72
+ describe "A view that includes a partial using :collection and :spacer_template", :behaviour_type => :view do
73
+ before(:each) do
74
+ render "view_spec/partial_collection_including_template"
75
+ end
76
+
77
+ it "should render the partial w/ spacer_tamplate" do
78
+ response.should have_tag('div', :content => 'Alice')
79
+ response.should have_tag('hr', :attributes =>{:id => "spacer"})
80
+ response.should have_tag('div', :content => 'Bob')
81
+ end
82
+
83
+ end
84
+
85
+ describe "A view that includes a partial using an array as partial_path", :behaviour_type => :view do
86
+ before(:each) do
87
+ module ActionView::Partials
88
+ def render_partial_with_array_support(partial_path, local_assigns = nil, deprecated_local_assigns = nil)
89
+ if partial_path.is_a?(Array)
90
+ "Array Partial"
91
+ else
92
+ render_partial_without_array_support(partial_path, local_assigns, deprecated_local_assigns)
93
+ end
94
+ end
95
+
96
+ alias :render_partial_without_array_support :render_partial
97
+ alias :render_partial :render_partial_with_array_support
98
+ end
99
+
100
+ @array = ['Alice', 'Bob']
101
+ assigns[:array] = @array
102
+ end
103
+
104
+ after(:each) do
105
+ module ActionView::Partials
106
+ alias :render_partial_with_array_support :render_partial
107
+ alias :render_partial :render_partial_without_array_support
108
+ undef render_partial_with_array_support
109
+ end
110
+ end
111
+
112
+ it "should render have the array passed through to render_partial without modification" do
113
+ render "view_spec/partial_with_array"
114
+ response.body.should match(/^Array Partial$/)
115
+ end
116
+ end
117
+
118
+ describe "Different types of renders (not :template)", :behaviour_type => :view do
119
+ it "should render partial with local" do
120
+ render :partial => "view_spec/partial_with_local_variable", :locals => {:x => "Ender"}
121
+ response.should have_tag('div', :content => "Ender")
122
+ end
123
+ end
124
+
125
+ describe "A view", :behaviour_type => :view do
126
+ before(:each) do
127
+ session[:key] = "session"
128
+ params[:key] = "params"
129
+ flash[:key] = "flash"
130
+ render "view_spec/accessor"
131
+ end
132
+
133
+ it "should have access to session data" do
134
+ response.should have_tag("div#session", "session")
135
+ end
136
+
137
+ specify "should have access to params data" do
138
+ puts response.body
139
+ response.should have_tag("div#params", "params")
140
+ end
141
+
142
+ it "should have access to flash data" do
143
+ response.should have_tag("div#flash", "flash")
144
+ end
145
+ end
146
+
147
+ describe "A view with a form_tag", :behaviour_type => :view do
148
+ it "should render the right action" do
149
+ render "view_spec/entry_form"
150
+ response.should have_tag("form[action=?]","/view_spec/entry_form")
151
+ end
152
+ end
153
+
154
+ module Spec
155
+ module Rails
156
+ module DSL
157
+ describe ViewBehaviour do
158
+ it "should tell you its behaviour_type is :view" do
159
+ behaviour = ViewBehaviour.new("") {}
160
+ behaviour.behaviour_type.should == :view
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ class Thing < ActiveRecord::Base
4
+ validates_presence_of :name
5
+ end
6
+
7
+ describe "A model" do
8
+ it "should tell you its required fields" do
9
+ Thing.new.should have(1).error_on(:name)
10
+ end
11
+
12
+ it "should tell you how many records it has" do
13
+ Thing.should have(:no).records
14
+ Thing.create(:name => "THE THING")
15
+ Thing.should have(1).record
16
+ end
17
+ end
@@ -0,0 +1,718 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ # assert_select plugins for Rails
4
+ #
5
+ # Copyright (c) 2006 Assaf Arkin, under Creative Commons Attribution and/or MIT License
6
+ # Developed for http://co.mments.com
7
+ # Code and documention: http://labnotes.org
8
+
9
+ class AssertSelectController < ActionController::Base
10
+
11
+ def response=(content)
12
+ @content = content
13
+ end
14
+
15
+ #NOTE - this is commented because response is implemented in lib/spec/rails/context/controller
16
+ # def response(&block)
17
+ # @update = block
18
+ # end
19
+ #
20
+ def html()
21
+ render :text=>@content, :layout=>false, :content_type=>Mime::HTML
22
+ @content = nil
23
+ end
24
+
25
+ def rjs()
26
+ update = @update
27
+ render :update do |page|
28
+ update.call page
29
+ end
30
+ @update = nil
31
+ end
32
+
33
+ def xml()
34
+ render :text=>@content, :layout=>false, :content_type=>Mime::XML
35
+ @content = nil
36
+ end
37
+
38
+ def rescue_action(e)
39
+ raise e
40
+ end
41
+
42
+ end
43
+
44
+ class AssertSelectMailer < ActionMailer::Base
45
+
46
+ def test(html)
47
+ recipients "test <test@test.host>"
48
+ from "test@test.host"
49
+ subject "Test e-mail"
50
+ part :content_type=>"text/html", :body=>html
51
+ end
52
+
53
+ end
54
+
55
+ module AssertSelectSpecHelpers
56
+ def render_html(html)
57
+ @controller.response = html
58
+ get :html
59
+ end
60
+
61
+ def render_rjs(&block)
62
+ clear_response
63
+ @controller.response &block
64
+ get :rjs
65
+ end
66
+
67
+ def render_xml(xml)
68
+ @controller.response = xml
69
+ get :xml
70
+ end
71
+
72
+ private
73
+ # necessary for 1.2.1
74
+ def clear_response
75
+ render_html("")
76
+ end
77
+ end
78
+
79
+ unless defined?(SpecFailed)
80
+ SpecFailed = Spec::Expectations::ExpectationNotMetError
81
+ end
82
+
83
+ describe "should have_tag", :behaviour_type => :controller do
84
+ include AssertSelectSpecHelpers
85
+ controller_name :assert_select
86
+ integrate_views
87
+
88
+ it "should find specific numbers of elements" do
89
+ render_html %Q{<div id="1"></div><div id="2"></div>}
90
+ response.should have_tag( "div" )
91
+ response.should have_tag("div", 2)
92
+ lambda { response.should_not have_tag("div") }.should raise_error(SpecFailed, "should not have tag(\"div\"), but did")
93
+
94
+ lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed)
95
+ lambda { response.should have_tag("p") }.should raise_error(SpecFailed)
96
+ end
97
+
98
+ it "should expect to find elements when using true" do
99
+ render_html %Q{<div id="1"></div><div id="2"></div>}
100
+ response.should have_tag( "div", true )
101
+ lambda { response.should have_tag( "p", true )}.should raise_error(SpecFailed)
102
+ end
103
+
104
+ it "should expect to not find elements when using false" do
105
+ render_html %Q{<div id="1"></div><div id="2"></div>}
106
+ response.should have_tag( "p", false )
107
+ lambda { response.should have_tag( "div", false )}.should raise_error(SpecFailed)
108
+ end
109
+
110
+
111
+ it "should match submitted text using text or regexp" do
112
+ render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
113
+ response.should have_tag("div", "foo")
114
+ response.should have_tag("div", /(foo|bar)/)
115
+ response.should have_tag("div", :text=>"foo")
116
+ response.should have_tag("div", :text=>/(foo|bar)/)
117
+
118
+ lambda { response.should have_tag("div", "bar") }.should raise_error(SpecFailed)
119
+ lambda { response.should have_tag("div", :text=>"bar") }.should raise_error(SpecFailed)
120
+ lambda { response.should have_tag("p", :text=>"foo") }.should raise_error(SpecFailed)
121
+
122
+ lambda { response.should have_tag("div", /foobar/) }.should raise_error(SpecFailed)
123
+ lambda { response.should have_tag("div", :text=>/foobar/) }.should raise_error(SpecFailed)
124
+ lambda { response.should have_tag("p", :text=>/foo/) }.should raise_error(SpecFailed)
125
+ end
126
+
127
+ it "should use submitted message" do
128
+ render_html %Q{nothing here}
129
+ lambda {
130
+ response.should have_tag("div", {}, "custom message")
131
+ }.should raise_error(SpecFailed, /custom message/)
132
+ end
133
+
134
+ it "should match submitted html" do
135
+ render_html %Q{<p>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</p>}
136
+ text = "\"This is not a big problem,\" he said."
137
+ html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said."
138
+ response.should have_tag("p", text)
139
+ lambda { response.should have_tag("p", html) }.should raise_error(SpecFailed)
140
+ response.should have_tag("p", :html=>html)
141
+ lambda { response.should have_tag("p", :html=>text) }.should raise_error(SpecFailed)
142
+
143
+ # # No stripping for pre.
144
+ render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>}
145
+ text = "\n\"This is not a big problem,\" he said.\n"
146
+ html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n"
147
+ response.should have_tag("pre", text)
148
+ lambda { response.should have_tag("pre", html) }.should raise_error(SpecFailed)
149
+ response.should have_tag("pre", :html=>html)
150
+ lambda { response.should have_tag("pre", :html=>text) }.should raise_error(SpecFailed)
151
+ end
152
+
153
+ it "should match number of instances" do
154
+ render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
155
+ response.should have_tag("div", 2)
156
+ lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed)
157
+ response.should have_tag("div", 1..2)
158
+ lambda { response.should have_tag("div", 3..4) }.should raise_error(SpecFailed)
159
+ response.should have_tag("div", :count=>2)
160
+ lambda { response.should have_tag("div", :count=>3) }.should raise_error(SpecFailed)
161
+ response.should have_tag("div", :minimum=>1)
162
+ response.should have_tag("div", :minimum=>2)
163
+ lambda { response.should have_tag("div", :minimum=>3) }.should raise_error(SpecFailed)
164
+ response.should have_tag("div", :maximum=>2)
165
+ response.should have_tag("div", :maximum=>3)
166
+ lambda { response.should have_tag("div", :maximum=>1) }.should raise_error(SpecFailed)
167
+ response.should have_tag("div", :minimum=>1, :maximum=>2)
168
+ lambda { response.should have_tag("div", :minimum=>3, :maximum=>4) }.should raise_error(SpecFailed)
169
+ end
170
+
171
+ it "substitution values" do
172
+ render_html %Q{<div id="1">foo</div><div id="2">foo</div><span id="3"></span>}
173
+ response.should have_tag("div#?", /\d+/) do |elements| #using do/end
174
+ elements.size.should == 2
175
+ end
176
+ response.should have_tag("div#?", /\d+/) { |elements| #using {}
177
+ elements.size.should == 2
178
+ }
179
+ lambda {
180
+ response.should have_tag("div#?", /\d+/) do |elements|
181
+ elements.size.should == 3
182
+ end
183
+ }.should raise_error(SpecFailed, "expected 3, got 2 (using ==)")
184
+
185
+ lambda {
186
+ response.should have_tag("div#?", /\d+/) { |elements|
187
+ elements.size.should == 3
188
+ }
189
+ }.should raise_error(SpecFailed, "expected 3, got 2 (using ==)")
190
+
191
+ response.should have_tag("div#?", /\d+/) do |elements|
192
+ elements.size.should == 2
193
+ with_tag("#1")
194
+ with_tag("#2")
195
+ without_tag("#3")
196
+ end
197
+ end
198
+
199
+ #added for RSpec
200
+ it "nested tags in form" do
201
+ render_html %Q{
202
+ <form action="test">
203
+ <input type="text" name="email">
204
+ </form>
205
+ <form action="other">
206
+ <input type="text" name="other_input">
207
+ </form>
208
+ }
209
+ response.should have_tag("form[action=test]") { |form|
210
+ with_tag("input[type=text][name=email]")
211
+ }
212
+ response.should have_tag("form[action=test]") { |form|
213
+ with_tag("input[type=text][name=email]")
214
+ }
215
+
216
+ lambda {
217
+ response.should have_tag("form[action=test]") { |form|
218
+ with_tag("input[type=text][name=other_input]")
219
+ }
220
+ }.should raise_error(SpecFailed)
221
+
222
+ lambda {
223
+ response.should have_tag("form[action=test]") {
224
+ with_tag("input[type=text][name=other_input]")
225
+ }
226
+ }.should raise_error(SpecFailed)
227
+ end
228
+
229
+ it "beatles" do
230
+ unless defined?(BEATLES)
231
+ BEATLES = [
232
+ ["John", "Guitar"],
233
+ ["George", "Guitar"],
234
+ ["Paul", "Bass"],
235
+ ["Ringo", "Drums"]
236
+ ]
237
+ end
238
+
239
+ render_html %Q{
240
+ <div id="beatles">
241
+ <div class="beatle">
242
+ <h2>John</h2><p>Guitar</p>
243
+ </div>
244
+ <div class="beatle">
245
+ <h2>George</h2><p>Guitar</p>
246
+ </div>
247
+ <div class="beatle">
248
+ <h2>Paul</h2><p>Bass</p>
249
+ </div>
250
+ <div class="beatle">
251
+ <h2>Ringo</h2><p>Drums</p>
252
+ </div>
253
+ </div>
254
+ }
255
+ response.should have_tag("div#beatles>div[class=\"beatle\"]", 4)
256
+
257
+ response.should have_tag("div#beatles>div.beatle") {
258
+ BEATLES.each { |name, instrument|
259
+ with_tag("div.beatle>h2", name)
260
+ with_tag("div.beatle>p", instrument)
261
+ without_tag("div.beatle>span")
262
+ }
263
+ }
264
+ end
265
+
266
+ it "assert_select_text_match" do
267
+ render_html %Q{<div id="1"><span>foo</span></div><div id="2"><span>bar</span></div>}
268
+ response.should have_tag("div") do |divs|
269
+ with_tag("div", "foo")
270
+ with_tag("div", "bar")
271
+ with_tag("div", /\w*/)
272
+ with_tag("div", /\w*/, :count=>2)
273
+ without_tag("div", :text=>"foo", :count=>2)
274
+ with_tag("div", :html=>"<span>bar</span>")
275
+ with_tag("div", :html=>"<span>bar</span>")
276
+ with_tag("div", :html=>/\w*/)
277
+ with_tag("div", :html=>/\w*/, :count=>2)
278
+ without_tag("div", :html=>"<span>foo</span>", :count=>2)
279
+ end
280
+ end
281
+
282
+
283
+ it "assert_select_from_rjs with one item" do
284
+ render_rjs do |page|
285
+ page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
286
+ end
287
+ response.should have_tag("div") { |elements|
288
+ elements.size.should == 2
289
+ with_tag("#1")
290
+ with_tag("#2")
291
+ }
292
+
293
+ lambda {
294
+ response.should have_tag("div") { |elements|
295
+ elements.size.should == 2
296
+ with_tag("#1")
297
+ with_tag("#3")
298
+ }
299
+ }.should raise_error(SpecFailed)
300
+
301
+ lambda {
302
+ response.should have_tag("div") { |elements|
303
+ elements.size.should == 2
304
+ with_tag("#1")
305
+ without_tag("#2")
306
+ }
307
+ }.should raise_error(SpecFailed, "should not have tag(\"#2\"), but did")
308
+
309
+ lambda {
310
+ response.should have_tag("div") { |elements|
311
+ elements.size.should == 3
312
+ with_tag("#1")
313
+ with_tag("#2")
314
+ }
315
+ }.should raise_error(SpecFailed)
316
+
317
+
318
+ response.should have_tag("div#?", /\d+/) { |elements|
319
+ with_tag("#1")
320
+ with_tag("#2")
321
+ }
322
+ end
323
+
324
+ it "assert_select_from_rjs with multiple items" do
325
+ render_rjs do |page|
326
+ page.replace_html "test", "<div id=\"1\">foo</div>"
327
+ page.replace_html "test2", "<div id=\"2\">foo</div>"
328
+ end
329
+ response.should have_tag("div")
330
+ response.should have_tag("div") { |elements|
331
+ elements.size.should == 2
332
+ with_tag("#1")
333
+ with_tag("#2")
334
+ }
335
+
336
+ lambda {
337
+ response.should have_tag("div") { |elements|
338
+ with_tag("#3")
339
+ }
340
+ }.should raise_error(SpecFailed)
341
+ end
342
+ end
343
+
344
+ describe "css_select", :behaviour_type => :controller do
345
+ include AssertSelectSpecHelpers
346
+ controller_name :assert_select
347
+ integrate_views
348
+
349
+ it "can select tags from html" do
350
+ render_html %Q{<div id="1"></div><div id="2"></div>}
351
+ css_select("div").size.should == 2
352
+ css_select("p").size.should == 0
353
+ end
354
+
355
+
356
+ it "can select nested tags from html" do
357
+ render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
358
+ response.should have_tag("div#?", /\d+/) { |elements|
359
+ css_select(elements[0], "div").should have(1).element
360
+ css_select(elements[1], "div").should have(1).element
361
+ }
362
+ response.should have_tag("div") {
363
+ css_select("div").should have(2).elements
364
+ css_select("div").each { |element|
365
+ # Testing as a group is one thing
366
+ css_select("#1,#2").should have(2).elements
367
+ # Testing individually is another
368
+ css_select("#1").should have(1).element
369
+ css_select("#2").should have(1).element
370
+ }
371
+ }
372
+ end
373
+
374
+ it "can select nested tags from rjs (one result)" do
375
+ render_rjs do |page|
376
+ page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
377
+ end
378
+ css_select("div").should have(2).elements
379
+ css_select("#1").should have(1).element
380
+ css_select("#2").should have(1).element
381
+ end
382
+
383
+ it "can select nested tags from rjs (two results)" do
384
+ render_rjs do |page|
385
+ page.replace_html "test", "<div id=\"1\">foo</div>"
386
+ page.replace_html "test2", "<div id=\"2\">foo</div>"
387
+ end
388
+ css_select("div").should have(2).elements
389
+ css_select("#1").should have(1).element
390
+ css_select("#2").should have(1).element
391
+ end
392
+
393
+ end
394
+
395
+ describe "have_rjs behaviour", :behaviour_type => :controller do
396
+ include AssertSelectSpecHelpers
397
+ controller_name :assert_select
398
+ integrate_views
399
+
400
+ before(:each) do
401
+ render_rjs do |page|
402
+ page.replace "test1", "<div id=\"1\">foo</div>"
403
+ page.replace_html "test2", "<div id=\"2\">bar</div><div id=\"3\">none</div>"
404
+ page.insert_html :top, "test3", "<div id=\"4\">loopy</div>"
405
+ page.hide "test4"
406
+ page["test5"].hide
407
+ end
408
+ end
409
+
410
+ it "should pass if any rjs exists" do
411
+ response.should have_rjs
412
+ end
413
+
414
+ it "should fail if no rjs exists" do
415
+ render_rjs do |page|
416
+ end
417
+ lambda do
418
+ response.should have_rjs
419
+ end.should raise_error(SpecFailed)
420
+ end
421
+
422
+ it "should find all rjs from multiple statements" do
423
+ response.should have_rjs do
424
+ with_tag("#1")
425
+ with_tag("#2")
426
+ with_tag("#3")
427
+ # with_tag("#4")
428
+ # with_tag("#5")
429
+ end
430
+ end
431
+
432
+ it "should find by id" do
433
+ response.should have_rjs("test1") { |rjs|
434
+ rjs.size.should == 1
435
+ with_tag("div", 1)
436
+ with_tag("div#1", "foo")
437
+ }
438
+
439
+ lambda do
440
+ response.should have_rjs("test1") { |rjs|
441
+ rjs.size.should == 1
442
+ without_tag("div#1", "foo")
443
+ }
444
+ end.should raise_error(SpecFailed, "should not have tag(\"div#1\", \"foo\"), but did")
445
+
446
+ response.should have_rjs("test2") { |rjs|
447
+ rjs.size.should == 2
448
+ with_tag("div", 2)
449
+ with_tag("div#2", "bar")
450
+ with_tag("div#3", "none")
451
+ }
452
+ # response.should have_rjs("test4")
453
+ # response.should have_rjs("test5")
454
+ end
455
+
456
+ # specify "should find rjs using :hide" do
457
+ # response.should have_rjs(:hide)
458
+ # response.should have_rjs(:hide, "test4")
459
+ # response.should have_rjs(:hide, "test5")
460
+ # lambda do
461
+ # response.should have_rjs(:hide, "test3")
462
+ # end.should raise_error(SpecFailed)
463
+ # end
464
+
465
+ it "should find rjs using :replace" do
466
+ response.should have_rjs(:replace) { |rjs|
467
+ with_tag("div", 1)
468
+ with_tag("div#1", "foo")
469
+ }
470
+ response.should have_rjs(:replace, "test1") { |rjs|
471
+ with_tag("div", 1)
472
+ with_tag("div#1", "foo")
473
+ }
474
+ lambda {
475
+ response.should have_rjs(:replace, "test2")
476
+ }.should raise_error(SpecFailed)
477
+
478
+ lambda {
479
+ response.should have_rjs(:replace, "test3")
480
+ }.should raise_error(SpecFailed)
481
+ end
482
+
483
+ it "should find rjs using :replace_html" do
484
+ response.should have_rjs(:replace_html) { |rjs|
485
+ with_tag("div", 2)
486
+ with_tag("div#2", "bar")
487
+ with_tag("div#3", "none")
488
+ }
489
+
490
+ response.should have_rjs(:replace_html, "test2") { |rjs|
491
+ with_tag("div", 2)
492
+ with_tag("div#2", "bar")
493
+ with_tag("div#3", "none")
494
+ }
495
+
496
+ lambda {
497
+ response.should have_rjs(:replace_html, "test1")
498
+ }.should raise_error(SpecFailed)
499
+
500
+ lambda {
501
+ response.should have_rjs(:replace_html, "test3")
502
+ }.should raise_error(SpecFailed)
503
+ end
504
+
505
+ it "should find rjs using :insert_html (non-positioned)" do
506
+ response.should have_rjs(:insert_html) { |rjs|
507
+ with_tag("div", 1)
508
+ with_tag("div#4", "loopy")
509
+ }
510
+
511
+ response.should have_rjs(:insert_html, "test3") { |rjs|
512
+ with_tag("div", 1)
513
+ with_tag("div#4", "loopy")
514
+ }
515
+
516
+ lambda {
517
+ response.should have_rjs(:insert_html, "test1")
518
+ }.should raise_error(SpecFailed)
519
+
520
+ lambda {
521
+ response.should have_rjs(:insert_html, "test2")
522
+ }.should raise_error(SpecFailed)
523
+ end
524
+
525
+ it "should find rjs using :insert (positioned)" do
526
+ render_rjs do |page|
527
+ page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
528
+ page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>"
529
+ page.insert_html :before, "test3", "<div id=\"3\">none</div>"
530
+ page.insert_html :after, "test4", "<div id=\"4\">loopy</div>"
531
+ end
532
+ response.should have_rjs(:insert, :top) do
533
+ with_tag("div", 1)
534
+ with_tag("#1")
535
+ end
536
+ response.should have_rjs(:insert, :top, "test1") do
537
+ with_tag("div", 1)
538
+ with_tag("#1")
539
+ end
540
+ lambda {
541
+ response.should have_rjs(:insert, :top, "test2")
542
+ }.should raise_error(SpecFailed)
543
+ response.should have_rjs(:insert, :bottom) {|rjs|
544
+ with_tag("div", 1)
545
+ with_tag("#2")
546
+ }
547
+ response.should have_rjs(:insert, :bottom, "test2") {|rjs|
548
+ with_tag("div", 1)
549
+ with_tag("#2")
550
+ }
551
+ response.should have_rjs(:insert, :before) {|rjs|
552
+ with_tag("div", 1)
553
+ with_tag("#3")
554
+ }
555
+ response.should have_rjs(:insert, :before, "test3") {|rjs|
556
+ with_tag("div", 1)
557
+ with_tag("#3")
558
+ }
559
+ response.should have_rjs(:insert, :after) {|rjs|
560
+ with_tag("div", 1)
561
+ with_tag("#4")
562
+ }
563
+ response.should have_rjs(:insert, :after, "test4") {|rjs|
564
+ with_tag("div", 1)
565
+ with_tag("#4")
566
+ }
567
+ end
568
+ end
569
+
570
+ describe "send_email behaviour", :behaviour_type => :controller do
571
+ include AssertSelectSpecHelpers
572
+ controller_name :assert_select
573
+ integrate_views
574
+
575
+ before(:each) do
576
+ ActionMailer::Base.delivery_method = :test
577
+ ActionMailer::Base.perform_deliveries = true
578
+ ActionMailer::Base.deliveries = []
579
+ end
580
+
581
+ after(:each) do
582
+ ActionMailer::Base.deliveries.clear
583
+ end
584
+
585
+ it "should fail with nothing sent" do
586
+ response.should_not send_email
587
+ lambda {
588
+ response.should send_email{}
589
+ }.should raise_error(SpecFailed, /No e-mail in delivery list./)
590
+ end
591
+
592
+ it "should pass otherwise" do
593
+ AssertSelectMailer.deliver_test "<div><p>foo</p><p>bar</p></div>"
594
+ response.should send_email
595
+ lambda {
596
+ response.should_not send_email
597
+ }.should raise_error(SpecFailed)
598
+ response.should send_email{}
599
+ response.should send_email {
600
+ with_tag("div:root") {
601
+ with_tag("p:first-child", "foo")
602
+ with_tag("p:last-child", "bar")
603
+ }
604
+ }
605
+
606
+ lambda {
607
+ response.should_not send_email
608
+ }.should raise_error(SpecFailed, "should not send email, but did")
609
+ end
610
+
611
+ end
612
+
613
+ # describe "An rjs call to :visual_effect, a 'should have_rjs' spec with",
614
+ # :behaviour_type => :view do
615
+ #
616
+ # before do
617
+ # render 'rjs_spec/visual_effect'
618
+ # end
619
+ #
620
+ # it "should pass with the correct element name" do
621
+ # response.should have_rjs(:effect, :fade, 'mydiv')
622
+ # end
623
+ #
624
+ # it "should fail the wrong element name" do
625
+ # lambda {
626
+ # response.should have_rjs(:effect, :fade, 'wrongname')
627
+ # }.should raise_error(SpecFailed)
628
+ # end
629
+ #
630
+ # it "should fail with the correct element but the wrong command" do
631
+ # lambda {
632
+ # response.should have_rjs(:effect, :puff, 'mydiv')
633
+ # }.should raise_error(SpecFailed)
634
+ # end
635
+ #
636
+ # end
637
+ #
638
+ # describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with",
639
+ # :behaviour_type => :view do
640
+ #
641
+ # before do
642
+ # render 'rjs_spec/visual_toggle_effect'
643
+ # end
644
+ #
645
+ # it "should pass with the correct element name" do
646
+ # response.should have_rjs(:effect, :toggle_blind, 'mydiv')
647
+ # end
648
+ #
649
+ # it "should fail with the wrong element name" do
650
+ # lambda {
651
+ # response.should have_rjs(:effect, :toggle_blind, 'wrongname')
652
+ # }.should raise_error(SpecFailed)
653
+ # end
654
+ #
655
+ # it "should fail the correct element but the wrong command" do
656
+ # lambda {
657
+ # response.should have_rjs(:effect, :puff, 'mydiv')
658
+ # }.should raise_error(SpecFailed)
659
+ # end
660
+ #
661
+ # end
662
+
663
+ describe "string.should have_tag", :behaviour_type => :helper do
664
+ include AssertSelectSpecHelpers
665
+
666
+ it "should find root element" do
667
+ "<p>a paragraph</p>".should have_tag("p", "a paragraph")
668
+ end
669
+
670
+ it "should not find non-existent element" do
671
+ lambda do
672
+ "<p>a paragraph</p>".should have_tag("p", "wrong text")
673
+ end.should raise_error(SpecFailed)
674
+ end
675
+
676
+ it "should find child element" do
677
+ "<div><p>a paragraph</p></div>".should have_tag("p", "a paragraph")
678
+ end
679
+
680
+ it "should find nested element" do
681
+ "<div><p>a paragraph</p></div>".should have_tag("div") do
682
+ with_tag("p", "a paragraph")
683
+ end
684
+ end
685
+
686
+ it "should not find wrong nested element" do
687
+ lambda do
688
+ "<div><p>a paragraph</p></div>".should have_tag("div") do
689
+ with_tag("p", "wrong text")
690
+ end
691
+ end.should raise_error(SpecFailed)
692
+ end
693
+ end
694
+
695
+ describe "have_tag", :behaviour_type => :controller do
696
+ include AssertSelectSpecHelpers
697
+ controller_name :assert_select
698
+ integrate_views
699
+
700
+ it "should work exactly the same as assert_select" do
701
+ render_html %Q{
702
+ <div id="wrapper">foo
703
+ <div class="piece">
704
+ <h3>Text</h3>
705
+ </div>
706
+ <div class="piece">
707
+ <h3>Another</h3>
708
+ </div>
709
+ </div>
710
+ }
711
+
712
+ assert_select "#wrapper .piece h3", :text => "Text"
713
+ assert_select "#wrapper .piece h3", :text => "Another"
714
+
715
+ response.should have_tag("#wrapper .piece h3", :text => "Text")
716
+ response.should have_tag("#wrapper .piece h3", :text => "Another")
717
+ end
718
+ end