Permalink
Browse files

Extracted context framework

  • Loading branch information...
1 parent acb71a6 commit d33b7daf8e5625e60382b007b7b8485ab919f5f6 @jferris jferris committed Dec 15, 2010
Showing with 764 additions and 18,581 deletions.
  1. +0 −13 .autotest
  2. +2 −0 .bundle/config
  3. +0 −2 .gitignore
  4. +3 −3 CONTRIBUTION_GUIDELINES.rdoc
  5. +5 −0 Gemfile
  6. +20 −0 Gemfile.lock
  7. +6 −108 README.rdoc
  8. +6 −36 Rakefile
  9. +0 −2 cucumber.yml
  10. +0 −115 features/rails_integration.feature
  11. +0 −31 features/step_definitions/common_steps.rb
  12. +0 −83 features/step_definitions/rails2_steps.rb
  13. +0 −60 features/step_definitions/rails3_steps.rb
  14. +0 −36 features/support/terminal.rb
  15. +12 −0 lib/shoulda-context.rb
  16. +0 −9 lib/shoulda.rb
  17. +0 −34 lib/shoulda/action_controller.rb
  18. +0 −221 lib/shoulda/action_controller/macros.rb
  19. +0 −39 lib/shoulda/action_controller/matchers.rb
  20. +0 −114 lib/shoulda/action_controller/matchers/assign_to_matcher.rb
  21. +0 −74 lib/shoulda/action_controller/matchers/filter_param_matcher.rb
  22. +0 −62 lib/shoulda/action_controller/matchers/redirect_to_matcher.rb
  23. +0 −54 lib/shoulda/action_controller/matchers/render_template_matcher.rb
  24. +0 −99 lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb
  25. +0 −74 lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
  26. +0 −85 lib/shoulda/action_controller/matchers/respond_with_matcher.rb
  27. +0 −93 lib/shoulda/action_controller/matchers/route_matcher.rb
  28. +0 −98 lib/shoulda/action_controller/matchers/set_session_matcher.rb
  29. +0 −100 lib/shoulda/action_controller/matchers/set_the_flash_matcher.rb
  30. +0 −13 lib/shoulda/action_mailer.rb
  31. +0 −42 lib/shoulda/action_mailer/assertions.rb
  32. +0 −22 lib/shoulda/action_mailer/matchers.rb
  33. +0 −110 lib/shoulda/action_mailer/matchers/have_sent_email.rb
  34. +0 −16 lib/shoulda/active_record.rb
  35. +0 −69 lib/shoulda/active_record/assertions.rb
  36. +0 −32 lib/shoulda/active_record/helpers.rb
  37. +0 −457 lib/shoulda/active_record/macros.rb
  38. +0 −42 lib/shoulda/active_record/matchers.rb
  39. +0 −83 lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb
  40. +0 −110 lib/shoulda/active_record/matchers/allow_value_matcher.rb
  41. +0 −226 lib/shoulda/active_record/matchers/association_matcher.rb
  42. +0 −87 lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
  43. +0 −141 lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
  44. +0 −169 lib/shoulda/active_record/matchers/have_db_column_matcher.rb
  45. +0 −112 lib/shoulda/active_record/matchers/have_db_index_matcher.rb
  46. +0 −59 lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb
  47. +0 −41 lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb
  48. +0 −65 lib/shoulda/active_record/matchers/validate_format_of_matcher.rb
  49. +0 −39 lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb
  50. +0 −60 lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb
  51. +0 −148 lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
  52. +0 −56 lib/shoulda/active_record/matchers/validation_matcher.rb
  53. +0 −79 lib/shoulda/assertions.rb
  54. +0 −441 lib/shoulda/context.rb
  55. +81 −0 lib/shoulda/context/assertions.rb
  56. 0 lib/shoulda/{ → context}/autoload_macros.rb
  57. +446 −0 lib/shoulda/context/context.rb
  58. 0 lib/shoulda/{ → context}/proc_extensions.rb
  59. 0 lib/shoulda/{ → context}/tasks.rb
  60. 0 lib/shoulda/{ → context}/tasks/list_tests.rake
  61. 0 lib/shoulda/{ → context}/tasks/yaml_to_shoulda.rake
  62. +5 −0 lib/shoulda/context/version.rb
  63. +0 −8 lib/shoulda/helpers.rb
  64. +0 −13 lib/shoulda/integrations/rspec.rb
  65. +0 −22 lib/shoulda/integrations/rspec2.rb
  66. +0 −22 lib/shoulda/integrations/test_unit.rb
  67. +0 −161 lib/shoulda/macros.rb
  68. +0 −13 lib/shoulda/private_helpers.rb
  69. +0 −8 lib/shoulda/rails.rb
  70. +0 −4 lib/shoulda/version.rb
  71. +2 −6 rails/init.rb
  72. +7 −8 shoulda.gemspec → shoulda-context.gemspec
  73. +1 −1 tasks/shoulda.rake
  74. +0 −36 test/README
  75. +0 −55 test/fail_macros.rb
  76. +1 −1 test/{rails2_root → fake_rails_root}/test/shoulda_macros/custom_macro.rb
  77. +1 −1 test/{rails2_root → fake_rails_root}/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
  78. 0 test/{rails2_root/log → fake_rails_root/vendor/plugins}/.keep
  79. +1 −1 test/{rails2_root → fake_rails_root}/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
  80. +0 −3 test/fixtures/addresses.yml
  81. 0 test/fixtures/friendships.yml
  82. +0 −5 test/fixtures/posts.yml
  83. 0 test/fixtures/products.yml
  84. 0 test/fixtures/taggings.yml
  85. +0 −9 test/fixtures/tags.yml
  86. +0 −6 test/fixtures/users.yml
  87. +0 −121 test/functional/posts_controller_test.rb
  88. +0 −19 test/functional/users_controller_test.rb
  89. +0 −76 test/matchers/action_mailer/have_sent_email_test.rb
  90. +0 −74 test/matchers/active_record/allow_mass_assignment_of_matcher_test.rb
  91. +0 −64 test/matchers/active_record/allow_value_matcher_test.rb
  92. +0 −263 test/matchers/active_record/association_matcher_test.rb
  93. +0 −81 test/matchers/active_record/ensure_inclusion_of_matcher_test.rb
  94. +0 −158 test/matchers/active_record/ensure_length_of_matcher_test.rb
  95. +0 −169 test/matchers/active_record/have_db_column_matcher_test.rb
  96. +0 −91 test/matchers/active_record/have_db_index_matcher_test.rb
  97. +0 −29 test/matchers/active_record/have_readonly_attributes_matcher_test.rb
  98. +0 −44 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
  99. +0 −39 test/matchers/active_record/validate_format_of_matcher_test.rb
  100. +0 −52 test/matchers/active_record/validate_numericality_of_matcher_test.rb
  101. +0 −86 test/matchers/active_record/validate_presence_of_matcher_test.rb
  102. +0 −147 test/matchers/active_record/validate_uniqueness_of_matcher_test.rb
  103. +0 −55 test/matchers/controller/assign_to_matcher_test.rb
  104. +0 −40 test/matchers/controller/filter_param_matcher_test.rb
  105. +0 −37 test/matchers/controller/redirect_to_matcher_test.rb
  106. +0 −37 test/matchers/controller/render_template_matcher_test.rb
  107. +0 −47 test/matchers/controller/render_with_layout_matcher_test.rb
  108. +0 −32 test/matchers/controller/respond_with_content_type_matcher_test.rb
  109. +0 −96 test/matchers/controller/respond_with_matcher_test.rb
  110. +0 −75 test/matchers/controller/route_matcher_test.rb
  111. +0 −48 test/matchers/controller/set_session_matcher_test.rb
  112. +0 −95 test/matchers/controller/set_the_flash_matcher.rb
  113. +0 −317 test/other/helpers_test.rb
  114. +0 −32 test/other/private_helpers_test.rb
  115. +0 −130 test/rails2_model_builder.rb
  116. +0 −22 test/rails2_root/app/controllers/application_controller.rb
  117. +0 −87 test/rails2_root/app/controllers/posts_controller.rb
  118. +0 −84 test/rails2_root/app/controllers/users_controller.rb
  119. +0 −3 test/rails2_root/app/helpers/application_helper.rb
  120. +0 −2 test/rails2_root/app/helpers/posts_helper.rb
  121. +0 −2 test/rails2_root/app/helpers/users_helper.rb
  122. +0 −7 test/rails2_root/app/models/address.rb
  123. +0 −11 test/rails2_root/app/models/flea.rb
  124. +0 −4 test/rails2_root/app/models/friendship.rb
  125. +0 −8 test/rails2_root/app/models/notifier.rb
  126. +0 −7 test/rails2_root/app/models/pets/cat.rb
  127. +0 −10 test/rails2_root/app/models/pets/dog.rb
  128. +0 −12 test/rails2_root/app/models/post.rb
  129. +0 −12 test/rails2_root/app/models/product.rb
  130. +0 −2 test/rails2_root/app/models/profile.rb
  131. +0 −2 test/rails2_root/app/models/registration.rb
  132. +0 −8 test/rails2_root/app/models/tag.rb
  133. +0 −4 test/rails2_root/app/models/tagging.rb
  134. +0 −3 test/rails2_root/app/models/treat.rb
  135. +0 −32 test/rails2_root/app/models/user.rb
  136. +0 −19 test/rails2_root/app/views/layouts/posts.rhtml
  137. +0 −17 test/rails2_root/app/views/layouts/users.rhtml
  138. +0 −1 test/rails2_root/app/views/layouts/wide.html.erb
  139. +0 −1 test/rails2_root/app/views/notifier/the_email.html.erb
  140. +0 −27 test/rails2_root/app/views/posts/edit.rhtml
  141. +0 −25 test/rails2_root/app/views/posts/index.rhtml
  142. +0 −26 test/rails2_root/app/views/posts/new.rhtml
  143. +0 −18 test/rails2_root/app/views/posts/show.rhtml
  144. +0 −22 test/rails2_root/app/views/users/edit.rhtml
  145. +0 −22 test/rails2_root/app/views/users/index.rhtml
  146. +0 −21 test/rails2_root/app/views/users/new.rhtml
  147. +0 −13 test/rails2_root/app/views/users/show.rhtml
  148. +0 −110 test/rails2_root/config/boot.rb
  149. +0 −4 test/rails2_root/config/database.yml
  150. +0 −17 test/rails2_root/config/environment.rb
  151. +0 −23 test/rails2_root/config/environments/test.rb
  152. +0 −15 test/rails2_root/config/initializers/new_rails_defaults.rb
  153. +0 −8 test/rails2_root/config/initializers/shoulda.rb
  154. +0 −6 test/rails2_root/config/routes.rb
  155. +0 −19 test/rails2_root/db/migrate/001_create_users.rb
  156. +0 −13 test/rails2_root/db/migrate/002_create_posts.rb
  157. +0 −12 test/rails2_root/db/migrate/003_create_taggings.rb
  158. +0 −11 test/rails2_root/db/migrate/004_create_tags.rb
  159. +0 −12 test/rails2_root/db/migrate/005_create_dogs.rb
  160. +0 −14 test/rails2_root/db/migrate/006_create_addresses.rb
  161. +0 −11 test/rails2_root/db/migrate/007_create_fleas.rb
  162. +0 −12 test/rails2_root/db/migrate/008_create_dogs_fleas.rb
  163. +0 −17 test/rails2_root/db/migrate/009_create_products.rb
  164. +0 −14 test/rails2_root/db/migrate/010_create_friendships.rb
  165. +0 −12 test/rails2_root/db/migrate/011_create_treats.rb
  166. +0 −12 test/rails2_root/db/migrate/20090506203502_create_profiles.rb
  167. +0 −14 test/rails2_root/db/migrate/20090506203536_create_registrations.rb
  168. +0 −12 test/rails2_root/db/migrate/20090513104502_create_cats.rb
  169. 0 test/rails2_root/db/schema.rb
  170. +0 −40 test/rails2_root/public/.htaccess
  171. +0 −30 test/rails2_root/public/404.html
  172. +0 −30 test/rails2_root/public/422.html
  173. +0 −30 test/rails2_root/public/500.html
  174. +0 −3 test/rails2_root/script/console
  175. +0 −3 test/rails2_root/script/generate
  176. 0 test/rails2_root/vendor/plugins/.keep
  177. +0 −6 test/rails2_test_helper.rb
  178. +0 −118 test/rails3_model_builder.rb
  179. +0 −4 test/rails3_root/.gitignore
  180. +0 −28 test/rails3_root/Gemfile
  181. +0 −244 test/rails3_root/README
  182. +0 −10 test/rails3_root/Rakefile
  183. +0 −22 test/rails3_root/app/controllers/application_controller.rb
  184. +0 −87 test/rails3_root/app/controllers/posts_controller.rb
  185. +0 −82 test/rails3_root/app/controllers/users_controller.rb
  186. +0 −2 test/rails3_root/app/helpers/application_helper.rb
  187. +0 −7 test/rails3_root/app/models/address.rb
  188. +0 −11 test/rails3_root/app/models/flea.rb
  189. +0 −4 test/rails3_root/app/models/friendship.rb
  190. +0 −8 test/rails3_root/app/models/notifier.rb
  191. +0 −7 test/rails3_root/app/models/pets/cat.rb
  192. +0 −10 test/rails3_root/app/models/pets/dog.rb
  193. +0 −12 test/rails3_root/app/models/post.rb
  194. +0 −12 test/rails3_root/app/models/product.rb
  195. +0 −2 test/rails3_root/app/models/profile.rb
  196. +0 −2 test/rails3_root/app/models/registration.rb
  197. +0 −8 test/rails3_root/app/models/tag.rb
  198. +0 −4 test/rails3_root/app/models/tagging.rb
  199. +0 −3 test/rails3_root/app/models/treat.rb
  200. +0 −32 test/rails3_root/app/models/user.rb
  201. +0 −14 test/rails3_root/app/views/layouts/application.html.erb
  202. +0 −19 test/rails3_root/app/views/layouts/posts.rhtml
  203. +0 −17 test/rails3_root/app/views/layouts/users.rhtml
  204. +0 −1 test/rails3_root/app/views/layouts/wide.html.erb
  205. +0 −1 test/rails3_root/app/views/notifier/the_email.html.erb
  206. +0 −27 test/rails3_root/app/views/posts/edit.rhtml
  207. +0 −25 test/rails3_root/app/views/posts/index.rhtml
  208. +0 −24 test/rails3_root/app/views/posts/new.rhtml
  209. +0 −18 test/rails3_root/app/views/posts/show.rhtml
  210. +0 −22 test/rails3_root/app/views/users/edit.rhtml
  211. +0 −22 test/rails3_root/app/views/users/index.rhtml
  212. +0 −21 test/rails3_root/app/views/users/new.rhtml
  213. +0 −13 test/rails3_root/app/views/users/show.rhtml
  214. +0 −4 test/rails3_root/config.ru
  215. +0 −46 test/rails3_root/config/application.rb
  216. +0 −6 test/rails3_root/config/boot.rb
  217. +0 −22 test/rails3_root/config/database.yml
  218. +0 −5 test/rails3_root/config/environment.rb
  219. +0 −19 test/rails3_root/config/environments/development.rb
  220. +0 −42 test/rails3_root/config/environments/production.rb
  221. +0 −32 test/rails3_root/config/environments/test.rb
  222. +0 −7 test/rails3_root/config/initializers/backtrace_silencers.rb
  223. +0 −10 test/rails3_root/config/initializers/inflections.rb
  224. +0 −5 test/rails3_root/config/initializers/mime_types.rb
  225. +0 −7 test/rails3_root/config/initializers/secret_token.rb
  226. +0 −8 test/rails3_root/config/initializers/session_store.rb
  227. +0 −5 test/rails3_root/config/locales/en.yml
  228. +0 −4 test/rails3_root/config/routes.rb
  229. +0 −19 test/rails3_root/db/migrate/001_create_users.rb
  230. +0 −13 test/rails3_root/db/migrate/002_create_posts.rb
  231. +0 −12 test/rails3_root/db/migrate/003_create_taggings.rb
  232. +0 −11 test/rails3_root/db/migrate/004_create_tags.rb
  233. +0 −12 test/rails3_root/db/migrate/005_create_dogs.rb
  234. +0 −14 test/rails3_root/db/migrate/006_create_addresses.rb
  235. +0 −11 test/rails3_root/db/migrate/007_create_fleas.rb
  236. +0 −12 test/rails3_root/db/migrate/008_create_dogs_fleas.rb
  237. +0 −17 test/rails3_root/db/migrate/009_create_products.rb
  238. +0 −14 test/rails3_root/db/migrate/010_create_friendships.rb
  239. +0 −12 test/rails3_root/db/migrate/011_create_treats.rb
  240. +0 −12 test/rails3_root/db/migrate/20090506203502_create_profiles.rb
  241. +0 −14 test/rails3_root/db/migrate/20090506203536_create_registrations.rb
  242. +0 −12 test/rails3_root/db/migrate/20090513104502_create_cats.rb
  243. +0 −7 test/rails3_root/db/seeds.rb
  244. 0 test/rails3_root/lib/tasks/.gitkeep
  245. +0 −26 test/rails3_root/public/404.html
  246. +0 −26 test/rails3_root/public/422.html
  247. +0 −26 test/rails3_root/public/500.html
  248. 0 test/rails3_root/public/favicon.ico
  249. BIN test/rails3_root/public/images/rails.png
  250. +0 −279 test/rails3_root/public/index.html
  251. +0 −2 test/rails3_root/public/javascripts/application.js
  252. +0 −965 test/rails3_root/public/javascripts/controls.js
  253. +0 −974 test/rails3_root/public/javascripts/dragdrop.js
  254. +0 −1,123 test/rails3_root/public/javascripts/effects.js
  255. +0 −4,874 test/rails3_root/public/javascripts/prototype.js
  256. +0 −118 test/rails3_root/public/javascripts/rails.js
  257. +0 −5 test/rails3_root/public/robots.txt
  258. 0 test/rails3_root/public/stylesheets/.gitkeep
  259. +0 −9 test/rails3_root/script/rails
  260. +0 −9 test/rails3_root/test/performance/browsing_test.rb
  261. +0 −13 test/rails3_root/test/test_helper.rb
  262. 0 test/rails3_root/vendor/plugins/.gitkeep
  263. +0 −6 test/rails3_test_helper.rb
  264. +0 −207 test/rspec_test.rb
  265. +1 −1 test/{other → shoulda}/autoload_macro_test.rb
  266. +15 −19 test/{other → shoulda}/context_test.rb
  267. +3 −3 test/{other → shoulda}/convert_to_should_syntax_test.rb
  268. +124 −0 test/shoulda/helpers_test.rb
  269. +19 −19 test/{other → shoulda}/should_test.rb
  270. +3 −28 test/test_helper.rb
  271. +0 −10 test/unit/address_test.rb
  272. +0 −7 test/unit/cat_test.rb
  273. +0 −9 test/unit/dog_test.rb
  274. +0 −14 test/unit/flea_test.rb
  275. +0 −6 test/unit/friendship_test.rb
  276. +0 −15 test/unit/post_test.rb
  277. +0 −23 test/unit/product_test.rb
  278. +0 −11 test/unit/tag_test.rb
  279. +0 −6 test/unit/tagging_test.rb
  280. +0 −46 test/unit/user_test.rb
