Permalink
Browse files

Extracted the context framework, switched to rspec

  • Loading branch information...
1 parent a01e60a commit ada334c1a265e3a6d03e912231d8cf471d034a83 @jferris jferris committed with jferris Dec 13, 2010
Showing with 1,733 additions and 3,529 deletions.
  1. +2 −0 .bundle/config
  2. +9 −0 Gemfile
  3. +115 −0 Gemfile.lock
  4. +13 −21 Rakefile
  5. +0 −42 bin/convert_to_should_syntax
  6. +1 −1 features/step_definitions/rails3_steps.rb
  7. +0 −1 init.rb
  8. +1 −0 lib/shoulda.rb
  9. +34 −14 lib/shoulda/action_controller.rb
  10. 0 lib/shoulda/action_controller/{matchers → }/assign_to_matcher.rb
  11. +50 −0 lib/shoulda/action_controller/filter_param_matcher.rb
  12. +0 −39 lib/shoulda/action_controller/matchers.rb
  13. +0 −74 lib/shoulda/action_controller/matchers/filter_param_matcher.rb
  14. 0 lib/shoulda/action_controller/{matchers → }/redirect_to_matcher.rb
  15. 0 lib/shoulda/action_controller/{matchers → }/render_template_matcher.rb
  16. +2 −2 lib/shoulda/action_controller/{matchers → }/render_with_layout_matcher.rb
  17. 0 lib/shoulda/action_controller/{matchers → }/respond_with_content_type_matcher.rb
  18. 0 lib/shoulda/action_controller/{matchers → }/respond_with_matcher.rb
  19. 0 lib/shoulda/action_controller/{matchers → }/route_matcher.rb
  20. 0 lib/shoulda/action_controller/{matchers → }/set_session_matcher.rb
  21. +3 −9 lib/shoulda/action_controller/{matchers → }/set_the_flash_matcher.rb
  22. +18 −7 lib/shoulda/action_mailer.rb
  23. 0 lib/shoulda/action_mailer/{matchers → }/have_sent_email.rb
  24. +0 −22 lib/shoulda/action_mailer/matchers.rb
  25. +37 −7 lib/shoulda/active_record.rb
  26. 0 lib/shoulda/active_record/{matchers → }/allow_mass_assignment_of_matcher.rb
  27. 0 lib/shoulda/active_record/{matchers → }/allow_value_matcher.rb
  28. 0 lib/shoulda/active_record/{matchers → }/association_matcher.rb
  29. 0 lib/shoulda/active_record/{matchers → }/ensure_inclusion_of_matcher.rb
  30. 0 lib/shoulda/active_record/{matchers → }/ensure_length_of_matcher.rb
  31. 0 lib/shoulda/active_record/{matchers → }/have_db_column_matcher.rb
  32. 0 lib/shoulda/active_record/{matchers → }/have_db_index_matcher.rb
  33. 0 lib/shoulda/active_record/{matchers → }/have_readonly_attribute_matcher.rb
  34. +0 −42 lib/shoulda/active_record/matchers.rb
  35. 0 lib/shoulda/active_record/{matchers → }/validate_acceptance_of_matcher.rb
  36. 0 lib/shoulda/active_record/{matchers → }/validate_format_of_matcher.rb
  37. 0 lib/shoulda/active_record/{matchers → }/validate_numericality_of_matcher.rb
  38. 0 lib/shoulda/active_record/{matchers → }/validate_presence_of_matcher.rb
  39. 0 lib/shoulda/active_record/{matchers → }/validate_uniqueness_of_matcher.rb
  40. 0 lib/shoulda/active_record/{matchers → }/validation_matcher.rb
  41. +0 −79 lib/shoulda/assertions.rb
  42. +0 −46 lib/shoulda/autoload_macros.rb
  43. +0 −441 lib/shoulda/context.rb
  44. +14 −13 lib/shoulda/integrations/rspec.rb
  45. +37 −14 lib/shoulda/integrations/test_unit.rb
  46. +0 −14 lib/shoulda/proc_extensions.rb
  47. +0 −8 lib/shoulda/rails.rb
  48. +0 −3 lib/shoulda/tasks.rb
  49. +0 −29 lib/shoulda/tasks/list_tests.rake
  50. +0 −28 lib/shoulda/tasks/yaml_to_shoulda.rake
  51. +0 −8 rails/init.rb
  52. 0 {test → spec}/fixtures/addresses.yml
  53. 0 {test → spec}/fixtures/friendships.yml
  54. 0 {test → spec}/fixtures/posts.yml
  55. 0 {test → spec}/fixtures/products.yml
  56. 0 {test → spec}/fixtures/taggings.yml
  57. 0 {test → spec}/fixtures/tags.yml
  58. 0 {test → spec}/fixtures/users.yml
  59. 0 {test → spec}/rails3_root/.gitignore
  60. +7 −0 spec/rails3_root/Gemfile
  61. +18 −0 {test → spec}/rails3_root/Gemfile.lock
  62. 0 {test → spec}/rails3_root/README
  63. 0 {test → spec}/rails3_root/Rakefile
  64. 0 {test → spec}/rails3_root/app/controllers/application_controller.rb
  65. 0 {test → spec}/rails3_root/app/controllers/posts_controller.rb
  66. 0 {test → spec}/rails3_root/app/controllers/users_controller.rb
  67. 0 {test → spec}/rails3_root/app/helpers/application_helper.rb
  68. 0 {test → spec}/rails3_root/app/models/address.rb
  69. 0 {test → spec}/rails3_root/app/models/flea.rb
  70. 0 {test → spec}/rails3_root/app/models/friendship.rb
  71. 0 {test → spec}/rails3_root/app/models/notifier.rb
  72. 0 {test → spec}/rails3_root/app/models/pets/cat.rb
  73. 0 {test → spec}/rails3_root/app/models/pets/dog.rb
  74. 0 {test → spec}/rails3_root/app/models/post.rb
  75. 0 {test → spec}/rails3_root/app/models/product.rb
  76. 0 {test → spec}/rails3_root/app/models/profile.rb
  77. 0 {test → spec}/rails3_root/app/models/registration.rb
  78. 0 {test → spec}/rails3_root/app/models/tag.rb
  79. 0 {test → spec}/rails3_root/app/models/tagging.rb
  80. 0 {test → spec}/rails3_root/app/models/treat.rb
  81. 0 {test → spec}/rails3_root/app/models/user.rb
  82. 0 {test → spec}/rails3_root/app/views/layouts/application.html.erb
  83. 0 {test → spec}/rails3_root/app/views/layouts/posts.rhtml
  84. 0 {test → spec}/rails3_root/app/views/layouts/users.rhtml
  85. 0 {test → spec}/rails3_root/app/views/layouts/wide.html.erb
  86. 0 {test → spec}/rails3_root/app/views/notifier/the_email.html.erb
  87. 0 {test → spec}/rails3_root/app/views/posts/edit.rhtml
  88. 0 {test → spec}/rails3_root/app/views/posts/index.rhtml
  89. 0 {test → spec}/rails3_root/app/views/posts/new.rhtml
  90. 0 {test → spec}/rails3_root/app/views/posts/show.rhtml
  91. 0 {test → spec}/rails3_root/app/views/users/edit.rhtml
  92. 0 {test → spec}/rails3_root/app/views/users/index.rhtml
  93. 0 {test → spec}/rails3_root/app/views/users/new.rhtml
  94. 0 {test → spec}/rails3_root/app/views/users/show.rhtml
  95. 0 {test → spec}/rails3_root/config.ru
  96. 0 {test → spec}/rails3_root/config/application.rb
  97. 0 {test → spec}/rails3_root/config/boot.rb
  98. 0 {test → spec}/rails3_root/config/database.yml
  99. 0 {test → spec}/rails3_root/config/environment.rb
  100. 0 {test → spec}/rails3_root/config/environments/development.rb
  101. 0 {test → spec}/rails3_root/config/environments/production.rb
  102. 0 {test → spec}/rails3_root/config/environments/test.rb
  103. 0 {test → spec}/rails3_root/config/initializers/backtrace_silencers.rb
  104. 0 {test → spec}/rails3_root/config/initializers/inflections.rb
  105. 0 {test → spec}/rails3_root/config/initializers/mime_types.rb
  106. 0 {test → spec}/rails3_root/config/initializers/secret_token.rb
  107. 0 {test → spec}/rails3_root/config/initializers/session_store.rb
  108. 0 {test → spec}/rails3_root/config/locales/en.yml
  109. 0 {test → spec}/rails3_root/config/routes.rb
  110. 0 {test → spec}/rails3_root/db/migrate/001_create_users.rb
  111. 0 {test → spec}/rails3_root/db/migrate/002_create_posts.rb
  112. 0 {test → spec}/rails3_root/db/migrate/003_create_taggings.rb
  113. 0 {test → spec}/rails3_root/db/migrate/004_create_tags.rb
  114. 0 {test → spec}/rails3_root/db/migrate/005_create_dogs.rb
  115. 0 {test → spec}/rails3_root/db/migrate/006_create_addresses.rb
  116. 0 {test → spec}/rails3_root/db/migrate/007_create_fleas.rb
  117. 0 {test → spec}/rails3_root/db/migrate/008_create_dogs_fleas.rb
  118. 0 {test → spec}/rails3_root/db/migrate/009_create_products.rb
  119. 0 {test → spec}/rails3_root/db/migrate/010_create_friendships.rb
  120. 0 {test → spec}/rails3_root/db/migrate/011_create_treats.rb
  121. 0 {test → spec}/rails3_root/db/migrate/20090506203502_create_profiles.rb
  122. 0 {test → spec}/rails3_root/db/migrate/20090506203536_create_registrations.rb
  123. 0 {test → spec}/rails3_root/db/migrate/20090513104502_create_cats.rb
  124. 0 {test → spec}/rails3_root/db/seeds.rb
  125. 0 {test → spec}/rails3_root/lib/tasks/.gitkeep
  126. 0 {test → spec}/rails3_root/public/404.html
  127. 0 {test → spec}/rails3_root/public/422.html
  128. 0 {test → spec}/rails3_root/public/500.html
  129. 0 {test → spec}/rails3_root/public/favicon.ico
  130. BIN {test → spec}/rails3_root/public/images/rails.png
  131. 0 {test → spec}/rails3_root/public/index.html
  132. 0 {test → spec}/rails3_root/public/javascripts/application.js
  133. 0 {test → spec}/rails3_root/public/javascripts/controls.js
  134. 0 {test → spec}/rails3_root/public/javascripts/dragdrop.js
  135. 0 {test → spec}/rails3_root/public/javascripts/effects.js
  136. 0 {test → spec}/rails3_root/public/javascripts/prototype.js
  137. 0 {test → spec}/rails3_root/public/javascripts/rails.js
  138. 0 {test → spec}/rails3_root/public/robots.txt
  139. 0 {test → spec}/rails3_root/public/stylesheets/.gitkeep
  140. 0 {test → spec}/rails3_root/script/rails
  141. 0 {test → spec}/rails3_root/test/performance/browsing_test.rb
  142. 0 {test → spec}/rails3_root/test/shoulda_macros/custom_macro.rb
  143. 0 {test → spec}/rails3_root/test/test_helper.rb
  144. 0 {test → spec}/rails3_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
  145. 0 {test → spec}/rails3_root/vendor/plugins/.gitkeep
  146. 0 {test → spec}/rails3_root/vendor/plugins/.keep
  147. 0 {test → spec}/rails3_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
  148. +55 −0 spec/shoulda/action_controller/assign_to_matcher_spec.rb
  149. +23 −0 spec/shoulda/action_controller/filter_param_matcher_spec.rb
  150. +37 −0 spec/shoulda/action_controller/redirect_to_matcher_spec.rb
  151. +38 −0 spec/shoulda/action_controller/render_template_matcher_spec.rb
  152. +48 −0 spec/shoulda/action_controller/render_with_layout_matcher_spec.rb
  153. +32 −0 spec/shoulda/action_controller/respond_with_content_type_matcher_spec.rb
  154. +96 −0 spec/shoulda/action_controller/respond_with_matcher_spec.rb
  155. +68 −0 spec/shoulda/action_controller/route_matcher_spec.rb
  156. +48 −0 spec/shoulda/action_controller/set_session_matcher_spec.rb
  157. +95 −0 spec/shoulda/action_controller/set_the_flash_matcher_spec.rb
  158. +71 −0 spec/shoulda/action_mailer/have_sent_email_spec.rb
  159. +19 −19 ...signment_of_matcher_test.rb → spec/shoulda/active_record/allow_mass_assignment_of_matcher_spec.rb
  160. +20 −22 ...ctive_record/allow_value_matcher_test.rb → spec/shoulda/active_record/allow_value_matcher_spec.rb
  161. +71 −73 ...ctive_record/association_matcher_test.rb → spec/shoulda/active_record/association_matcher_spec.rb
  162. +71 −0 spec/shoulda/active_record/ensure_inclusion_of_matcher_spec.rb
  163. +125 −0 spec/shoulda/active_record/ensure_length_of_matcher_spec.rb
  164. +54 −54 ...record/have_db_column_matcher_test.rb → spec/shoulda/active_record/have_db_column_matcher_spec.rb
  165. +32 −33 ...e_record/have_db_index_matcher_test.rb → spec/shoulda/active_record/have_db_index_matcher_spec.rb
  166. +8 −8 ..._attributes_matcher_test.rb → spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
  167. +43 −0 spec/shoulda/active_record/validate_acceptance_of_matcher_spec.rb
  168. +35 −0 spec/shoulda/active_record/validate_format_of_matcher_spec.rb
  169. +49 −0 spec/shoulda/active_record/validate_numericality_of_matcher_spec.rb
  170. +22 −22 ...ate_presence_of_matcher_test.rb → spec/shoulda/active_record/validate_presence_of_matcher_spec.rb
  171. +145 −0 spec/shoulda/active_record/validate_uniqueness_of_matcher_spec.rb
  172. +32 −0 spec/spec_helper.rb
  173. +35 −19 test/rails3_model_builder.rb → spec/support/model_builder.rb
  174. +0 −1 tasks/shoulda.rake
  175. +0 −36 test/README
  176. +0 −76 test/matchers/action_mailer/have_sent_email_test.rb
  177. +0 −81 test/matchers/active_record/ensure_inclusion_of_matcher_test.rb
  178. +0 −158 test/matchers/active_record/ensure_length_of_matcher_test.rb
  179. +0 −44 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
  180. +0 −39 test/matchers/active_record/validate_format_of_matcher_test.rb
  181. +0 −52 test/matchers/active_record/validate_numericality_of_matcher_test.rb
  182. +0 −147 test/matchers/active_record/validate_uniqueness_of_matcher_test.rb
  183. +0 −55 test/matchers/controller/assign_to_matcher_test.rb
  184. +0 −40 test/matchers/controller/filter_param_matcher_test.rb
  185. +0 −37 test/matchers/controller/redirect_to_matcher_test.rb
  186. +0 −37 test/matchers/controller/render_template_matcher_test.rb
  187. +0 −47 test/matchers/controller/render_with_layout_matcher_test.rb
  188. +0 −32 test/matchers/controller/respond_with_content_type_matcher_test.rb
  189. +0 −96 test/matchers/controller/respond_with_matcher_test.rb
  190. +0 −75 test/matchers/controller/route_matcher_test.rb
  191. +0 −48 test/matchers/controller/set_session_matcher_test.rb
  192. +0 −95 test/matchers/controller/set_the_flash_matcher.rb
  193. +0 −18 test/other/autoload_macro_test.rb
  194. +0 −372 test/other/context_test.rb
  195. +0 −63 test/other/convert_to_should_syntax_test.rb
  196. +0 −126 test/other/helpers_test.rb
  197. +0 −271 test/other/should_test.rb
  198. +0 −28 test/rails3_root/Gemfile
  199. +0 −207 test/rspec_test.rb
  200. +0 −34 test/test_helper.rb
