Skip to content
Browse files

Added rspec 1.1.4.

  • Loading branch information...
1 parent e93c3f9 commit 30a4d05f8ce39a58958749be90d4361a60f34246 @notahat committed Jun 24, 2008
Showing with 14,757 additions and 0 deletions.
  1. +4 −0 vendor/plugins/rspec-rails/.gitignore
  2. +26 −0 vendor/plugins/rspec-rails/CHANGES
  3. +31 −0 vendor/plugins/rspec-rails/MIT-LICENSE
  4. +3 −0 vendor/plugins/rspec-rails/README
  5. +9 −0 vendor/plugins/rspec-rails/Rakefile
  6. +7 −0 vendor/plugins/rspec-rails/UPGRADE
  7. +1 −0 vendor/plugins/rspec-rails/generators/rspec/CHANGES
  8. +35 −0 vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb
  9. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/all_stories.rb
  10. 0 vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt
  11. +2 −0 vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts
  12. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec
  13. +116 −0 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec_server
  14. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts
  15. +47 −0 vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb
  16. +3 −0 vendor/plugins/rspec-rails/generators/rspec/templates/stories_helper.rb
  17. +33 −0 vendor/plugins/rspec-rails/generators/rspec_controller/USAGE
  18. +49 −0 vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
  19. +25 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb
  20. +11 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb
  21. +12 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb
  22. +18 −0 vendor/plugins/rspec-rails/generators/rspec_model/USAGE
  23. +30 −0 vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb
  24. +11 −0 vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb
  25. +167 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
  26. +313 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb
  27. +25 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
  28. +11 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb
  29. +22 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb
  30. +26 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb
  31. +61 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb
  32. +22 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb
  33. +9 −0 vendor/plugins/rspec-rails/init.rb
  34. +1 −0 vendor/plugins/rspec-rails/lib/autotest/discover.rb
  35. +81 −0 vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb
  36. +52 −0 vendor/plugins/rspec-rails/lib/spec/rails.rb
  37. +46 −0 vendor/plugins/rspec-rails/lib/spec/rails/example.rb
  38. +43 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
  39. +271 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
  40. +59 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb
  41. +164 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb
  42. +14 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/model_example_group.rb
  43. +29 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/rails_example_group.rb
  44. +90 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/render_observer.rb
  45. +178 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb
  46. +12 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions.rb
  47. +14 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/base.rb
  48. +21 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb
  49. +11 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb
  50. +27 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb
  51. +30 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/active_record/base.rb
  52. +5 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/object.rb
  53. +71 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/example/configuration.rb
  54. +21 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb
  55. +30 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers.rb
  56. +130 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/assert_select.rb
  57. +57 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb
  58. +54 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb
  59. +113 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/redirect_to.rb
  60. +70 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb
  61. +117 −0 vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb
  62. +71 −0 vendor/plugins/rspec-rails/lib/spec/rails/story_adapter.rb
  63. +23 −0 vendor/plugins/rspec-rails/lib/spec/rails/version.rb
  64. +36 −0 vendor/plugins/rspec-rails/spec/rails/autotest/mappings_spec.rb
  65. +8 −0 vendor/plugins/rspec-rails/spec/rails/autotest/rails_rspec_spec.rb
  66. +60 −0 vendor/plugins/rspec-rails/spec/rails/example/assigns_hash_proxy_spec.rb
  67. +83 −0 vendor/plugins/rspec-rails/spec/rails/example/configuration_spec.rb
  68. +62 −0 vendor/plugins/rspec-rails/spec/rails/example/controller_isolation_spec.rb
  69. +206 −0 vendor/plugins/rspec-rails/spec/rails/example/controller_spec_spec.rb
  70. +112 −0 vendor/plugins/rspec-rails/spec/rails/example/example_group_factory_spec.rb
  71. +161 −0 vendor/plugins/rspec-rails/spec/rails/example/helper_spec_spec.rb
  72. +18 −0 vendor/plugins/rspec-rails/spec/rails/example/model_spec_spec.rb
  73. +16 −0 vendor/plugins/rspec-rails/spec/rails/example/shared_behaviour_spec.rb
  74. +33 −0 vendor/plugins/rspec-rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb
  75. +272 −0 vendor/plugins/rspec-rails/spec/rails/example/view_spec_spec.rb
  76. +54 −0 vendor/plugins/rspec-rails/spec/rails/extensions/action_controller_rescue_action_spec.rb
  77. +48 −0 vendor/plugins/rspec-rails/spec/rails/extensions/action_view_base_spec.rb
  78. +14 −0 vendor/plugins/rspec-rails/spec/rails/extensions/active_record_spec.rb
  79. +806 −0 vendor/plugins/rspec-rails/spec/rails/matchers/assert_select_spec.rb
  80. +37 −0 vendor/plugins/rspec-rails/spec/rails/matchers/description_generation_spec.rb
  81. +13 −0 vendor/plugins/rspec-rails/spec/rails/matchers/errors_on_spec.rb
  82. +62 −0 vendor/plugins/rspec-rails/spec/rails/matchers/have_text_spec.rb
  83. +70 −0 vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
  84. +209 −0 vendor/plugins/rspec-rails/spec/rails/matchers/redirect_to_spec.rb
  85. +169 −0 vendor/plugins/rspec-rails/spec/rails/matchers/render_spec.rb
  86. +10 −0 vendor/plugins/rspec-rails/spec/rails/mocks/ar_classes.rb
  87. +64 −0 vendor/plugins/rspec-rails/spec/rails/mocks/mock_model_spec.rb
  88. +79 −0 vendor/plugins/rspec-rails/spec/rails/mocks/stub_model_spec.rb
  89. +8 −0 vendor/plugins/rspec-rails/spec/rails/sample_modified_fixture.rb
  90. +8 −0 vendor/plugins/rspec-rails/spec/rails/sample_spec.rb
  91. +96 −0 vendor/plugins/rspec-rails/spec/rails/spec_server_spec.rb
  92. +11 −0 vendor/plugins/rspec-rails/spec/rails/spec_spec.rb
  93. +7 −0 vendor/plugins/rspec-rails/spec/rails_suite.rb
  94. +46 −0 vendor/plugins/rspec-rails/spec/spec_helper.rb
  95. +2 −0 vendor/plugins/rspec-rails/spec_resources/controllers/action_view_base_spec_controller.rb
  96. +68 −0 vendor/plugins/rspec-rails/spec_resources/controllers/controller_spec_controller.rb
  97. +59 −0 vendor/plugins/rspec-rails/spec_resources/controllers/redirect_spec_controller.rb
  98. +26 −0 vendor/plugins/rspec-rails/spec_resources/controllers/render_spec_controller.rb
  99. +58 −0 vendor/plugins/rspec-rails/spec_resources/controllers/rjs_spec_controller.rb
  100. +34 −0 vendor/plugins/rspec-rails/spec_resources/helpers/explicit_helper.rb
  101. +5 −0 vendor/plugins/rspec-rails/spec_resources/helpers/more_explicit_helper.rb
  102. +6 −0 vendor/plugins/rspec-rails/spec_resources/helpers/plugin_application_helper.rb
  103. +13 −0 vendor/plugins/rspec-rails/spec_resources/helpers/view_spec_helper.rb
  104. 0 vendor/plugins/rspec-rails/spec_resources/views/controller_spec/_partial.rhtml
  105. +1 −0 ...s/rspec-rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
  106. +1 −0 .../rspec-rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
  107. 0 ...or/plugins/rspec-rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
  108. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml
  109. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_with_template.rhtml
  110. 0 vendor/plugins/rspec-rails/spec_resources/views/render_spec/_a_partial.rhtml
  111. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.js.rjs
  112. 0 vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.rhtml
  113. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.rjs
  114. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml
  115. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/hide_div.rjs
  116. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/hide_page_element.rjs
  117. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/insert_html.rjs
  118. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace.rjs
  119. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace_html.rjs
  120. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs
  121. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/visual_effect.rjs
  122. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs
  123. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/tag_spec/no_tags.rhtml
  124. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml
  125. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml
  126. +2 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/_partial.rhtml
  127. 0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/_partial_used_twice.rhtml
  128. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml
  129. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/_partial_with_sub_partial.rhtml
  130. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/_spacer.rhtml
  131. +5 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/accessor.rhtml
  132. +2 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/entry_form.rhtml
  133. +2 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/explicit_helper.rhtml
  134. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/foo/show.rhtml
  135. +2 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/implicit_helper.rhtml
  136. +3 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/multiple_helpers.rhtml
  137. +5 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/template_with_partial.rhtml
  138. +3 −0 ...r/plugins/rspec-rails/spec_resources/views/view_spec/template_with_partial_using_collection.rhtml
  139. +1 −0 vendor/plugins/rspec-rails/spec_resources/views/view_spec/template_with_partial_with_array.rhtml
  140. +10 −0 vendor/plugins/rspec-rails/stories/all.rb
  141. +5 −0 vendor/plugins/rspec-rails/stories/helper.rb
  142. +8 −0 vendor/plugins/rspec-rails/stories/steps/people.rb
  143. +15 −0 vendor/plugins/rspec-rails/stories/transactions_should_rollback
  144. +25 −0 vendor/plugins/rspec-rails/stories/transactions_should_rollback.rb
  145. +137 −0 vendor/plugins/rspec-rails/tasks/rspec.rake
  146. +3 −0 vendor/plugins/rspec/.autotest
  147. +7 −0 vendor/plugins/rspec/.gitignore
  148. +1,103 −0 vendor/plugins/rspec/CHANGES
  149. +20 −0 vendor/plugins/rspec/MIT-LICENSE
  150. +36 −0 vendor/plugins/rspec/README
  151. +262 −0 vendor/plugins/rspec/Rakefile
  152. +1 −0 vendor/plugins/rspec/TODO
  153. +3 −0 vendor/plugins/rspec/bin/autospec
  154. +4 −0 vendor/plugins/rspec/bin/spec
  155. +8 −0 vendor/plugins/rspec/bin/spec_translator
  156. +19 −0 vendor/plugins/rspec/examples/pure/autogenerated_docstrings_example.rb
  157. +40 −0 vendor/plugins/rspec/examples/pure/before_and_after_example.rb
  158. +45 −0 vendor/plugins/rspec/examples/pure/behave_as_example.rb
  159. +54 −0 vendor/plugins/rspec/examples/pure/custom_expectation_matchers.rb
  160. +12 −0 vendor/plugins/rspec/examples/pure/custom_formatter.rb
  161. +9 −0 vendor/plugins/rspec/examples/pure/dynamic_spec.rb
  162. +19 −0 vendor/plugins/rspec/examples/pure/file_accessor.rb
  163. +38 −0 vendor/plugins/rspec/examples/pure/file_accessor_spec.rb
  164. +31 −0 vendor/plugins/rspec/examples/pure/greeter_spec.rb
  165. +14 −0 vendor/plugins/rspec/examples/pure/helper_method_example.rb
  166. +8 −0 vendor/plugins/rspec/examples/pure/io_processor.rb
  167. +21 −0 vendor/plugins/rspec/examples/pure/io_processor_spec.rb
  168. +11 −0 vendor/plugins/rspec/examples/pure/legacy_spec.rb
  169. +27 −0 vendor/plugins/rspec/examples/pure/mocking_example.rb
  170. +28 −0 vendor/plugins/rspec/examples/pure/multi_threaded_behaviour_runner.rb
  171. +36 −0 vendor/plugins/rspec/examples/pure/nested_classes_example.rb
  172. +29 −0 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
  173. +20 −0 vendor/plugins/rspec/examples/pure/pending_example.rb
  174. +27 −0 vendor/plugins/rspec/examples/pure/predicate_example.rb
  175. +1 −0 vendor/plugins/rspec/examples/pure/priority.txt
  176. +81 −0 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
  177. +38 −0 vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
  178. +3 −0 vendor/plugins/rspec/examples/pure/spec_helper.rb
  179. +36 −0 vendor/plugins/rspec/examples/pure/stack.rb
  180. +63 −0 vendor/plugins/rspec/examples/pure/stack_spec.rb
  181. +67 −0 vendor/plugins/rspec/examples/pure/stack_spec_with_nested_example_groups.rb
  182. +69 −0 vendor/plugins/rspec/examples/pure/stubbing_example.rb
  183. +13 −0 vendor/plugins/rspec/examples/stories/adder.rb
  184. +34 −0 vendor/plugins/rspec/examples/stories/addition
  185. +9 −0 vendor/plugins/rspec/examples/stories/addition.rb
  186. +65 −0 vendor/plugins/rspec/examples/stories/calculator.rb
  187. +5 −0 vendor/plugins/rspec/examples/stories/game-of-life/.loadpath
  188. +21 −0 vendor/plugins/rspec/examples/stories/game-of-life/README.txt
  189. +6 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/everything.rb
  190. +3 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/examples/examples.rb
  191. +35 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb
  192. +66 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb
  193. +21 −0 ...ins/rspec/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story
  194. +21 −0 ...s/rspec/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story
  195. +42 −0 ...c/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story
  196. +42 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story
  197. +17 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story
  198. +53 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story
  199. +52 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb
  200. +6 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/helper.rb
  201. +26 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb
  202. +5 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/steps.rb
  203. +3 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/stories.rb
  204. +22 −0 vendor/plugins/rspec/examples/stories/game-of-life/behaviour/stories/stories.txt
  205. +3 −0 vendor/plugins/rspec/examples/stories/game-of-life/life.rb
  206. +23 −0 vendor/plugins/rspec/examples/stories/game-of-life/life/game.rb
  207. +43 −0 vendor/plugins/rspec/examples/stories/game-of-life/life/grid.rb
  208. +9 −0 vendor/plugins/rspec/examples/stories/helper.rb
  209. +18 −0 vendor/plugins/rspec/examples/stories/steps/addition_steps.rb
  210. +7 −0 vendor/plugins/rspec/failing_examples/README.txt
  211. +36 −0 vendor/plugins/rspec/failing_examples/diffing_spec.rb
  212. +19 −0 vendor/plugins/rspec/failing_examples/failing_autogenerated_docstrings_example.rb
  213. +10 −0 vendor/plugins/rspec/failing_examples/failure_in_setup.rb
  214. +10 −0 vendor/plugins/rspec/failing_examples/failure_in_teardown.rb
  215. +40 −0 vendor/plugins/rspec/failing_examples/mocking_example.rb
  216. +26 −0 vendor/plugins/rspec/failing_examples/mocking_with_flexmock.rb
  217. +25 −0 vendor/plugins/rspec/failing_examples/mocking_with_mocha.rb
  218. +27 −0 vendor/plugins/rspec/failing_examples/mocking_with_rr.rb
  219. +20 −0 vendor/plugins/rspec/failing_examples/partial_mock_example.rb
  220. +29 −0 vendor/plugins/rspec/failing_examples/predicate_example.rb
  221. +47 −0 vendor/plugins/rspec/failing_examples/raising_example.rb
  222. +3 −0 vendor/plugins/rspec/failing_examples/spec_helper.rb
  223. +7 −0 vendor/plugins/rspec/failing_examples/syntax_error_example.rb
  224. +44 −0 vendor/plugins/rspec/failing_examples/team_spec.rb
  225. +7 −0 vendor/plugins/rspec/failing_examples/timeout_behaviour.rb
  226. +9 −0 vendor/plugins/rspec/init.rb
  227. +3 −0 vendor/plugins/rspec/lib/autotest/discover.rb
  228. +72 −0 vendor/plugins/rspec/lib/autotest/rspec.rb
  229. +31 −0 vendor/plugins/rspec/lib/spec.rb
  230. +1 −0 vendor/plugins/rspec/lib/spec/adapters.rb
  231. +26 −0 vendor/plugins/rspec/lib/spec/adapters/ruby_engine.rb
  232. +8 −0 vendor/plugins/rspec/lib/spec/adapters/ruby_engine/mri.rb
  233. +8 −0 vendor/plugins/rspec/lib/spec/adapters/ruby_engine/rubinius.rb
  234. +12 −0 vendor/plugins/rspec/lib/spec/example.rb
  235. +158 −0 vendor/plugins/rspec/lib/spec/example/configuration.rb
  236. +9 −0 vendor/plugins/rspec/lib/spec/example/errors.rb
  237. +17 −0 vendor/plugins/rspec/lib/spec/example/example_group.rb
  238. +64 −0 vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
  239. +440 −0 vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
  240. +44 −0 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
  241. +112 −0 vendor/plugins/rspec/lib/spec/example/example_methods.rb
  242. +37 −0 vendor/plugins/rspec/lib/spec/example/module_inclusion_warnings.rb
  243. +21 −0 vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
  244. +18 −0 vendor/plugins/rspec/lib/spec/example/pending.rb
  245. +58 −0 vendor/plugins/rspec/lib/spec/example/shared_example_group.rb
  246. +56 −0 vendor/plugins/rspec/lib/spec/expectations.rb
  247. +66 −0 vendor/plugins/rspec/lib/spec/expectations/differs/default.rb
  248. +12 −0 vendor/plugins/rspec/lib/spec/expectations/errors.rb
  249. +2 −0 vendor/plugins/rspec/lib/spec/expectations/extensions.rb
  250. +63 −0 vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
  251. +17 −0 vendor/plugins/rspec/lib/spec/expectations/extensions/string_and_symbol.rb
  252. +62 −0 vendor/plugins/rspec/lib/spec/expectations/handler.rb
  253. +4 −0 vendor/plugins/rspec/lib/spec/extensions.rb
  254. +24 −0 vendor/plugins/rspec/lib/spec/extensions/class.rb
  255. +102 −0 vendor/plugins/rspec/lib/spec/extensions/main.rb
  256. +7 −0 vendor/plugins/rspec/lib/spec/extensions/metaclass.rb
  257. +6 −0 vendor/plugins/rspec/lib/spec/extensions/object.rb
  258. +12 −0 vendor/plugins/rspec/lib/spec/interop/test.rb
  259. +6 −0 vendor/plugins/rspec/lib/spec/interop/test/unit/autorunner.rb
  260. +61 −0 vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb
  261. +6 −0 vendor/plugins/rspec/lib/spec/interop/test/unit/testresult.rb
  262. +34 −0 vendor/plugins/rspec/lib/spec/interop/test/unit/testsuite_adapter.rb
  263. +61 −0 vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
  264. +156 −0 vendor/plugins/rspec/lib/spec/matchers.rb
  265. +224 −0 vendor/plugins/rspec/lib/spec/matchers/be.rb
  266. +37 −0 vendor/plugins/rspec/lib/spec/matchers/be_close.rb
  267. +148 −0 vendor/plugins/rspec/lib/spec/matchers/change.rb
  268. +43 −0 vendor/plugins/rspec/lib/spec/matchers/eql.rb
  269. +43 −0 vendor/plugins/rspec/lib/spec/matchers/equal.rb
  270. +17 −0 vendor/plugins/rspec/lib/spec/matchers/exist.rb
  271. +34 −0 vendor/plugins/rspec/lib/spec/matchers/has.rb
  272. +149 −0 vendor/plugins/rspec/lib/spec/matchers/have.rb
  273. +70 −0 vendor/plugins/rspec/lib/spec/matchers/include.rb
  274. +41 −0 vendor/plugins/rspec/lib/spec/matchers/match.rb
  275. +73 −0 vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb
  276. +132 −0 vendor/plugins/rspec/lib/spec/matchers/raise_error.rb
  277. +45 −0 vendor/plugins/rspec/lib/spec/matchers/respond_to.rb
  278. +47 −0 vendor/plugins/rspec/lib/spec/matchers/satisfy.rb
  279. +132 −0 vendor/plugins/rspec/lib/spec/matchers/simple_matcher.rb
  280. +74 −0 vendor/plugins/rspec/lib/spec/matchers/throw_symbol.rb
  281. +211 −0 vendor/plugins/rspec/lib/spec/mocks.rb
  282. +31 −0 vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb
  283. +216 −0 vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb
  284. +84 −0 vendor/plugins/rspec/lib/spec/mocks/error_generator.rb
  285. +10 −0 vendor/plugins/rspec/lib/spec/mocks/errors.rb
  286. +1 −0 vendor/plugins/rspec/lib/spec/mocks/extensions.rb
  287. +3 −0 vendor/plugins/rspec/lib/spec/mocks/extensions/object.rb
  288. +15 −0 vendor/plugins/rspec/lib/spec/mocks/framework.rb
  289. +290 −0 vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
  290. +39 −0 vendor/plugins/rspec/lib/spec/mocks/methods.rb
  291. +56 −0 vendor/plugins/rspec/lib/spec/mocks/mock.rb
  292. +29 −0 vendor/plugins/rspec/lib/spec/mocks/order_group.rb
  293. +184 −0 vendor/plugins/rspec/lib/spec/mocks/proxy.rb
  294. +28 −0 vendor/plugins/rspec/lib/spec/mocks/space.rb
  295. +38 −0 vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
  296. +227 −0 vendor/plugins/rspec/lib/spec/rake/spectask.rb
  297. +52 −0 vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb
  298. +201 −0 vendor/plugins/rspec/lib/spec/runner.rb
  299. +57 −0 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
  300. +16 −0 vendor/plugins/rspec/lib/spec/runner/class_and_arguments_parser.rb