View
@@ -1,13 +0,0 @@
-Autotest.add_hook :initialize do |at|
- at.add_mapping(%r{^lib/\w.*\.rb}) do
- at.files_matching(%r{^test/*/\w.*_test\.rb})
- end
-
- at.add_mapping(%r{^test/rails_root/\w.*}) do
- at.files_matching(%r{^test/*/\w.*_test\.rb})
- end
-
- at.add_exception(%r{.svn})
- at.add_exception(%r{.log$})
- at.add_exception(%r{^.autotest$})
-end
View
@@ -0,0 +1,2 @@
+---
+BUNDLE_DISABLE_SHARED_GEMS: "1"
View
@@ -1,7 +1,5 @@
-test/*/log/*.log
doc
coverage
-.svn/
pkg
*.swp
*.swo
@@ -1,10 +1,10 @@
-We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
+We're using GitHub[http://github.com/thoughtbot/shoulda-context], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
-* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master].
+* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda-context].
* We prefer git branches over patches, but we can take either.
* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
* If you're submitting patches, please cut each fix or feature into a separate patch.
-* There should be an issue[http://github.com/thoughtbot/shoulda/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
+* There should be an issue[http://github.com/thoughtbot/shoulda-context/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
* Please <b>don't send pull requests</b> Just update the issue with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
View
@@ -0,0 +1,5 @@
+source 'http://rubygems.org'
+
+gem 'mocha'
+gem 'ruby-debug'
+
View
@@ -0,0 +1,20 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ columnize (0.3.2)
+ linecache (0.43)
+ mocha (0.9.10)
+ rake
+ rake (0.8.7)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ mocha
+ ruby-debug
View
@@ -1,65 +1,10 @@
-= Shoulda - Making tests easy on the fingers and eyes
+= should-context - a context framework for Test::Unit
-Shoulda makes it easy to write elegant, understandable, and maintainable tests. Shoulda consists of matchers, test helpers, and assertions. It's fully compatible with your existing tests in Test::Unit or RSpec, and requires no retooling to use.
+Shoulda's contexts make it easy to write elegant, understandable, and maintainable tests for Test::Unit. It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
-Matchers:: Test::Unit- and RSpec-compatible one-liners that test common Rails functionality.
- These tests would otherwise be much longer, more complex, and error-prone.
-Helpers:: #context and #should give you RSpec like test blocks in Test::Unit.
- In addition, you get nested contexts and a much more readable syntax.
-Assertions:: Many common Rails testing idioms have been distilled into a set of useful assertions.
+The #context and #should methods give you RSpec like test blocks in Test::Unit.
-= Usage
-
-=== ActiveRecord Tests (Shoulda::ActiveRecord::Matchers)
-
-Test your ActiveRecord associations and validations with these powerful matchers:
-
- class PostTest < Test::Unit::TestCase
- should belong_to(:user)
- should have_many(:tags).through(:taggings)
-
- should validate_uniqueness_of(:title)
- should validate_presence_of(:body).with_message(/wtf/)
- should validate_presence_of(:title)
- should validate_numericality_of(:user_id)
- end
-
- class UserTest < Test::Unit::TestCase
- should have_many(:posts)
-
- should_not allow_value("blah").for(:email)
- should_not allow_value("b lah").for(:email)
- should allow_value("a@b.com").for(:email)
- should allow_value("asdf@asdf.com").for(:email)
- should ensure_inclusion_of(:email).in_range(1..100)
- should ensure_inclusion_of(:age).in_range(1..100)
- should_not allow_mass_assignment_of(:password)
- end
-
-Makes TDD so much easier.
-
-=== Controller Tests (Shoulda::Controller::Matchers)
-
-Matchers to test the most common controller patterns...
-
- class PostsControllerTest < ActionController::TestCase
- context "on GET to :show for first record" do
- setup do
- get :show, :id => 1
- end
-
- should assign_to(:user)
- should respond_with(:success)
- should render_template(:show)
- should_not set_the_flash
-
- should "do something else really cool" do
- assert_equal 1, assigns(:user).id
- end
- end
- end
-
-=== Context Helpers (Shoulda::Context)
+== Contexts
Stop killing your fingers with all of those underscores... Name your tests with plain sentences!
@@ -92,63 +37,16 @@ Produces the following test methods:
So readable!
-=== Helpful Assertions (Shoulda::Assertions)
-
-More to come here, but have fun with what's there.
+== Assertions
assert_same_elements([:a, :b, :c], [:c, :a, :b])
assert_contains(['a', '1'], /\d/)
assert_contains(['a', '1'], 'a')
-= Rails Installation (Test::Unit)
-
-Specify the gem dependency in your config/environment.rb file:
-
- Rails::Initializer.run do |config|
- config.gem "shoulda", :lib => "shoulda"
- end
-
-Then:
-
- $ rake gems:install
- $ rake gems:unpack
-
-= Rails Installation (RSpec)
-
-If you're using Shoulda with RSpec, we recommend that you add config.gem lines
-for RSpec and Shoulda in your config/environment/test.rb file, but do not ask
-Rails to load the RSpec and Shoulda libraries:
-
- config.gem 'rspec', :lib => false
- config.gem 'rspec-rails', :lib => false
- config.gem 'shoulda', :lib => false
-
-Then require shoulda from your spec/spec_helper.rb file, before Spec::Runner is
-configured:
-
- # requires for RSpec
- require 'shoulda'
- Spec::Runner.configure do |config|
- # ...
-
-You should not need to require anything besides the top-level shoulda library.
-
-= Rails 3 Installation (RSpec)
-
-With Rails 3 and Bundler, requiring Shoulda is as easy as adding it to your Gemfile:
-
- group :test do
- gem "shoulda"
- gem "rspec-rails", "2.0.0.beta.12"
- end
-
-Shoulda will automatically include matchers into the appropriate example
-groups.
-
= Credits
Shoulda is maintained and funded by {thoughtbot}[http://thoughtbot.com/community]
= License
-Shoulda is Copyright © 2006-2010 Tammer Saleh, Thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
+Shoulda is Copyright © 2010 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
View
@@ -1,20 +1,14 @@
require 'rubygems'
+require 'bundler/setup'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
-begin
- require 'cucumber/rake/task'
-rescue LoadError
- warn "couldn't load cucumber, skipping"
-end
$LOAD_PATH.unshift("lib")
-require 'shoulda/version'
load 'tasks/shoulda.rake'
-# Test::Unit::UI::VERBOSE
-test_files_pattern = 'test/{unit,functional,other,matchers}/**/*_test.rb'
+test_files_pattern = 'test/**/*_test.rb'
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
t.pattern = test_files_pattern
@@ -23,7 +17,7 @@ end
Rake::RDocTask.new { |rdoc|
rdoc.rdoc_dir = 'doc'
- rdoc.title = "Shoulda -- Making tests easy on the fingers and eyes"
+ rdoc.title = "shoulda-context -- Context framework for Test::Unit"
rdoc.options << '--line-numbers'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb')
@@ -36,7 +30,7 @@ task :coverage do
system "rcov --rails --sort coverage -Ilib #{files.join(' ')}"
end
-eval("$specification = begin; #{IO.read('shoulda.gemspec')}; end")
+eval("$specification = begin; #{IO.read('shoulda-context.gemspec')}; end")
Rake::GemPackageTask.new $specification do |pkg|
pkg.need_tar = true
pkg.need_zip = true
@@ -45,30 +39,6 @@ end
desc "Clean files generated by rake tasks"
task :clobber => [:clobber_rdoc, :clobber_package]
-namespace :cucumber do
- Cucumber::Rake::Task.new(:rails2, "Run the cucumber features in Rails 2") do |t|
- t.fork = true
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
- t.profile = 'rails2'
- end
-
- Cucumber::Rake::Task.new(:rails3, "Run the cucumber features in Rails 3") do |t|
- t.fork = true
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
- t.profile = 'rails3'
- end
-end rescue nil
-
-desc "Run the cucumber features in both Rails 2 and 3"
-task :cucumber => ["cucumber:rails2", "cucumber:rails3"]
-
-desc 'run tests for all supported versions of Rails'
-task :test_all do
- %w(2.3.8 3.0.0.beta4).each do |version|
- system("RAILS_VERSION=#{version} rake -s test;")
- end
-end
-
-desc 'Default: run test and cucumber features for support versions'
-task :default => [:test_all, :cucumber]
+desc 'Default: run tests'
+task :default => [:test]
View
@@ -1,2 +0,0 @@
-rails2: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails2_steps.rb
-rails3: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails3_steps.rb
@@ -1,115 +0,0 @@
-Feature: integrate with Rails
-
- Background:
- When I generate a new rails application
- And I configure the application to use "shoulda" from this project
- And I save the following as "db/migrate/1_create_users.rb"
- """
- class CreateUsers < ActiveRecord::Migration
- def self.up
- create_table :users do |t|
- t.string :name
- end
- end
- end
- """
- When I run "rake db:migrate"
- And I save the following as "app/models/user.rb"
- """
- class User < ActiveRecord::Base
- validates_presence_of :name
- end
- """
- When I save the following as "app/controllers/examples_controller.rb"
- """
- class ExamplesController < ApplicationController
- def show
- @example = 'hello'
- render :nothing => true
- end
- end
- """
- When I configure a wildcard route
-
- Scenario: generate a rails application and use macros in Test::Unit
- When I save the following as "test/unit/user_test.rb"
- """
- require 'test_helper'
-
- class UserTest < ActiveSupport::TestCase
- should_validate_presence_of :name
- end
- """
- When I save the following as "test/functional/examples_controller_test.rb"
- """
- require 'test_helper'
-
- class ExamplesControllerTest < ActionController::TestCase
- def setup
- get :show
- end
-
- should_respond_with :success
- should_assign_to :example
- end
- """
- When I run "rake test TESTOPTS=-v"
- Then I should see "1 tests, 1 assertions, 0 failures, 0 errors"
- And I should see "2 tests, 2 assertions, 0 failures, 0 errors"
- And I should see "User should require name to be set"
- And I should see "ExamplesController should assign @example"
-
- Scenario: generate a rails application and use matchers in Test::Unit
- When I save the following as "test/unit/user_test.rb"
- """
- require 'test_helper'
-
- class UserTest < ActiveSupport::TestCase
- should validate_presence_of(:name)
- end
- """
- When I save the following as "test/functional/examples_controller_test.rb"
- """
- require 'test_helper'
-
- class ExamplesControllerTest < ActionController::TestCase
- def setup
- get :show
- end
-
- should respond_with(:success)
- should assign_to(:example)
- end
- """
- When I run "rake test TESTOPTS=-v"
- Then I should see "1 tests, 1 assertions, 0 failures, 0 errors"
- And I should see "2 tests, 2 assertions, 0 failures, 0 errors"
- And I should see "User should require name to be set"
- And I should see "ExamplesController should assign @example"
-
- Scenario: generate a rails application and use matchers in Rspec
- When I configure the application to use rspec-rails
- And I run the rspec generator
- And I save the following as "spec/models/user_spec.rb"
- """
- require 'spec_helper'
-
- describe User do
- it { should validate_presence_of(:name) }
- end
- """
- When I save the following as "spec/controllers/examples_controller_spec.rb"
- """
- require 'spec_helper'
-
- describe ExamplesController, "show" do
- before { get :show }
- # rspec2 doesn't use the controller as the subject
- subject { controller }
- it { should assign_to(:example) }
- end
- """
- When I run "rake spec SPEC_OPTS=-fs"
- Then I should see "2 examples, 0 failures"
- And I should see "should require name to be set"
- And I should see "should assign @example"
Oops, something went wrong.

0 comments on commit d33b7da

Please sign in to comment.