View
@@ -0,0 +1,2 @@
+---
+BUNDLE_DISABLE_SHARED_GEMS: "1"
View
@@ -0,0 +1,9 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.beta4'
+gem 'sqlite3-ruby', :require => 'sqlite3'
+gem 'mocha'
+gem 'rspec-rails', '2.0.0.beta.12'
+gem 'ruby-debug'
+gem 'cucumber'
+
View
@@ -0,0 +1,115 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.0.beta4)
+ actionpack (= 3.0.0.beta4)
+ mail (~> 2.2.3)
+ actionpack (3.0.0.beta4)
+ activemodel (= 3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.5)
+ i18n (~> 0.4.1)
+ rack (~> 1.1.0)
+ rack-mount (~> 0.6.3)
+ rack-test (~> 0.5.4)
+ tzinfo (~> 0.3.16)
+ activemodel (3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ builder (~> 2.1.2)
+ i18n (~> 0.4.1)
+ activerecord (3.0.0.beta4)
+ activemodel (= 3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ arel (~> 0.4.0)
+ tzinfo (~> 0.3.16)
+ activeresource (3.0.0.beta4)
+ activemodel (= 3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ activesupport (3.0.0.beta4)
+ arel (0.4.0)
+ activesupport (>= 3.0.0.beta)
+ builder (2.1.2)
+ columnize (0.3.1)
+ cucumber (0.9.4)
+ builder (~> 2.1.2)
+ diff-lcs (~> 1.1.2)
+ gherkin (~> 2.2.9)
+ json (~> 1.4.6)
+ term-ansicolor (~> 1.0.5)
+ diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ gherkin (2.2.9)
+ json (~> 1.4.6)
+ term-ansicolor (~> 1.0.5)
+ i18n (0.4.1)
+ json (1.4.6)
+ linecache (0.43)
+ mail (2.2.12)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mocha (0.9.10)
+ rake
+ nokogiri (1.4.4)
+ polyglot (0.3.1)
+ rack (1.1.0)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.6)
+ rack (>= 1.0)
+ rails (3.0.0.beta4)
+ actionmailer (= 3.0.0.beta4)
+ actionpack (= 3.0.0.beta4)
+ activerecord (= 3.0.0.beta4)
+ activeresource (= 3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ bundler (>= 0.9.26)
+ railties (= 3.0.0.beta4)
+ railties (3.0.0.beta4)
+ actionpack (= 3.0.0.beta4)
+ activesupport (= 3.0.0.beta4)
+ rake (>= 0.8.3)
+ thor (~> 0.13.6)
+ rake (0.8.7)
+ rspec (2.0.0.beta.12)
+ rspec-core (= 2.0.0.beta.12)
+ rspec-expectations (= 2.0.0.beta.12)
+ rspec-mocks (= 2.0.0.beta.12)
+ rspec-core (2.0.0.beta.12)
+ rspec-expectations (2.0.0.beta.12)
+ diff-lcs (>= 1.1.2)
+ rspec-mocks (2.0.0.beta.12)
+ rspec-rails (2.0.0.beta.12)
+ rspec (= 2.0.0.beta.12)
+ webrat (>= 0.7.0)
+ ruby-debug (0.10.3)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.3.0)
+ ruby-debug-base (0.10.3)
+ linecache (>= 0.3)
+ sqlite3-ruby (1.3.2)
+ term-ansicolor (1.0.5)
+ thor (0.13.8)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+ webrat (0.7.2)
+ nokogiri (>= 1.2.0)
+ rack (>= 1.0)
+ rack-test (>= 0.5.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ cucumber
+ mocha
+ rails (= 3.0.0.beta4)
+ rspec-rails (= 2.0.0.beta.12)
+ ruby-debug
+ sqlite3-ruby
View
@@ -1,25 +1,13 @@
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
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
$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'
-Rake::TestTask.new do |t|
- t.libs << 'lib' << 'test'
- t.pattern = test_files_pattern
- t.verbose = false
-end
Rake::RDocTask.new { |rdoc|
rdoc.rdoc_dir = 'doc'
@@ -29,11 +17,15 @@ Rake::RDocTask.new { |rdoc|
rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb')
}
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "spec/**/*_spec.rb"
+end
+
desc "Run code-coverage analysis using rcov"
-task :coverage do
- rm_rf "coverage"
- files = Dir[test_files_pattern]
- system "rcov --rails --sort coverage -Ilib #{files.join(' ')}"
+RSpec::Core::RakeTask.new(:coverage) do |t|
+ t.rcov = true
+ t.rcov_opts = %{--exclude osx\/objc,spec,gems\/ --failure-threshold 100}
+ t.pattern = "spec/**/*_spec.rb"
end
eval("$specification = begin; #{IO.read('shoulda.gemspec')}; end")
@@ -51,6 +43,6 @@ Cucumber::Rake::Task.new do |t|
t.profile = 'default'
end
-desc 'Default: run test and cucumber features for support versions'
-task :default => [:test, :cucumber]
+desc 'Default: run specs and cucumber features'
+task :default => [:spec, :cucumber]
@@ -1,42 +0,0 @@
-#!/usr/bin/env ruby
-require 'fileutils'
-require 'tmpdir'
-
-TMP = Dir::tmpdir
-
-def usage(msg = nil)
- puts "Error: #{msg}" if msg
- puts if msg
- puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb"
- puts
- puts "Will convert an existing test file with names like "
- puts
- puts " def test_should_do_stuff"
- puts " ..."
- puts " end"
- puts
- puts "to one using the new syntax: "
- puts
- puts " should \"be super cool\" do"
- puts " ..."
- puts " end"
- puts
- puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
- puts
- exit (msg ? 2 : 0)
-end
-
-usage("Wrong number of arguments.") unless ARGV.size == 1
-usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)
-
-file = ARGV.shift
-tmpfile = File.join(TMP, File.basename(file))
-usage("File '#{file}' doesn't exist") unless File.exists?(file)
-
-FileUtils.cp(file, tmpfile)
-contents = File.read(tmpfile)
-contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"}
-contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
-File.open(file, 'w') { |f| f.write(contents) }
-
-puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'"
@@ -29,7 +29,7 @@
end
When /^I configure the application to use rspec\-rails$/ do
- append_to_gemfile "gem 'rspec-rails', '>= 2.0.0.beta.12'"
+ append_to_gemfile "gem 'rspec-rails', '= 2.0.0.beta.12'"
steps %{And I run "bundle install"}
end
View
@@ -1 +0,0 @@
-require File.join(File.dirname(__FILE__), 'rails', 'init')
View
@@ -5,3 +5,4 @@
else
require 'shoulda/integrations/test_unit'
end
+
@@ -1,19 +1,39 @@
-require 'shoulda'
-require 'shoulda/action_controller/matchers'
+require 'shoulda/action_controller/assign_to_matcher'
+require 'shoulda/action_controller/filter_param_matcher'
+require 'shoulda/action_controller/set_the_flash_matcher'
+require 'shoulda/action_controller/render_with_layout_matcher'
+require 'shoulda/action_controller/respond_with_matcher'
+require 'shoulda/action_controller/respond_with_content_type_matcher'
+require 'shoulda/action_controller/set_session_matcher'
+require 'shoulda/action_controller/route_matcher'
+require 'shoulda/action_controller/redirect_to_matcher'
+require 'shoulda/action_controller/render_template_matcher'
-module Test # :nodoc: all
- module Unit
- class TestCase
- include Shoulda::ActionController::Matchers
- extend Shoulda::ActionController::Matchers
- end
- end
-end
+module Shoulda # :nodoc:
+ module ActionController # :nodoc:
-if defined?(ActionController::TestCase)
- class ActionController::TestCase
- def subject
- @controller
+ # By using the matchers you can quickly and easily create concise and
+ # easy to read test suites.
+ #
+ # This code segment:
+ #
+ # describe UsersController, "on GET to show with a valid id" do
+ # before(:each) do
+ # get :show, :id => User.first.to_param
+ # end
+ #
+ # it { should assign_to(:user) }
+ # it { should respond_with(:success) }
+ # it { should render_template(:show) }
+ # it { should not_set_the_flash) }
+ #
+ # it "should do something else really cool" do
+ # assigns[:user].id.should == 1
+ # end
+ # end
+ #
+ # Would produce 5 tests for the show action
+ module Matchers
end
end
end
@@ -0,0 +1,50 @@
+module Shoulda # :nodoc:
+ module ActionController # :nodoc:
+ module Matchers
+
+ # Ensures that filter_parameter_logging is set for the specified key.
+ #
+ # Example:
+ #
+ # it { should filter_param(:password) }
+ def filter_param(key)
+ FilterParamMatcher.new(key)
+ end
+
+ class FilterParamMatcher # :nodoc:
+
+ def initialize(key)
+ @key = key.to_s
+ end
+
+ def matches?(controller)
+ @controller = controller
+ filters_key?
+ end
+
+ def failure_message
+ "Expected #{@key} to be filtered; filtered keys: #{filtered_keys.join(', ')}"
+ end
+
+ def negative_failure_message
+ "Did not expect #{@key} to be filtered"
+ end
+
+ def description
+ "filter #{@key}"
+ end
+
+ private
+
+ def filters_key?
+ filtered_keys.include?(@key)
+ end
+
+ def filtered_keys
+ Rails.application.config.filter_parameters.map { |filter| filter.to_s }
+ end
+ end
+
+ end
+ end
+end
@@ -1,39 +0,0 @@
-require 'shoulda/action_controller/matchers/assign_to_matcher'
-require 'shoulda/action_controller/matchers/filter_param_matcher'
-require 'shoulda/action_controller/matchers/set_the_flash_matcher'
-require 'shoulda/action_controller/matchers/render_with_layout_matcher'
-require 'shoulda/action_controller/matchers/respond_with_matcher'
-require 'shoulda/action_controller/matchers/respond_with_content_type_matcher'
-require 'shoulda/action_controller/matchers/set_session_matcher'
-require 'shoulda/action_controller/matchers/route_matcher'
-require 'shoulda/action_controller/matchers/redirect_to_matcher'
-require 'shoulda/action_controller/matchers/render_template_matcher'
-
-module Shoulda # :nodoc:
- module ActionController # :nodoc:
-
- # By using the matchers you can quickly and easily create concise and
- # easy to read test suites.
- #
- # This code segment:
- #
- # describe UsersController, "on GET to show with a valid id" do
- # before(:each) do
- # get :show, :id => User.first.to_param
- # end
- #
- # it { should assign_to(:user) }
- # it { should respond_with(:success) }
- # it { should render_template(:show) }
- # it { should not_set_the_flash) }
- #
- # it "should do something else really cool" do
- # assigns[:user].id.should == 1
- # end
- # end
- #
- # Would produce 5 tests for the show action
- module Matchers
- end
- end
-end
Oops, something went wrong.

0 comments on commit ada334c

Please sign in to comment.