Sorry, we could not display the entire diff because too many files (545) changed.
View
4 vendor/plugins/rspec-rails/.gitignore
@@ -0,0 +1,4 @@
+tmtags
+.DS_Store
+.emacs-project
+*~
View
26 vendor/plugins/rspec-rails/CHANGES
@@ -0,0 +1,26 @@
+== Version 1.1.5
+
+* Add conditional so Rails 2.1.0 doesn't warn about cache_template_extensions (patch from James Herdman)
+* Fixed stub_model examples to work with Rails 2.1.0 (the code was fine, just the spec needed patching)
+
+== Version 1.1.4
+
+Maintenance release.
+
+* Moved mock_model and stub_model to their own module: Spec::Rails::Mocks
+* Setting mock_model object id with stubs hash - patch from Adam Meehan
+* Added as_new_record to stub_model e.g. stub_model(Foo).as_new_record
+* Improved stub_model such that new_record? does "the right thing"
+* Patch from Pat Maddox to get integrate_views to work in nested example groups.
+* Patch from Pat Maddox to get controller_name to work in nested example groups.
+* Patch from Corey Haines to add include_text matcher
+* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited.
+* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320.
+* Added #helper and #assigns to helper specs.
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
+* Tweaked list of exceptions (ignores) for autotest
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
+* Allow any type of render in view specs. Closes #57.
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+* Applied patch from Jon Strother to have spec_server reload fixtures. Closes #344.
View
31 vendor/plugins/rspec-rails/MIT-LICENSE
@@ -0,0 +1,31 @@
+====================================================================
+== RSpec
+Copyright (c) 2005-2007 The RSpec Development Team
+====================================================================
+== ARTS
+Copyright (c) 2006 Kevin Clark, Jake Howerton
+====================================================================
+== ZenTest
+Copyright (c) 2001-2006 Ryan Davis, Eric Hodel, Zen Spider Software
+====================================================================
+== AssertSelect
+Copyright (c) 2006 Assaf Arkin
+====================================================================
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
3 vendor/plugins/rspec-rails/README
@@ -0,0 +1,3 @@
+See the rdoc for Spec::Rails for usage documentation.
+
+See ~/rspec/README for instructions on running rspec_on_rails' examples.
View
9 vendor/plugins/rspec-rails/Rakefile
@@ -0,0 +1,9 @@
+require 'rake'
+require 'rake/rdoctask'
+
+desc 'Generate RDoc'
+rd = Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = '../doc/output/rdoc-rails'
+ rdoc.options << '--title' << 'Spec::Rails' << '--line-numbers' << '--inline-source' << '--main' << 'Spec::Rails'
+ rdoc.rdoc_files.include('MIT-LICENSE', 'lib/**/*.rb')
+end
View
7 vendor/plugins/rspec-rails/UPGRADE
@@ -0,0 +1,7 @@
+== Upgrade
+
+ script/generate rspec
+
+Or modify spec_helper.rb based on the template, which can be found at:
+
+ vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb
View
1 vendor/plugins/rspec-rails/generators/rspec/CHANGES
@@ -0,0 +1 @@
+Please refer to the CHANGES file for RSpec's core
View
35 vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb
@@ -0,0 +1,35 @@
+require 'rbconfig'
+
+# This generator bootstraps a Rails project for use with RSpec
+class RspecGenerator < Rails::Generator::Base
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
+ Config::CONFIG['ruby_install_name'])
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ end
+
+ def manifest
+ record do |m|
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
+
+ m.directory 'spec'
+ m.template 'spec_helper.rb', 'spec/spec_helper.rb'
+ m.file 'spec.opts', 'spec/spec.opts'
+ m.file 'rcov.opts', 'spec/rcov.opts'
+ m.file 'script/spec_server', 'script/spec_server', script_options
+ m.file 'script/spec', 'script/spec', script_options
+
+ m.directory 'stories'
+ m.file 'all_stories.rb', 'stories/all.rb'
+ m.file 'stories_helper.rb', 'stories/helper.rb'
+ end
+ end
+
+protected
+
+ def banner
+ "Usage: #{$0} rspec"
+ end
+
+end
View
4 vendor/plugins/rspec-rails/generators/rspec/templates/all_stories.rb
@@ -0,0 +1,4 @@
+dir = File.dirname(__FILE__)
+Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
+ require file
+end
View
0 vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt
No changes.
View
2 vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts
@@ -0,0 +1,2 @@
+--exclude "spec/*,gems/*"
+--rails
View
4 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
+require 'spec'
+exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
View
116 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec_server
@@ -0,0 +1,116 @@
+#!/usr/bin/env ruby
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
+require 'rubygems'
+require 'drb/drb'
+require 'rbconfig'
+require 'spec'
+require 'optparse'
+
+# This is based on Florian Weber's TDDMate
+module Spec
+ module Runner
+ class RailsSpecServer
+ def run(argv, stderr, stdout)
+ $stdout = stdout
+ $stderr = stderr
+
+ base = ActiveRecord::Base
+ def base.clear_reloadable_connections!
+ active_connections.each do |name, conn|
+ if conn.requires_reloading?
+ conn.disconnect!
+ active_connections.delete(name)
+ end
+ end
+ end
+
+ if ActionController.const_defined?(:Dispatcher)
+ dispatcher = ::ActionController::Dispatcher.new($stdout)
+ dispatcher.cleanup_application
+ elsif ::Dispatcher.respond_to?(:reset_application!)
+ ::Dispatcher.reset_application!
+ else
+ raise "Application reloading failed"
+ end
+ if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
+ Fixtures.reset_cache
+ end
+
+ ::Dependencies.mechanism = :load
+ require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
+ load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
+
+ if in_memory_database?
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
+ ActiveRecord::Migrator.up('db/migrate') # use migrations
+ end
+
+ ::Spec::Runner::CommandLine.run(
+ ::Spec::Runner::OptionParser.parse(
+ argv,
+ $stderr,
+ $stdout
+ )
+ )
+ end
+
+ def in_memory_database?
+ ENV["RAILS_ENV"] == "test" and
+ ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
+ ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
+ end
+ end
+ end
+end
+puts "Loading Rails environment"
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'dispatcher'
+
+def restart_test_server
+ puts "restarting"
+ config = ::Config::CONFIG
+ ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
+ command_line = [ruby, $0, ARGV].flatten.join(' ')
+ exec(command_line)
+end
+
+def daemonize(pid_file = nil)
+ return yield if $DEBUG
+ pid = Process.fork{
+ Process.setsid
+ Dir.chdir(RAILS_ROOT)
+ trap("SIGINT"){ exit! 0 }
+ trap("SIGTERM"){ exit! 0 }
+ trap("SIGHUP"){ restart_test_server }
+ File.open("/dev/null"){|f|
+ STDERR.reopen f
+ STDIN.reopen f
+ STDOUT.reopen f
+ }
+ yield
+ }
+ puts "spec_server launched. (PID: %d)" % pid
+ File.open(pid_file,"w"){|f| f.puts pid } if pid_file
+ exit! 0
+end
+
+options = Hash.new
+opts = OptionParser.new
+opts.on("-d", "--daemon"){|v| options[:daemon] = true }
+opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v }
+opts.parse!(ARGV)
+
+puts "Ready"
+exec_server = lambda {
+ trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
+ DRb.start_service("druby://127.0.0.1:8989", Spec::Runner::RailsSpecServer.new)
+ DRb.thread.join
+}
+
+if options[:daemon]
+ daemonize(options[:pid], &exec_server)
+else
+ exec_server.call
+end
View
4 vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts
@@ -0,0 +1,4 @@
+--colour
+--format progress
+--loadby mtime
+--reverse
View
47 vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb
@@ -0,0 +1,47 @@
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'spec'
+require 'spec/rails'
+
+Spec::Runner.configure do |config|
+ # If you're not using ActiveRecord you should remove these
+ # lines, delete config/database.yml and disable :active_record
+ # in your config/boot.rb
+ config.use_transactional_fixtures = true
+ config.use_instantiated_fixtures = false
+ config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+
+ # == Fixtures
+ #
+ # You can declare fixtures for each example_group like this:
+ # describe "...." do
+ # fixtures :table_a, :table_b
+ #
+ # Alternatively, if you prefer to declare them only once, you can
+ # do so right here. Just uncomment the next line and replace the fixture
+ # names with your fixtures.
+ #
+ # config.global_fixtures = :table_a, :table_b
+ #
+ # If you declare global fixtures, be aware that they will be declared
+ # for all of your examples, even those that don't use them.
+ #
+ # You can also declare which fixtures to use (for example fixtures for test/fixtures):
+ #
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+ #
+ # == Mock Framework
+ #
+ # RSpec uses it's own mocking framework by default. If you prefer to
+ # use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ #
+ # == Notes
+ #
+ # For more information take a look at Spec::Example::Configuration and Spec::Runner
+end
View
3 vendor/plugins/rspec-rails/generators/rspec/templates/stories_helper.rb
@@ -0,0 +1,3 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'spec/rails/story_adapter'
View
33 vendor/plugins/rspec-rails/generators/rspec_controller/USAGE
@@ -0,0 +1,33 @@
+Description:
+ The rspec_controller generator creates stub specs and files for a new
+ controller and its views.
+
+ The generator takes a controller name and a list of views as arguments.
+ The controller name may be given in CamelCase or under_score and should
+ not be suffixed with 'Controller'. To create a controller within a
+ module, specify the controller name as 'module/controller'.
+
+ The generator creates stubs for a controller (and spec), a view (and spec)
+ for each view in the argument list, plus a helper.
+
+Example:
+ ./script/generate rspec_controller dog bark fetch
+ ...
+ create spec/controllers/dog_controller_spec.rb
+ create app/controllers/dog_controller.rb
+ create app/helpers/dog_helper.rb
+ create spec/views/dog/bark_view_spec.rb
+ create app/views/dog/bark.rhtml
+ create spec/views/dog/fetch_view_spec.rb
+ create app/views/dog/fetch.rhtml
+
+Modules Example:
+ ./script/generate rspec_controller 'pets/dog' bark fetch
+ ...
+ create spec/controllers/pets/dog_controller_spec.rb
+ create app/controllers/pets/dog_controller.rb
+ create app/helpers/pets/dog_helper.rb
+ create spec/views/pets/dog/bark_view_spec.rb
+ create app/views/pets/dog/bark.rhtml
+ create spec/views/pets/dog/fetch_view_spec.rb
+ create app/views/pets/dog/fetch.rhtml
View
49 vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
@@ -0,0 +1,49 @@
+require 'rails_generator/generators/components/controller/controller_generator'
+
+class RspecControllerGenerator < ControllerGenerator
+
+ def manifest
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
+
+ # Controller, helper, views, and spec directories.
+ m.directory File.join('app/controllers', class_path)
+ m.directory File.join('app/helpers', class_path)
+ m.directory File.join('app/views', class_path, file_name)
+ m.directory File.join('spec/controllers', class_path)
+ m.directory File.join('spec/helpers', class_path)
+ m.directory File.join('spec/views', class_path, file_name)
+
+ if Rails::VERSION::STRING < "2.0.0"
+ @default_file_extension = "rhtml"
+ else
+ @default_file_extension = "html.erb"
+ end
+
+ # Controller spec, class, and helper.
+ m.template 'controller_spec.rb',
+ File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
+
+ m.template 'helper_spec.rb',
+ File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
+
+ m.template 'controller:controller.rb',
+ File.join('app/controllers', class_path, "#{file_name}_controller.rb")
+
+ m.template 'controller:helper.rb',
+ File.join('app/helpers', class_path, "#{file_name}_helper.rb")
+
+ # Spec and view template for each action.
+ actions.each do |action|
+ m.template 'view_spec.rb',
+ File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
+ :assigns => { :action => action, :model => file_name }
+ path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}")
+ m.template "controller:view.#{@default_file_extension}",
+ path,
+ :assigns => { :action => action, :path => path }
+ end
+ end
+ end
+end
View
25 vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= class_name %>Controller do
+
+<% if actions.empty? -%>
+ #Delete this example and add some real ones
+<% else -%>
+ #Delete these examples and add some real ones
+<% end -%>
+ it "should use <%= class_name %>Controller" do
+ controller.should be_an_instance_of(<%= class_name %>Controller)
+ end
+
+<% unless actions.empty? -%>
+<% for action in actions -%>
+
+ describe "GET '<%= action %>'" do
+ it "should be successful" do
+ get '<%= action %>'
+ response.should be_success
+ end
+ end
+<% end -%>
+<% end -%>
+end
View
11 vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= class_name %>Helper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(<%= class_name %>Helper)
+ end
+
+end
View
12 vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+describe "/<%= class_name.underscore %>/<%= action %>" do
+ before(:each) do
+ render '<%= class_name.underscore %>/<%= action %>'
+ end
+
+ #Delete this example and add some real ones or delete this file
+ it "should tell you where to find the file" do
+ response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
+ end
+end
View
18 vendor/plugins/rspec-rails/generators/rspec_model/USAGE
@@ -0,0 +1,18 @@
+Description:
+ The rspec_model generator creates stubs for a new model.
+
+ The generator takes a model name as its argument. The model name may be
+ given in CamelCase or under_score and should not be suffixed with 'Model'.
+
+ The generator creates a model class in app/models, an RSpec spec in
+ spec/models, database fixtures in spec/fixtures/plural_name.yml, and a migration
+ in db/migrate.
+
+Example:
+ ./script/generate rspec_model Account
+
+ This will create an Account model:
+ Model: app/models/account.rb
+ Spec: spec/models/account_spec.rb
+ Fixtures: spec/fixtures/accounts.yml
+ Migration: db/migrate/XXX_add_accounts.rb
View
30 vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb
@@ -0,0 +1,30 @@
+require 'rails_generator/generators/components/model/model_generator'
+
+class RspecModelGenerator < ModelGenerator
+
+ def manifest
+
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions class_path, class_name
+
+ # Model, spec, and fixture directories.
+ m.directory File.join('app/models', class_path)
+ m.directory File.join('spec/models', class_path)
+ m.directory File.join('spec/fixtures', class_path)
+
+ # Model class, spec and fixtures.
+ m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
+ m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml")
+ m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
+
+ unless options[:skip_migration]
+ m.migration_template 'model:migration.rb', 'db/migrate', :assigns => {
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
+ }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
+ end
+
+ end
+ end
+
+end
View
11 vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= class_name %> do
+ before(:each) do
+ @<%= file_name %> = <%= class_name %>.new
+ end
+
+ it "should be valid" do
+ @<%= file_name %>.should be_valid
+ end
+end
View
167 vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
@@ -0,0 +1,167 @@
+class RspecScaffoldGenerator < Rails::Generator::NamedBase
+ default_options :skip_migration => false
+
+ attr_reader :controller_name,
+ :controller_class_path,
+ :controller_file_path,
+ :controller_class_nesting,
+ :controller_class_nesting_depth,
+ :controller_class_name,
+ :controller_singular_name,
+ :controller_plural_name,
+ :resource_edit_path,
+ :default_file_extension
+ alias_method :controller_file_name, :controller_singular_name
+ alias_method :controller_table_name, :controller_plural_name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+
+ @controller_name = @name.pluralize
+
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
+ @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
+
+ if @controller_class_nesting.empty?
+ @controller_class_name = @controller_class_name_without_nesting
+ else
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
+ end
+
+ if Rails::VERSION::STRING < "2.0.0"
+ @resource_generator = "scaffold_resource"
+ @default_file_extension = "rhtml"
+ else
+ @resource_generator = "scaffold"
+ @default_file_extension = "html.erb"
+ end
+
+ if ActionController::Base.respond_to?(:resource_action_separator)
+ @resource_edit_path = "/edit"
+ else
+ @resource_edit_path = ";edit"
+ end
+ end
+
+ def manifest
+ record do |m|
+
+ # Check for class naming collisions.
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
+ m.class_collisions(class_path, "#{class_name}")
+
+ # Controller, helper, views, and spec directories.
+ m.directory(File.join('app/models', class_path))
+ m.directory(File.join('app/controllers', controller_class_path))
+ m.directory(File.join('app/helpers', controller_class_path))
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
+ m.directory(File.join('spec/controllers', controller_class_path))
+ m.directory(File.join('spec/models', class_path))
+ m.directory(File.join('spec/helpers', class_path))
+ m.directory File.join('spec/fixtures', class_path)
+ m.directory File.join('spec/views', controller_class_path, controller_file_name)
+
+ # Controller spec, class, and helper.
+ m.template 'rspec_scaffold:routing_spec.rb',
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_routing_spec.rb")
+
+ m.template 'rspec_scaffold:controller_spec.rb',
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
+
+ m.template "#{@resource_generator}:controller.rb",
+ File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
+
+ m.template 'rspec_scaffold:helper_spec.rb',
+ File.join('spec/helpers', class_path, "#{controller_file_name}_helper_spec.rb")
+
+ m.template "#{@resource_generator}:helper.rb",
+ File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")
+
+ for action in scaffold_views
+ m.template(
+ "#{@resource_generator}:view_#{action}.#{@default_file_extension}",
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.#{default_file_extension}")
+ )
+ end
+
+ # Model class, unit test, and fixtures.
+ m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
+ m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml")
+ m.template 'rspec_model:model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
+
+ # View specs
+ m.template "rspec_scaffold:edit_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "edit.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:index_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "index.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:new_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "new.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:show_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "show.#{default_file_extension}_spec.rb")
+
+ unless options[:skip_migration]
+ m.migration_template(
+ 'model:migration.rb', 'db/migrate',
+ :assigns => {
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
+ :attributes => attributes
+ },
+ :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
+ )
+ end
+
+ m.route_resources controller_file_name
+
+ end
+ end
+
+ protected
+ # Override with your own usage banner.
+ def banner
+ "Usage: #{$0} rspec_scaffold ModelName [field:type field:type]"
+ end
+
+ def add_options!(opt)
+ opt.separator ''
+ opt.separator 'Options:'
+ opt.on("--skip-migration",
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
+ end
+
+ def scaffold_views
+ %w[ index show new edit ]
+ end
+
+ def model_name
+ class_name.demodulize
+ end
+end
+
+module Rails
+ module Generator
+ class GeneratedAttribute
+ def default_value
+ @default_value ||= case type
+ when :int, :integer then "\"1\""
+ when :float then "\"1.5\""
+ when :decimal then "\"9.99\""
+ when :datetime, :timestamp, :time then "Time.now"
+ when :date then "Date.today"
+ when :string then "\"MyString\""
+ when :text then "\"MyText\""
+ when :boolean then "false"
+ else
+ ""
+ end
+ end
+
+ def input_type
+ @input_type ||= case type
+ when :text then "textarea"
+ else
+ "input"
+ end
+ end
+ end
+ end
+end
View
313 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb
@@ -0,0 +1,313 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= controller_class_name %>Controller do
+ describe "handling GET /<%= table_name %>" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+ <%= class_name %>.stub!(:find).and_return([@<%= file_name %>])
+ end
+
+ def do_get
+ get :index
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should render index template" do
+ do_get
+ response.should render_template('index')
+ end
+
+ it "should find all <%= table_name %>" do
+ <%= class_name %>.should_receive(:find).with(:all).and_return([@<%= file_name %>])
+ do_get
+ end
+
+ it "should assign the found <%= table_name %> for the view" do
+ do_get
+ assigns[:<%= table_name %>].should == [@<%= file_name %>]
+ end
+ end
+
+ describe "handling GET /<%= table_name %>.xml" do
+
+ before(:each) do
+ @<%= file_name.pluralize %> = mock("Array of <%= class_name.pluralize %>", :to_xml => "XML")
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name.pluralize %>)
+ end
+
+ def do_get
+ @request.env["HTTP_ACCEPT"] = "application/xml"
+ get :index
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should find all <%= table_name %>" do
+ <%= class_name %>.should_receive(:find).with(:all).and_return(@<%= file_name.pluralize %>)
+ do_get
+ end
+
+ it "should render the found <%= table_name %> as xml" do
+ @<%= file_name.pluralize %>.should_receive(:to_xml).and_return("XML")
+ do_get
+ response.body.should == "XML"
+ end
+ end
+
+ describe "handling GET /<%= table_name %>/1" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ end
+
+ def do_get
+ get :show, :id => "1"
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should render show template" do
+ do_get
+ response.should render_template('show')
+ end
+
+ it "should find the <%= file_name %> requested" do
+ <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
+ do_get
+ end
+
+ it "should assign the found <%= file_name %> for the view" do
+ do_get
+ assigns[:<%= file_name %>].should equal(@<%= file_name %>)
+ end
+ end
+
+ describe "handling GET /<%= table_name %>/1.xml" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>, :to_xml => "XML")
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ end
+
+ def do_get
+ @request.env["HTTP_ACCEPT"] = "application/xml"
+ get :show, :id => "1"
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should find the <%= file_name %> requested" do
+ <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
+ do_get
+ end
+
+ it "should render the found <%= file_name %> as xml" do
+ @<%= file_name %>.should_receive(:to_xml).and_return("XML")
+ do_get
+ response.body.should == "XML"
+ end
+ end
+
+ describe "handling GET /<%= table_name %>/new" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+ <%= class_name %>.stub!(:new).and_return(@<%= file_name %>)
+ end
+
+ def do_get
+ get :new
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should render new template" do
+ do_get
+ response.should render_template('new')
+ end
+
+ it "should create an new <%= file_name %>" do
+ <%= class_name %>.should_receive(:new).and_return(@<%= file_name %>)
+ do_get
+ end
+
+ it "should not save the new <%= file_name %>" do
+ @<%= file_name %>.should_not_receive(:save)
+ do_get
+ end
+
+ it "should assign the new <%= file_name %> for the view" do
+ do_get
+ assigns[:<%= file_name %>].should equal(@<%= file_name %>)
+ end
+ end
+
+ describe "handling GET /<%= table_name %>/1/edit" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ end
+
+ def do_get
+ get :edit, :id => "1"
+ end
+
+ it "should be successful" do
+ do_get
+ response.should be_success
+ end
+
+ it "should render edit template" do
+ do_get
+ response.should render_template('edit')
+ end
+
+ it "should find the <%= file_name %> requested" do
+ <%= class_name %>.should_receive(:find).and_return(@<%= file_name %>)
+ do_get
+ end
+
+ it "should assign the found <%= class_name %> for the view" do
+ do_get
+ assigns[:<%= file_name %>].should equal(@<%= file_name %>)
+ end
+ end
+
+ describe "handling POST /<%= table_name %>" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>, :to_param => "1")
+ <%= class_name %>.stub!(:new).and_return(@<%= file_name %>)
+ end
+
+ describe "with successful save" do
+
+ def do_post
+ @<%= file_name %>.should_receive(:save).and_return(true)
+ post :create, :<%= file_name %> => {}
+ end
+
+ it "should create a new <%= file_name %>" do
+ <%= class_name %>.should_receive(:new).with({}).and_return(@<%= file_name %>)
+ do_post
+ end
+
+ it "should redirect to the new <%= file_name %>" do
+ do_post
+ response.should redirect_to(<%= table_name.singularize %>_url("1"))
+ end
+
+ end
+
+ describe "with failed save" do
+
+ def do_post
+ @<%= file_name %>.should_receive(:save).and_return(false)
+ post :create, :<%= file_name %> => {}
+ end
+
+ it "should re-render 'new'" do
+ do_post
+ response.should render_template('new')
+ end
+
+ end
+ end
+
+ describe "handling PUT /<%= table_name %>/1" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>, :to_param => "1")
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ end
+
+ describe "with successful update" do
+
+ def do_put
+ @<%= file_name %>.should_receive(:update_attributes).and_return(true)
+ put :update, :id => "1"
+ end
+
+ it "should find the <%= file_name %> requested" do
+ <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
+ do_put
+ end
+
+ it "should update the found <%= file_name %>" do
+ do_put
+ assigns(:<%= file_name %>).should equal(@<%= file_name %>)
+ end
+
+ it "should assign the found <%= file_name %> for the view" do
+ do_put
+ assigns(:<%= file_name %>).should equal(@<%= file_name %>)
+ end
+
+ it "should redirect to the <%= file_name %>" do
+ do_put
+ response.should redirect_to(<%= table_name.singularize %>_url("1"))
+ end
+
+ end
+
+ describe "with failed update" do
+
+ def do_put
+ @<%= file_name %>.should_receive(:update_attributes).and_return(false)
+ put :update, :id => "1"
+ end
+
+ it "should re-render 'edit'" do
+ do_put
+ response.should render_template('edit')
+ end
+
+ end
+ end
+
+ describe "handling DELETE /<%= table_name %>/1" do
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>, :destroy => true)
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ end
+
+ def do_delete
+ delete :destroy, :id => "1"
+ end
+
+ it "should find the <%= file_name %> requested" do
+ <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
+ do_delete
+ end
+
+ it "should call destroy on the found <%= file_name %>" do
+ @<%= file_name %>.should_receive(:destroy)
+ do_delete
+ end
+
+ it "should redirect to the <%= table_name %> list" do
+ do_delete
+ response.should redirect_to(<%= table_name %>_url)
+ end
+ end
+end
View
25 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
+ include <%= controller_class_name %>Helper
+
+ before do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+<% for attribute in attributes -%>
+ @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+<% end -%>
+ assigns[:<%= file_name %>] = @<%= file_name %>
+ end
+
+ it "should render edit form" do
+ render "/<%= table_name %>/edit.<%= default_file_extension %>"
+
+ response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
+<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+ with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
+<% end -%><% end -%>
+ end
+ end
+end
+
+
View
11 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= controller_class_name %>Helper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(<%= controller_class_name %>Helper)
+ end
+
+end
View
22 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+describe "/<%= table_name %>/index.<%= default_file_extension %>" do
+ include <%= controller_class_name %>Helper
+
+ before(:each) do
+<% [98,99].each do |id| -%>
+ <%= file_name %>_<%= id %> = mock_model(<%= class_name %>)
+<% for attribute in attributes -%>
+ <%= file_name %>_<%= id %>.should_receive(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+<% end -%><% end %>
+ assigns[:<%= table_name %>] = [<%= file_name %>_98, <%= file_name %>_99]
+ end
+
+ it "should render list of <%= table_name %>" do
+ render "/<%= table_name %>/index.<%= default_file_extension %>"
+<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+ response.should have_tag("tr>td", <%= attribute.default_value %>, 2)
+<% end -%><% end -%>
+ end
+end
+
View
26 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+describe "/<%= table_name %>/new.<%= default_file_extension %>" do
+ include <%= controller_class_name %>Helper
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+ @<%= file_name %>.stub!(:new_record?).and_return(true)
+<% for attribute in attributes -%>
+ @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+<% end -%>
+ assigns[:<%= file_name %>] = @<%= file_name %>
+ end
+
+ it "should render new form" do
+ render "/<%= table_name %>/new.<%= default_file_extension %>"
+
+ response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
+<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+ with_tag("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
+<% end -%><% end -%>
+ end
+ end
+end
+
+
View
61 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb
@@ -0,0 +1,61 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+
+describe <%= controller_class_name %>Controller do
+ describe "route generation" do
+
+ it "should map { :controller => '<%= table_name %>', :action => 'index' } to /<%= table_name %>" do
+ route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
+ end
+
+ it "should map { :controller => '<%= table_name %>', :action => 'new' } to /<%= table_name %>/new" do
+ route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
+ end
+
+ it "should map { :controller => '<%= table_name %>', :action => 'show', :id => 1 } to /<%= table_name %>/1" do
+ route_for(:controller => "<%= table_name %>", :action => "show", :id => 1).should == "/<%= table_name %>/1"
+ end
+
+ it "should map { :controller => '<%= table_name %>', :action => 'edit', :id => 1 } to /<%= table_name %>/1<%= resource_edit_path %>" do
+ route_for(:controller => "<%= table_name %>", :action => "edit", :id => 1).should == "/<%= table_name %>/1<%= resource_edit_path %>"
+ end
+
+ it "should map { :controller => '<%= table_name %>', :action => 'update', :id => 1} to /<%= table_name %>/1" do
+ route_for(:controller => "<%= table_name %>", :action => "update", :id => 1).should == "/<%= table_name %>/1"
+ end
+
+ it "should map { :controller => '<%= table_name %>', :action => 'destroy', :id => 1} to /<%= table_name %>/1" do
+ route_for(:controller => "<%= table_name %>", :action => "destroy", :id => 1).should == "/<%= table_name %>/1"
+ end
+ end
+
+ describe "route recognition" do
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'index' } from GET /<%= table_name %>" do
+ params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'new' } from GET /<%= table_name %>/new" do
+ params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'create' } from POST /<%= table_name %>" do
+ params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'show', id => '1' } from GET /<%= table_name %>/1" do
+ params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'edit', id => '1' } from GET /<%= table_name %>/1;edit" do
+ params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'update', id => '1' } from PUT /<%= table_name %>/1" do
+ params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
+ end
+
+ it "should generate params { :controller => '<%= table_name %>', action => 'destroy', id => '1' } from DELETE /<%= table_name %>/1" do
+ params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
+ end
+ end
+end
View
22 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+describe "/<%= table_name %>/show.<%= default_file_extension %>" do
+ include <%= controller_class_name %>Helper
+
+ before(:each) do
+ @<%= file_name %> = mock_model(<%= class_name %>)
+<% for attribute in attributes -%>
+ @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+<% end -%>
+
+ assigns[:<%= file_name %>] = @<%= file_name %>
+ end
+
+ it "should render attributes in <p>" do
+ render "/<%= table_name %>/show.<%= default_file_extension %>"
+<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+ response.should have_text(/<%= Regexp.escape(attribute.default_value)[1..-2]%>/)
+<% end -%><% end -%>
+ end
+end
+
View
9 vendor/plugins/rspec-rails/init.rb
@@ -0,0 +1,9 @@
+# Placeholder to satisfy Rails.
+#
+# Do NOT add any require statements to this file. Doing
+# so will cause Rails to load this plugin all of the time.
+#
+# Running 'ruby script/generate rspec' will
+# generate spec/spec_helper.rb, which includes the necessary
+# require statements and configuration. This file should
+# be required by all of your spec files.
View
1 vendor/plugins/rspec-rails/lib/autotest/discover.rb
@@ -0,0 +1 @@
+# This needs to be here for >= ZenTest-3.9.0 to add this directory to the load path.
View
81 vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb
@@ -0,0 +1,81 @@
+# (c) Copyright 2006 Nick Sieger <nicksieger@gmail.com>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+$:.push(*Dir["vendor/rails/*/lib"])
+
+require 'active_support'
+require 'autotest/rspec'
+
+Autotest.add_hook :initialize do |at|
+ %w{config/ coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
+ at.add_exception(exception)
+ end
+
+ at.clear_mappings
+
+ at.add_mapping(%r%^(test|spec)/fixtures/(.*).yml$%) { |_, m|
+ ["spec/models/#{m[2].singularize}_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
+ }
+ at.add_mapping(%r%^spec/(models|controllers|views|helpers|lib)/.*rb$%) { |filename, _|
+ filename
+ }
+ at.add_mapping(%r%^app/models/(.*)\.rb$%) { |_, m|
+ ["spec/models/#{m[1]}_spec.rb"]
+ }
+ at.add_mapping(%r%^app/views/(.*)$%) { |_, m|
+ at.files_matching %r%^spec/views/#{m[1]}_spec.rb$%
+ }
+ at.add_mapping(%r%^app/controllers/(.*)\.rb$%) { |_, m|
+ if m[1] == "application"
+ at.files_matching %r%^spec/controllers/.*_spec\.rb$%
+ else
+ ["spec/controllers/#{m[1]}_spec.rb"]
+ end
+ }
+ at.add_mapping(%r%^app/helpers/(.*)_helper\.rb$%) { |_, m|
+ if m[1] == "application" then
+ at.files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
+ else
+ ["spec/helpers/#{m[1]}_helper_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
+ end
+ }
+ at.add_mapping(%r%^config/routes\.rb$%) {
+ at.files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
+ }
+ at.add_mapping(%r%^config/database\.yml$%) { |_, m|
+ at.files_matching %r%^spec/models/.*_spec\.rb$%
+ }
+ at.add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) {
+ at.files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$%
+ }
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
+ ["spec/lib/#{m[1]}_spec.rb"]
+ }
+end
+
+class Autotest::RailsRspec < Autotest::Rspec
+
+ def spec_command
+ "script/spec"
+ end
+
+end
View
52 vendor/plugins/rspec-rails/lib/spec/rails.rb
@@ -0,0 +1,52 @@
+silence_warnings { RAILS_ENV = "test" }
+
+require 'application'
+require 'action_controller/test_process'
+require 'action_controller/integration'
+require 'active_record/fixtures' if defined?(ActiveRecord::Base)
+require 'test/unit'
+
+require 'spec'
+
+require 'spec/rails/matchers'
+require 'spec/rails/mocks'
+require 'spec/rails/example'
+require 'spec/rails/extensions'
+require 'spec/rails/version'
+
+module Spec
+ # = Spec::Rails
+ #
+ # Spec::Rails (a.k.a. RSpec on Rails) is a Ruby on Rails plugin that allows you to drive the development
+ # of your RoR application using RSpec, a framework that aims to enable Example Driven Development
+ # in Ruby.
+ #
+ # == Features
+ #
+ # * Use RSpec to independently specify Rails Models, Views, Controllers and Helpers
+ # * Integrated fixture loading
+ # * Special generators for Resources, Models, Views and Controllers that generate Specs instead of Tests.
+ #
+ # == Vision
+ #
+ # For people for whom TDD is a brand new concept, the testing support built into Ruby on Rails
+ # is a huge leap forward. The fact that it is built right in is fantastic, and Ruby on Rails
+ # apps are generally much easier to maintain than they might have been without such support.
+ #
+ # For those of us coming from a history with TDD, and now BDD, the existing support presents some problems related to dependencies across specs. To that end, RSpec on Rails supports 4 types of specs. We’ve also built in first class mocking and stubbing support in order to break dependencies across these different concerns.
+ #
+ # == More Information
+ #
+ # See Spec::Rails::Runner for information about the different kinds of contexts
+ # you can use to spec the different Rails components
+ #
+ # See Spec::Rails::Expectations for information about Rails-specific expectations
+ # you can set on responses and models, etc.
+ #
+ # == License
+ #
+ # RSpec on Rails is licensed under the same license as RSpec itself,
+ # the MIT-LICENSE.
+ module Rails
+ end
+end
View
46 vendor/plugins/rspec-rails/lib/spec/rails/example.rb
@@ -0,0 +1,46 @@
+dir = File.dirname(__FILE__)
+
+require 'spec/rails/example/assigns_hash_proxy'
+
+require "spec/rails/example/render_observer"
+require "spec/rails/example/rails_example_group"
+require "spec/rails/example/model_example_group"
+require "spec/rails/example/functional_example_group"
+require "spec/rails/example/controller_example_group"
+require "spec/rails/example/helper_example_group"
+require "spec/rails/example/view_example_group"
+
+module Spec
+ module Rails
+ # Spec::Rails::Example extends Spec::Example (RSpec's core Example module) to provide
+ # Rails-specific contexts for describing Rails Models, Views, Controllers and Helpers.
+ #
+ # == Model Examples
+ #
+ # These are the equivalent of unit tests in Rails' built in testing. Ironically (for the traditional TDD'er) these are the only specs that we feel should actually interact with the database.
+ #
+ # See Spec::Rails::Example::ModelExampleGroup
+ #
+ # == Controller Examples
+ #
+ # These align somewhat with functional tests in rails, except that they do not actually render views (though you can force rendering of views if you prefer). Instead of setting expectations about what goes on a page, you set expectations about what templates get rendered.
+ #
+ # See Spec::Rails::Example::ControllerExampleGroup
+ #
+ # == View Examples
+ #
+ # This is the other half of Rails functional testing. View specs allow you to set up assigns and render
+ # a template. By assigning mock model data, you can specify view behaviour with no dependency on a database
+ # or your real models.
+ #
+ # See Spec::Rails::Example::ViewExampleGroup
+ #
+ # == Helper Examples
+ #
+ # These let you specify directly methods that live in your helpers.
+ #
+ # See Spec::Rails::Example::HelperExampleGroup
+ module Example
+ end
+ end
+end
View
43 vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
@@ -0,0 +1,43 @@
+module Spec
+ module Rails
+ module Example
+ class AssignsHashProxy #:nodoc:
+ def initialize(object)
+ @object = object
+ end
+
+ def [](ivar)
+ if assigns.include?(ivar.to_s)
+ assigns[ivar.to_s]
+ elsif assigns.include?(ivar)
+ assigns[ivar]
+ else
+ nil
+ end
+ end
+
+ def []=(ivar, val)
+ @object.instance_variable_set "@#{ivar}", val
+ assigns[ivar.to_s] = val
+ end
+
+ def delete(name)
+ assigns.delete(name.to_s)
+ end
+
+ def each(&block)
+ assigns.each &block
+ end
+
+ def has_key?(key)
+ assigns.key?(key.to_s)
+ end
+
+ protected
+ def assigns
+ @object.assigns
+ end
+ end
+ end
+ end
+end
View
271 vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
@@ -0,0 +1,271 @@
+module Spec
+ module Rails
+ module Example
+ # Controller Examples live in $RAILS_ROOT/spec/controllers/.
+ #
+ # Controller Examples use Spec::Rails::Example::ControllerExampleGroup, which supports running specs for
+ # Controllers in two modes, which represent the tension between the more granular
+ # testing common in TDD and the more high level testing built into
+ # rails. BDD sits somewhere in between: we want to a balance between
+ # specs that are close enough to the code to enable quick fault
+ # isolation and far enough away from the code to enable refactoring
+ # with minimal changes to the existing specs.
+ #
+ # == Isolation mode (default)
+ #
+ # No dependencies on views because none are ever rendered. The
+ # benefit of this mode is that can spec the controller completely
+ # independent of the view, allowing that responsibility to be
+ # handled later, or by somebody else. Combined w/ separate view
+ # specs, this also provides better fault isolation.
+ #
+ # == Integration mode
+ #
+ # To run in this mode, include the +integrate_views+ declaration
+ # in your controller context:
+ #
+ # describe ThingController do
+ # integrate_views
+ # ...
+ #
+ # In this mode, controller specs are run in the same way that
+ # rails functional tests run - one set of tests for both the
+ # controllers and the views. The benefit of this approach is that
+ # you get wider coverage from each spec. Experienced rails
+ # developers may find this an easier approach to begin with, however
+ # we encourage you to explore using the isolation mode and revel
+ # in its benefits.
+ #
+ # == Expecting Errors
+ #
+ # Rspec on Rails will raise errors that occur in controller actions.
+ # In contrast, Rails will swallow errors that are raised in controller
+ # actions and return an error code in the header. If you wish to override
+ # Rspec and have Rail's default behaviour,tell the controller to use
+ # rails error handling ...
+ #
+ # before(:each) do
+ # controller.use_rails_error_handling!
+ # end
+ #
+ # When using Rail's error handling, you can expect error codes in headers ...
+ #
+ # it "should return an error in the header" do
+ # response.should be_error
+ # end
+ #
+ # it "should return a 501" do
+ # response.response_code.should == 501
+ # end
+ #
+ # it "should return a 501" do
+ # response.code.should == "501"
+ # end
+ class ControllerExampleGroup < FunctionalExampleGroup
+ class << self
+
+ # Use this to instruct RSpec to render views in your controller examples (Integration Mode).
+ #
+ # describe ThingController do
+ # integrate_views
+ # ...
+ #
+ # See Spec::Rails::Example::ControllerExampleGroup for more information about
+ # Integration and Isolation modes.
+ def integrate_views(integrate_views = true)
+ @integrate_views = integrate_views
+ end
+
+ def integrate_views? # :nodoc:
+ @integrate_views
+ end
+
+ def inherited(klass) # :nodoc:
+ klass.controller_class_name = controller_class_name
+ klass.integrate_views(integrate_views?)
+ super
+ end
+
+ # You MUST provide a controller_name within the context of
+ # your controller specs:
+ #
+ # describe "ThingController" do
+ # controller_name :thing
+ # ...
+ def controller_name(name)
+ @controller_class_name = "#{name}_controller".camelize
+ end
+ attr_accessor :controller_class_name # :nodoc:
+ end
+
+ before(:each) do
+ # Some Rails apps explicitly disable ActionMailer in environment.rb
+ if defined?(ActionMailer)
+ @deliveries = []
+ ActionMailer::Base.deliveries = @deliveries
+ end
+
+ unless @controller.class.ancestors.include?(ActionController::Base)
+ Spec::Expectations.fail_with <<-EOE
+ You have to declare the controller name in controller specs. For example:
+ describe "The ExampleController" do
+ controller_name "example" #invokes the ExampleController
+ end
+ EOE
+ end
+ (class << @controller; self; end).class_eval do
+ def controller_path #:nodoc:
+ self.class.name.underscore.gsub('_controller', '')
+ end
+ include ControllerInstanceMethods
+ end
+ @controller.integrate_views! if @integrate_views
+ @controller.session = session
+ end
+
+ attr_reader :response, :request, :controller
+
+ def initialize(defined_description, &implementation) #:nodoc:
+ super
+ controller_class_name = self.class.controller_class_name
+ if controller_class_name
+ @controller_class_name = controller_class_name.to_s
+ else
+ @controller_class_name = self.class.described_type.to_s
+ end
+ @integrate_views = self.class.integrate_views?
+ end
+
+ # Uses ActionController::Routing::Routes to generate
+ # the correct route for a given set of options.
+ # == Example
+ # route_for(:controller => 'registrations', :action => 'edit', :id => 1)
+ # => '/registrations/1;edit'
+ def route_for(options)