spree 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree might be problematic. Click here for more details.

Files changed (211) hide show
  1. data/History.txt +5 -0
  2. data/Manifest.txt +158 -21
  3. data/config/hoe.rb +2 -1
  4. data/lib/spree/version.rb +1 -1
  5. data/starter-app/app/views/layouts/application.rhtml +6 -4
  6. data/starter-app/db/sample/line_items.yml +6 -4
  7. data/starter-app/db/sample/{variations.yml → variants.yml} +16 -0
  8. data/starter-app/log/README +1 -0
  9. data/starter-app/public/images/spree.jpg +0 -0
  10. data/starter-app/public/stylesheets/application.css +2 -2
  11. data/starter-app/script/spec +4 -0
  12. data/starter-app/script/spec_server +102 -0
  13. data/starter-app/spec/models/cart_item_spec.rb +50 -0
  14. data/starter-app/spec/models/cart_spec.rb +51 -0
  15. data/starter-app/spec/models/line_item_spec.rb +33 -0
  16. data/starter-app/spec/models/product_spec.rb +29 -0
  17. data/starter-app/spec/rcov.opts +2 -0
  18. data/starter-app/spec/spec.opts +6 -0
  19. data/starter-app/spec/spec_helper.rb +39 -0
  20. data/starter-app/stories/all.rb +4 -0
  21. data/starter-app/stories/helper.rb +3 -0
  22. data/starter-app/vendor/plugins/rspec_on_rails/MIT-LICENSE +31 -0
  23. data/starter-app/vendor/plugins/rspec_on_rails/README +3 -0
  24. data/starter-app/vendor/plugins/rspec_on_rails/Rakefile +9 -0
  25. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES +1 -0
  26. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb +35 -0
  27. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb +4 -0
  28. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt +0 -0
  29. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts +2 -0
  30. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec +4 -0
  31. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server +102 -0
  32. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts +6 -0
  33. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb +39 -0
  34. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb +3 -0
  35. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE +33 -0
  36. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb +49 -0
  37. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb +25 -0
  38. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb +11 -0
  39. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb +12 -0
  40. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE +18 -0
  41. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb +30 -0
  42. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb +11 -0
  43. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +167 -0
  44. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb +313 -0
  45. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +25 -0
  46. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb +11 -0
  47. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb +22 -0
  48. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb +26 -0
  49. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb +61 -0
  50. data/starter-app/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb +22 -0
  51. data/starter-app/vendor/plugins/rspec_on_rails/init.rb +9 -0
  52. data/starter-app/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb +1 -0
  53. data/starter-app/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb +81 -0
  54. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails.rb +51 -0
  55. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb +47 -0
  56. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb +42 -0
  57. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb +255 -0
  58. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb +66 -0
  59. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb +82 -0
  60. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/ivar_proxy.rb +62 -0
  61. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/model_example_group.rb +14 -0
  62. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb +68 -0
  63. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb +90 -0
  64. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb +171 -0
  65. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb +12 -0
  66. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/base.rb +14 -0
  67. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb +21 -0
  68. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb +11 -0
  69. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/base.rb +27 -0
  70. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/base.rb +30 -0
  71. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/object.rb +5 -0
  72. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb +66 -0
  73. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/matchers/have.rb +21 -0
  74. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb +29 -0
  75. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/assert_select.rb +130 -0
  76. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb +55 -0
  77. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb +113 -0
  78. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb +70 -0
  79. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/story_adapter.rb +71 -0
  80. data/starter-app/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb +23 -0
  81. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb +36 -0
  82. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/autotest/rails_rspec_spec.rb +8 -0
  83. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb +55 -0
  84. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb +83 -0
  85. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb +43 -0
  86. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb +187 -0
  87. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb +112 -0
  88. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb +118 -0
  89. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/ivar_proxy_spec.rb +64 -0
  90. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb +18 -0
  91. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb +16 -0
  92. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb +33 -0
  93. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb +263 -0
  94. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb +54 -0
  95. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb +48 -0
  96. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb +14 -0
  97. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb +783 -0
  98. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb +37 -0
  99. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb +13 -0
  100. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb +62 -0
  101. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb +203 -0
  102. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb +169 -0
  103. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb +65 -0
  104. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb +7 -0
  105. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb +89 -0
  106. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails/spec_spec.rb +11 -0
  107. data/starter-app/vendor/plugins/rspec_on_rails/spec/rails_suite.rb +7 -0
  108. data/starter-app/vendor/plugins/rspec_on_rails/spec/spec_helper.rb +46 -0
  109. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/controllers/action_view_base_spec_controller.rb +2 -0
  110. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb +56 -0
  111. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/controllers/redirect_spec_controller.rb +59 -0
  112. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb +26 -0
  113. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/controllers/rjs_spec_controller.rb +58 -0
  114. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/helpers/explicit_helper.rb +10 -0
  115. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/helpers/more_explicit_helper.rb +5 -0
  116. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/helpers/plugin_application_helper.rb +6 -0
  117. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/helpers/view_spec_helper.rb +13 -0
  118. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_partial.rhtml +0 -0
  119. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml +1 -0
  120. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml +1 -0
  121. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml +0 -0
  122. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml +1 -0
  123. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_template.rhtml +1 -0
  124. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml +0 -0
  125. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.js.rjs +1 -0
  126. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml +0 -0
  127. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rjs +1 -0
  128. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml +1 -0
  129. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_div.rjs +1 -0
  130. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_page_element.rjs +1 -0
  131. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/insert_html.rjs +1 -0
  132. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace.rjs +1 -0
  133. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html.rjs +1 -0
  134. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs +1 -0
  135. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_effect.rjs +1 -0
  136. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs +1 -0
  137. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/no_tags.rhtml +1 -0
  138. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml +1 -0
  139. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml +1 -0
  140. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial.rhtml +2 -0
  141. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_used_twice.rhtml +0 -0
  142. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml +1 -0
  143. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_sub_partial.rhtml +1 -0
  144. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_spacer.rhtml +1 -0
  145. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml +3 -0
  146. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/entry_form.rhtml +2 -0
  147. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/explicit_helper.rhtml +2 -0
  148. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/foo/show.rhtml +1 -0
  149. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/implicit_helper.rhtml +2 -0
  150. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/multiple_helpers.rhtml +3 -0
  151. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial.rhtml +5 -0
  152. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_using_collection.rhtml +3 -0
  153. data/starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_with_array.rhtml +1 -0
  154. data/starter-app/vendor/plugins/rspec_on_rails/stories/all.rb +10 -0
  155. data/starter-app/vendor/plugins/rspec_on_rails/stories/helper.rb +5 -0
  156. data/starter-app/vendor/plugins/rspec_on_rails/stories/steps/people.rb +8 -0
  157. data/starter-app/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback +15 -0
  158. data/starter-app/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback.rb +25 -0
  159. data/starter-app/vendor/plugins/rspec_on_rails/tasks/rspec.rake +137 -0
  160. data/starter-app/vendor/plugins/spree/LICENSE +1 -1
  161. data/starter-app/vendor/plugins/spree/app/controllers/admin/categories_controller.rb +0 -24
  162. data/starter-app/vendor/plugins/spree/app/controllers/admin/products_controller.rb +16 -16
  163. data/starter-app/vendor/plugins/spree/app/controllers/cart_controller.rb +2 -8
  164. data/starter-app/vendor/plugins/spree/app/helpers/admin/products_helper.rb +1 -1
  165. data/starter-app/vendor/plugins/spree/app/helpers/spree/base_helper.rb +2 -2
  166. data/starter-app/vendor/plugins/spree/app/models/cart.rb +7 -20
  167. data/starter-app/vendor/plugins/spree/app/models/cart_item.rb +3 -6
  168. data/starter-app/vendor/plugins/spree/app/models/category.rb +6 -22
  169. data/starter-app/vendor/plugins/spree/app/models/line_item.rb +3 -5
  170. data/starter-app/vendor/plugins/spree/app/models/option_value.rb +1 -1
  171. data/starter-app/vendor/plugins/spree/app/models/product.rb +18 -2
  172. data/starter-app/vendor/plugins/spree/app/models/variant.rb +5 -0
  173. data/starter-app/vendor/plugins/spree/app/views/admin/categories/_form.rhtml +1 -5
  174. data/starter-app/vendor/plugins/spree/app/views/admin/overview/index.rhtml +3 -0
  175. data/starter-app/vendor/plugins/spree/app/views/admin/products/_form.rhtml +2 -2
  176. data/starter-app/vendor/plugins/spree/app/views/admin/products/{_new_variation.rhtml → _new_variant.rhtml} +1 -1
  177. data/starter-app/vendor/plugins/spree/app/views/admin/products/_variants.rhtml +43 -0
  178. data/starter-app/vendor/plugins/spree/app/views/cart/index.rhtml +4 -4
  179. data/starter-app/vendor/plugins/spree/app/views/layouts/admin.rhtml +1 -1
  180. data/starter-app/vendor/plugins/spree/app/views/order_mailer/cancel.rhtml +1 -1
  181. data/starter-app/vendor/plugins/spree/app/views/order_mailer/confirm.rhtml +1 -1
  182. data/starter-app/vendor/plugins/spree/app/views/shared/_order_details.rhtml +1 -1
  183. data/starter-app/vendor/plugins/spree/app/views/store/show.rhtml +30 -29
  184. data/starter-app/vendor/plugins/spree/assets/images/spree/spree.jpg +0 -0
  185. data/starter-app/vendor/plugins/spree/assets/stylesheets/spree-admin.css +1 -1
  186. data/starter-app/vendor/plugins/spree/assets/stylesheets/store/_controller.css +1 -1
  187. data/starter-app/vendor/plugins/spree/db/migrate/002_create_cart_items.rb +1 -2
  188. data/starter-app/vendor/plugins/spree/db/migrate/006_create_line_items.rb +5 -7
  189. data/starter-app/vendor/plugins/spree/db/migrate/011_create_variants.rb +11 -0
  190. data/starter-app/vendor/plugins/spree/db/migrate/018_create_option_values_variants.rb +12 -0
  191. data/starter-app/vendor/plugins/spree/test/unit/product_test.rb +0 -33
  192. metadata +170 -23
  193. data/starter-app/vendor/plugins/spree/app/controllers/admin/variations_controller.rb +0 -73
  194. data/starter-app/vendor/plugins/spree/app/helpers/admin/variations_helper.rb +0 -2
  195. data/starter-app/vendor/plugins/spree/app/models/variation.rb +0 -8
  196. data/starter-app/vendor/plugins/spree/app/views/admin/option_types/test.rhtml +0 -8
  197. data/starter-app/vendor/plugins/spree/app/views/admin/products/_variations.rhtml +0 -41
  198. data/starter-app/vendor/plugins/spree/app/views/admin/variations/_form.rhtml +0 -33
  199. data/starter-app/vendor/plugins/spree/app/views/admin/variations/_option_values.rhtml +0 -5
  200. data/starter-app/vendor/plugins/spree/app/views/admin/variations/list.rhtml +0 -23
  201. data/starter-app/vendor/plugins/spree/app/views/admin/variations/new.rhtml +0 -14
  202. data/starter-app/vendor/plugins/spree/assets/images/spree/spree_logo142x65.gif +0 -0
  203. data/starter-app/vendor/plugins/spree/assets/images/spree/spree_logo245x112.gif +0 -0
  204. data/starter-app/vendor/plugins/spree/db/migrate/011_create_variations.rb +0 -11
  205. data/starter-app/vendor/plugins/spree/db/migrate/018_create_option_values_variations.rb +0 -12
  206. data/starter-app/vendor/plugins/spree/test/functional/admin/variations_controller_test.rb +0 -18
  207. data/starter-app/vendor/plugins/spree/test/integration/variations_test.rb +0 -24
  208. data/starter-app/vendor/plugins/spree/test/unit/cart_item_test.rb +0 -55
  209. data/starter-app/vendor/plugins/spree/test/unit/cart_test.rb +0 -35
  210. data/starter-app/vendor/plugins/spree/test/unit/line_item_test.rb +0 -61
  211. data/starter-app/vendor/plugins/spree/test/unit/variation_test.rb +0 -9
@@ -0,0 +1,70 @@
1
+ module Spec
2
+ module Rails
3
+ module Matchers
4
+
5
+ class RenderTemplate #:nodoc:
6
+
7
+ def initialize(expected, controller)
8
+ @controller = controller
9
+ @expected = expected
10
+ end
11
+
12
+ def matches?(response)
13
+ @actual = response.rendered_file
14
+ full_path(@actual) == full_path(@expected)
15
+ end
16
+
17
+ def failure_message
18
+ "expected #{@expected.inspect}, got #{@actual.inspect}"
19
+ end
20
+
21
+ def negative_failure_message
22
+ "expected not to render #{@expected.inspect}, but did"
23
+ end
24
+
25
+ def description
26
+ "render template #{@expected.inspect}"
27
+ end
28
+
29
+ private
30
+ def full_path(path)
31
+ return nil if path.nil?
32
+ path.include?('/') ? path : "#{@controller.class.to_s.underscore.gsub('_controller','')}/#{path}"
33
+ end
34
+
35
+ end
36
+
37
+ # :call-seq:
38
+ # response.should render_template(path)
39
+ # response.should_not render_template(path)
40
+ #
41
+ # Passes if the specified template is rendered by the response.
42
+ # Useful in controller specs (integration or isolation mode).
43
+ #
44
+ # <code>path</code> can include the controller path or not. It
45
+ # can also include an optional extension (no extension assumes .rhtml).
46
+ #
47
+ # Note that partials must be spelled with the preceding underscore.
48
+ #
49
+ # == Examples
50
+ #
51
+ # response.should render_template('list')
52
+ # response.should render_template('same_controller/list')
53
+ # response.should render_template('other_controller/list')
54
+ #
55
+ # #rjs
56
+ # response.should render_template('list.rjs')
57
+ # response.should render_template('same_controller/list.rjs')
58
+ # response.should render_template('other_controller/list.rjs')
59
+ #
60
+ # #partials
61
+ # response.should render_template('_a_partial')
62
+ # response.should render_template('same_controller/_a_partial')
63
+ # response.should render_template('other_controller/_a_partial')
64
+ def render_template(path)
65
+ RenderTemplate.new(path.to_s, @controller)
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,71 @@
1
+ # WARNING - THIS IS PURELY EXPERIMENTAL AT THIS POINT
2
+ # Courtesy of Brian Takita and Yurii Rashkovskii
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec lib])
5
+ if defined?(ActiveRecord::Base)
6
+ require 'test_help'
7
+ else
8
+ require 'action_controller/test_process'
9
+ require 'action_controller/integration'
10
+ end
11
+ require 'test/unit/testresult'
12
+ require 'spec'
13
+ require 'spec/rails'
14
+
15
+ Test::Unit.run = true
16
+
17
+ ActionController::Integration::Session.send(:include, Spec::Matchers)
18
+ ActionController::Integration::Session.send(:include, Spec::Rails::Matchers)
19
+
20
+ class RailsStory < ActionController::IntegrationTest
21
+ if defined?(ActiveRecord::Base)
22
+ self.use_transactional_fixtures = true
23
+ else
24
+ def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
25
+ end
26
+
27
+ def initialize #:nodoc:
28
+ # TODO - eliminate this hack, which is here to stop
29
+ # Rails Stories from dumping the example summary.
30
+ Spec::Runner::Options.class_eval do
31
+ def examples_should_be_run?
32
+ false
33
+ end
34
+ end
35
+ @_result = Test::Unit::TestResult.new
36
+ end
37
+ end
38
+
39
+ class ActiveRecordSafetyListener
40
+ include Singleton
41
+ def scenario_started(*args)
42
+ if defined?(ActiveRecord::Base)
43
+ ActiveRecord::Base.send :increment_open_transactions unless Rails::VERSION::STRING == "1.1.6"
44
+ ActiveRecord::Base.connection.begin_db_transaction
45
+ end
46
+ end
47
+
48
+ def scenario_succeeded(*args)
49
+ if defined?(ActiveRecord::Base)
50
+ ActiveRecord::Base.connection.rollback_db_transaction
51
+ ActiveRecord::Base.send :decrement_open_transactions unless Rails::VERSION::STRING == "1.1.6"
52
+ end
53
+ end
54
+ alias :scenario_pending :scenario_succeeded
55
+ alias :scenario_failed :scenario_succeeded
56
+ end
57
+
58
+ class Spec::Story::Runner::ScenarioRunner
59
+ def initialize
60
+ @listeners = [ActiveRecordSafetyListener.instance]
61
+ end
62
+ end
63
+
64
+ class Spec::Story::GivenScenario
65
+ def perform(instance, name = nil)
66
+ scenario = Spec::Story::Runner::StoryRunner.scenario_from_current_story @name
67
+ runner = Spec::Story::Runner::ScenarioRunner.new
68
+ runner.instance_variable_set(:@listeners,[])
69
+ runner.run(scenario, instance)
70
+ end
71
+ end
@@ -0,0 +1,23 @@
1
+ module Spec
2
+ module Rails
3
+ module VERSION #:nodoc:
4
+ BUILD_TIME_UTC = 20080131122909
5
+ end
6
+ end
7
+ end
8
+
9
+ # Verify that the plugin has the same revision as RSpec
10
+ if Spec::Rails::VERSION::BUILD_TIME_UTC != Spec::VERSION::BUILD_TIME_UTC
11
+ raise <<-EOF
12
+
13
+ ############################################################################
14
+ Your RSpec on Rails plugin is incompatible with your installed RSpec.
15
+
16
+ RSpec : #{Spec::VERSION::BUILD_TIME_UTC}
17
+ RSpec on Rails : #{Spec::Rails::VERSION::BUILD_TIME_UTC}
18
+
19
+ Make sure your RSpec on Rails plugin is compatible with your RSpec gem.
20
+ See http://rspec.rubyforge.org/documentation/rails/install.html for details.
21
+ ############################################################################
22
+ EOF
23
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.join(File.dirname(__FILE__), *%w[.. .. .. lib autotest rails_rspec])
3
+ require File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec spec autotest_matchers])
4
+
5
+ describe Autotest::RailsRspec, "file mapping" do
6
+ before(:each) do
7
+ @autotest = Autotest::RailsRspec.new
8
+ @autotest.hook :initialize
9
+ end
10
+
11
+ it "should map model example to model" do
12
+ @autotest.should map_specs(['spec/models/thing_spec.rb']).
13
+ to('app/models/thing.rb')
14
+ end
15
+
16
+ it "should map controller example to controller" do
17
+ @autotest.should map_specs(['spec/controllers/things_controller_spec.rb']).
18
+ to('app/controllers/things_controller.rb')
19
+ end
20
+
21
+ it "should map view.rhtml" do
22
+ @autotest.should map_specs(['spec/views/things/index.rhtml_spec.rb']).
23
+ to('app/views/things/index.rhtml')
24
+ end
25
+
26
+ it "should map view.rhtml with underscores in example filename" do
27
+ @autotest.should map_specs(['spec/views/things/index_rhtml_spec.rb']).
28
+ to('app/views/things/index.rhtml')
29
+ end
30
+
31
+ it "should map view.html.erb" do
32
+ @autotest.should map_specs(['spec/views/things/index.html.erb_spec.rb']).
33
+ to('app/views/things/index.html.erb')
34
+ end
35
+
36
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "autotest", "rails_rspec")
3
+
4
+ describe Autotest::RailsRspec do
5
+ it "should provide the correct spec_command" do
6
+ Autotest::RailsRspec.new.spec_command.should == "script/spec"
7
+ end
8
+ end
@@ -0,0 +1,55 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "An AssignsHashProxy" do
4
+ before(:each) do
5
+ @object = Object.new
6
+ @assigns = Hash.new
7
+ @object.stub!(:assigns).and_return(@assigns)
8
+ @proxy = Spec::Rails::Example::AssignsHashProxy.new(@object)
9
+ end
10
+
11
+ it "has [] accessor" do
12
+ @proxy['foo'] = 'bar'
13
+ @assigns['foo'].should == 'bar'
14
+ @proxy['foo'].should == 'bar'
15
+ end
16
+
17
+ it "works for symbol key" do
18
+ @assigns[:foo] = 2
19
+ @proxy[:foo].should == 2
20
+ end
21
+
22
+ it "checks for string key before symbol key" do
23
+ @assigns['foo'] = false
24
+ @assigns[:foo] = 2
25
+ @proxy[:foo].should == false
26
+ end
27
+
28
+ it "each method iterates through each element like a Hash" do
29
+ values = {
30
+ 'foo' => 1,
31
+ 'bar' => 2,
32
+ 'baz' => 3
33
+ }
34
+ @proxy['foo'] = values['foo']
35
+ @proxy['bar'] = values['bar']
36
+ @proxy['baz'] = values['baz']
37
+
38
+ @proxy.each do |key, value|
39
+ key.should == key
40
+ value.should == values[key]
41
+ end
42
+ end
43
+
44
+ it "delete method deletes the element of passed in key" do
45
+ @proxy['foo'] = 'bar'
46
+ @proxy.delete('foo').should == 'bar'
47
+ @proxy['foo'].should be_nil
48
+ end
49
+
50
+ it "has_key? detects the presence of a key" do
51
+ @proxy['foo'] = 'bar'
52
+ @proxy.has_key?('foo').should == true
53
+ @proxy.has_key?('bar').should == false
54
+ end
55
+ end
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Spec
4
+ module Example
5
+ describe Configuration, :shared => true do
6
+ before(:each) { @config = Configuration.new }
7
+ end
8
+
9
+ describe Configuration, "#use_transactional_fixtures" do
10
+ it_should_behave_like "Spec::Example::Configuration"
11
+
12
+ it "should return Test::Unit::TestCase.use_transactional_fixtures" do
13
+ @config.use_transactional_fixtures.should == Test::Unit::TestCase.use_transactional_fixtures
14
+ end
15
+
16
+ it "should set Test::Unit::TestCase.use_transactional_fixtures to false" do
17
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
18
+ example_group.should_receive(:use_transactional_fixtures=).with(false)
19
+ end
20
+ @config.use_transactional_fixtures = false
21
+ end
22
+
23
+ it "should set Test::Unit::TestCase.use_transactional_fixtures to true" do
24
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
25
+ example_group.should_receive(:use_transactional_fixtures=).with(true)
26
+ end
27
+ @config.use_transactional_fixtures = true
28
+ end
29
+ end
30
+
31
+ describe Configuration, "#use_instantiated_fixtures" do
32
+ it_should_behave_like "Spec::Example::Configuration"
33
+
34
+ it "should return Test::Unit::TestCase.use_transactional_fixtures" do
35
+ @config.use_instantiated_fixtures.should == Test::Unit::TestCase.use_instantiated_fixtures
36
+ end
37
+
38
+ it "should set Test::Unit::TestCase.use_instantiated_fixtures to false" do
39
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
40
+ example_group.should_receive(:use_instantiated_fixtures=).with(false)
41
+ end
42
+ @config.use_instantiated_fixtures = false
43
+ end
44
+
45
+ it "should set Test::Unit::TestCase.use_instantiated_fixtures to true" do
46
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
47
+ example_group.should_receive(:use_instantiated_fixtures=).with(true)
48
+ end
49
+ @config.use_instantiated_fixtures = true
50
+ end
51
+ end
52
+
53
+ describe Configuration, "#fixture_path" do
54
+ it_should_behave_like "Spec::Example::Configuration"
55
+
56
+ it "should default to RAILS_ROOT + '/spec/fixtures'" do
57
+ @config.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
58
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
59
+ example_group.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
60
+ end
61
+ end
62
+
63
+ it "should set fixture_path" do
64
+ @config.fixture_path = "/new/path"
65
+ @config.fixture_path.should == "/new/path"
66
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
67
+ example_group.fixture_path.should == "/new/path"
68
+ end
69
+ end
70
+ end
71
+
72
+ describe Configuration, "#global_fixtures" do
73
+ it_should_behave_like "Spec::Example::Configuration"
74
+
75
+ it "should set fixtures on TestCase" do
76
+ Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
77
+ example_group.should_receive(:fixtures).with(:blah)
78
+ end
79
+ @config.global_fixtures = [:blah]
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'controller_spec_controller'
3
+
4
+ describe "a controller spec running in isolation mode", :type => :controller do
5
+ controller_name :controller_spec
6
+
7
+ it "should not care if the template doesn't exist" do
8
+ get 'some_action'
9
+ response.should be_success
10
+ response.should render_template("template/that/does/not/actually/exist")
11
+ end
12
+
13
+ it "should not care if the template has errors" do
14
+ get 'action_with_errors_in_template'
15
+ response.should be_success
16
+ response.should render_template("action_with_errors_in_template")
17
+ end
18
+ end
19
+
20
+ describe "a controller spec running in integration mode", :type => :controller do
21
+ controller_name :controller_spec
22
+ integrate_views
23
+
24
+ before(:each) do
25
+ controller.class.send(:define_method, :rescue_action) { |e| raise e }
26
+ end
27
+
28
+ it "should render a template" do
29
+ get 'action_with_template'
30
+ response.should be_success
31
+ response.should have_tag('div', 'This is action_with_template.rhtml')
32
+ end
33
+
34
+ it "should choke if the template doesn't exist" do
35
+ lambda { get 'some_action' }.should raise_error(ActionController::MissingTemplate)
36
+ response.should_not be_success
37
+ end
38
+
39
+ it "should choke if the template has errors" do
40
+ lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError)
41
+ response.should_not be_success
42
+ end
43
+ end
@@ -0,0 +1,187 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'controller_spec_controller'
3
+
4
+ ['integration', 'isolation'].each do |mode|
5
+ describe "A controller example running in #{mode} mode", :type => :controller do
6
+ controller_name :controller_spec
7
+ integrate_views if mode == 'integration'
8
+
9
+ it "should provide controller.session as session" do
10
+ get 'action_with_template'
11
+ session.should equal(controller.session)
12
+ end
13
+
14
+ it "should provide the same session object before and after the action" do
15
+ session_before = session
16
+ get 'action_with_template'
17
+ session.should equal(session_before)
18
+ end
19
+
20
+ it "should ensure controller.session is NOT nil before the action" do
21
+ controller.session.should_not be_nil
22
+ get 'action_with_template'
23
+ end
24
+
25
+ it "should ensure controller.session is NOT nil after the action" do
26
+ get 'action_with_template'
27
+ controller.session.should_not be_nil
28
+ end
29
+
30
+ it "should allow specifying a partial with partial name only" do
31
+ get 'action_with_partial'
32
+ response.should render_template("_partial")
33
+ end
34
+
35
+ it "should allow specifying a partial with expect_render" do
36
+ controller.expect_render(:partial => "controller_spec/partial")
37
+ get 'action_with_partial'
38
+ end
39
+
40
+ it "should allow specifying a partial with expect_render with object" do
41
+ controller.expect_render(:partial => "controller_spec/partial", :object => "something")
42
+ get 'action_with_partial_with_object', :thing => "something"
43
+ end
44
+
45
+ it "should allow specifying a partial with expect_render with locals" do
46
+ controller.expect_render(:partial => "controller_spec/partial", :locals => {:thing => "something"})
47
+ get 'action_with_partial_with_locals', :thing => "something"
48
+ end
49
+
50
+ it "should yield to render :update" do
51
+ template = stub("template")
52
+ controller.expect_render(:update).and_yield(template)
53
+ template.should_receive(:replace).with(:bottom, "replace_me", :partial => "non_existent_partial")
54
+ get 'action_with_render_update'
55
+ puts response.body
56
+ end
57
+
58
+ it "should allow a path relative to RAILS_ROOT/app/views/ when specifying a partial" do
59
+ get 'action_with_partial'
60
+ response.should render_template("controller_spec/_partial")
61
+ end
62
+
63
+ it "should provide access to flash" do
64
+ get 'action_with_template'
65
+ flash[:flash_key].should == "flash value"
66
+ end
67
+
68
+ it "should provide access to flash values set after a session reset" do
69
+ get 'action_setting_flash_after_session_reset'
70
+ flash[:after_reset].should == "available"
71
+ end
72
+
73
+ it "should not provide access to flash values set before a session reset" do
74
+ get 'action_setting_flash_before_session_reset'
75
+ flash[:before_reset].should_not == "available"
76
+ end
77
+
78
+ it "should provide access to session" do
79
+ get 'action_with_template'
80
+ session[:session_key].should == "session value"
81
+ end
82
+
83
+ it "should support custom routes" do
84
+ route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route"
85
+ end
86
+
87
+ it "should support existing routes" do
88
+ route_for(:controller => "controller_spec", :action => "some_action").should == "/controller_spec/some_action"
89
+ end
90
+
91
+ it "should generate params for custom routes" do
92
+ params_from(:get, '/custom_route').should == {:controller => "custom_route_spec", :action => "custom_route"}
93
+ end
94
+
95
+ it "should generate params for existing routes" do
96
+ params_from(:get, '/controller_spec/some_action').should == {:controller => "controller_spec", :action => "some_action"}
97
+ end
98
+
99
+ it "should expose instance vars through the assigns hash" do
100
+ get 'action_setting_the_assigns_hash'
101
+ assigns[:indirect_assigns_key].should == :indirect_assigns_key_value
102
+ end
103
+
104
+ it "should expose the assigns hash directly" do
105
+ get 'action_setting_the_assigns_hash'
106
+ assigns[:direct_assigns_key].should == :direct_assigns_key_value
107
+ end
108
+
109
+ it "should complain when calling should_receive(:render) on the controller" do
110
+ lambda {
111
+ controller.should_receive(:render)
112
+ }.should raise_error(RuntimeError, /should_receive\(:render\) has been disabled/)
113
+ end
114
+
115
+ it "should complain when calling stub!(:render) on the controller" do
116
+ lambda {
117
+ controller.stub!(:render)
118
+ }.should raise_error(RuntimeError, /stub!\(:render\) has been disabled/)
119
+ end
120
+
121
+ it "should NOT complain when calling should_receive with arguments other than :render" do
122
+ controller.should_receive(:anything_besides_render)
123
+ lambda {
124
+ controller.rspec_verify
125
+ }.should raise_error(Exception, /expected :anything_besides_render/)
126
+ end
127
+ end
128
+
129
+ describe "Given a controller spec for RedirectSpecController running in #{mode} mode", :type => :controller do
130
+ controller_name :redirect_spec
131
+ integrate_views if mode == 'integration'
132
+
133
+ it "a redirect should ignore the absence of a template" do
134
+ get 'action_with_redirect_to_somewhere'
135
+ response.should be_redirect
136
+ response.redirect_url.should == "http://test.host/redirect_spec/somewhere"
137
+ response.should redirect_to("http://test.host/redirect_spec/somewhere")
138
+ end
139
+
140
+ it "a call to response.should redirect_to should fail if no redirect" do
141
+ get 'action_with_no_redirect'
142
+ lambda {
143
+ response.redirect?.should be_true
144
+ }.should fail
145
+ lambda {
146
+ response.should redirect_to("http://test.host/redirect_spec/somewhere")
147
+ }.should fail_with("expected redirect to \"http://test.host/redirect_spec/somewhere\", got no redirect")
148
+ end
149
+ end
150
+
151
+ describe "Given a controller spec running in #{mode} mode" do
152
+ example_group = describe "A controller spec"
153
+ # , :type => :controller do
154
+ # integrate_views if mode == 'integration'
155
+ it "a spec in a context without controller_name set should fail with a useful warning" do
156
+ pending("need a new way to deal with examples that should_raise")
157
+ # ,
158
+ # :should_raise => [
159
+ # Spec::Expectations::ExpectationNotMetError,
160
+ # /You have to declare the controller name in controller specs/
161
+ # ] do
162
+ end
163
+ end
164
+
165
+ end
166
+
167
+ describe ControllerSpecController, :type => :controller do
168
+ it "should not require naming the controller if describe is passed a type" do
169
+ end
170
+ end
171
+
172
+ module Spec
173
+ module Rails
174
+ module Example
175
+ describe ControllerExampleGroup do
176
+ it "should clear its name from the description" do
177
+ group = describe("foo", :type => :controller) do
178
+ $nested_group = describe("bar") do
179
+ end
180
+ end
181
+ group.description.to_s.should == "foo"
182
+ $nested_group.description.to_s.should == "foo bar"
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end