Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change to use rspec

  • Loading branch information...
commit 02fd5de273cc79608b0666838f6743d8fe9f674e 1 parent a6723dd
@mjankowski mjankowski authored
Showing with 783 additions and 585 deletions.
  1. +3 −3 .gitignore
  2. +8 −4 Gemfile
  3. +42 −0 Gemfile.lock
  4. +20 −22 MIT-LICENSE
  5. +4 −8 Rakefile
  6. +2 −0  gemfiles/rails-3.0.3-database-mysql.gemfile
  7. +41 −0 gemfiles/rails-3.0.3-database-mysql.gemfile.lock
  8. +2 −0  gemfiles/rails-3.0.3-database-mysql2.gemfile
  9. +41 −0 gemfiles/rails-3.0.3-database-mysql2.gemfile.lock
  10. +2 −0  gemfiles/rails-3.0.3-database-pg.gemfile
  11. +41 −0 gemfiles/rails-3.0.3-database-pg.gemfile.lock
  12. +2 −0  gemfiles/rails-3.0.3-database-sqlite3-ruby.gemfile
  13. +41 −0 gemfiles/rails-3.0.3-database-sqlite3-ruby.gemfile.lock
  14. +9 −9 test/associations_test.rb → spec/associations_spec.rb
  15. +30 −0 spec/boolean_spec.rb
  16. +85 −0 spec/datetime_spec.rb
  17. 0  {test → spec}/dummy/Rakefile
  18. 0  {test → spec}/dummy/app/controllers/application_controller.rb
  19. 0  {test → spec}/dummy/app/helpers/application_helper.rb
  20. 0  {test → spec}/dummy/app/models/article.rb
  21. 0  {test → spec}/dummy/app/models/comment.rb
  22. 0  {test → spec}/dummy/app/models/mammal.rb
  23. 0  {test → spec}/dummy/app/models/post.rb
  24. 0  {test → spec}/dummy/app/models/user.rb
  25. 0  {test → spec}/dummy/app/views/layouts/application.html.erb
  26. 0  {test → spec}/dummy/config.ru
  27. 0  {test → spec}/dummy/config/application.rb
  28. 0  {test → spec}/dummy/config/boot.rb
  29. 0  {test → spec}/dummy/config/database.yml
  30. 0  {test → spec}/dummy/config/environment.rb
  31. 0  {test → spec}/dummy/config/environments/development.rb
  32. 0  {test → spec}/dummy/config/environments/production.rb
  33. 0  {test → spec}/dummy/config/environments/test.rb
  34. 0  {test → spec}/dummy/config/initializers/backtrace_silencers.rb
  35. 0  {test → spec}/dummy/config/initializers/inflections.rb
  36. 0  {test → spec}/dummy/config/initializers/mime_types.rb
  37. +1 −1  {test → spec}/dummy/config/initializers/secret_token.rb
  38. 0  {test → spec}/dummy/config/initializers/session_store.rb
  39. 0  {test → spec}/dummy/config/locales/en.yml
  40. 0  {test → spec}/dummy/config/routes.rb
  41. 0  {test → spec}/dummy/db/migrate/20100419201348_create_schema.rb
  42. 0  {test → spec}/dummy/public/404.html
  43. 0  {test → spec}/dummy/public/422.html
  44. 0  {test → spec}/dummy/public/500.html
  45. 0  {test → spec}/dummy/public/favicon.ico
  46. 0  {test → spec}/dummy/public/javascripts/application.js
  47. 0  {test → spec}/dummy/public/javascripts/controls.js
  48. 0  {test → spec}/dummy/public/javascripts/dragdrop.js
  49. 0  {test → spec}/dummy/public/javascripts/effects.js
  50. 0  {test → spec}/dummy/public/javascripts/prototype.js
  51. 0  {test → spec}/dummy/public/javascripts/rails.js
  52. 0  {test → spec}/dummy/public/stylesheets/.gitkeep
  53. 0  {test → spec}/dummy/script/rails
  54. +22 −0 spec/duration_spec.rb
  55. 0  {test → spec}/factories.rb
  56. +49 −0 spec/helpers_spec.rb
  57. +9 −0 spec/integration/navigation_spec.rb
  58. +25 −0 spec/limit_spec.rb
  59. +43 −0 spec/numeric_spec.rb
  60. +22 −0 spec/order_spec.rb
  61. +7 −0 spec/pacecar_spec.rb
  62. +18 −0 spec/polymorph_spec.rb
  63. +23 −0 spec/presence_spec.rb
  64. +21 −0 spec/ranking_spec.rb
  65. +63 −0 spec/search_spec.rb
  66. +38 −0 spec/spec_helper.rb
  67. +69 −0 spec/state_spec.rb
  68. 0  {test → spec}/test_helper.rb
  69. +0 −30 test/boolean_test.rb
  70. +0 −83 test/datetime_test.rb
  71. +0 −5 test/dummy/config/initializers/run_migrations.rb
  72. +0 −42 test/dummy/db/schema.rb
  73. +0 −22 test/duration_test.rb
  74. +0 −51 test/helpers_test.rb
  75. +0 −7 test/integration/navigation_test.rb
  76. +0 −25 test/limit_test.rb
  77. +0 −43 test/numeric_test.rb
  78. +0 −22 test/order_test.rb
  79. +0 −9 test/pacecar_test.rb
  80. +0 −18 test/polymorph_test.rb
  81. +0 −23 test/presence_test.rb
  82. +0 −21 test/ranking_test.rb
  83. +0 −63 test/search_test.rb
  84. +0 −69 test/state_test.rb
  85. +0 −5 test/support/integration_case.rb
View
6 .gitignore
@@ -1,6 +1,6 @@
.bundle/
log/*.log
pkg/
-test/dummy/db/*.sqlite3
-test/dummy/log/*.log
-test/dummy/tmp/
+spec/dummy/db/*.sqlite3
+spec/dummy/log/*.log
+spec/dummy/tmp/
View
12 Gemfile
@@ -1,7 +1,11 @@
-source 'http://rubygems.org'
+source "http://rubygems.org"
-gem 'appraisal'
+gem "appraisal"
+gem "rails", "3.0.3"
+gem "capybara", ">= 0.4.0"
+# gem "sqlite3-ruby", :require => "sqlite3"
-gem 'mocha'
+gem "mocha"
+gem "rspec-rails", ">= 2.4.0"
-gem 'factory_girl_rails'
+gem "factory_girl_rails"
View
42 Gemfile.lock
@@ -33,13 +33,30 @@ GEM
rake
arel (2.0.6)
builder (2.1.2)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.7)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.2)
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
i18n (0.5.0)
+ json_pure (1.4.6)
mail (2.2.12)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -48,6 +65,7 @@ GEM
mime-types (1.16)
mocha (0.9.10)
rake
+ nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
@@ -68,15 +86,39 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ rspec-rails (2.4.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.4.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
appraisal
+ capybara (>= 0.4.0)
factory_girl_rails
mocha
+ rails (= 3.0.3)
+ rspec-rails (>= 2.4.0)
View
42 MIT-LICENSE
@@ -1,22 +1,20 @@
-Copyright (c) 2008, Matt Jankowski & thoughtbot, inc.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
+Copyright (c) 2008, Matt Jankowski & thoughtbot, inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
12 Rakefile
@@ -9,18 +9,14 @@ end
require 'rake'
require 'rake/rdoctask'
-require 'rake/testtask'
+require 'rspec/core'
+require 'rspec/core/rake_task'
require 'appraisal'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = false
-end
+RSpec::Core::RakeTask.new(:spec)
-task :default => :test
+task :default => :spec
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
View
2  gemfiles/rails-3.0.3-database-mysql.gemfile
@@ -3,6 +3,8 @@
source "http://rubygems.org"
gem "rails", "3.0.3"
gem "mysql"
+gem "rspec-rails", ">= 2.4.0"
gem "mocha"
gem "appraisal"
+gem "capybara", ">= 0.4.0"
gem "factory_girl_rails"
View
41 gemfiles/rails-3.0.3-database-mysql.gemfile.lock
@@ -33,13 +33,30 @@ GEM
rake
arel (2.0.7)
builder (2.1.2)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.7)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
i18n (0.5.0)
+ json_pure (1.4.6)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -49,6 +66,7 @@ GEM
mocha (0.9.10)
rake
mysql (2.8.1)
+ nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
@@ -69,17 +87,40 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ rspec-rails (2.4.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.4.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
appraisal
+ capybara (>= 0.4.0)
factory_girl_rails
mocha
mysql
rails (= 3.0.3)
+ rspec-rails (>= 2.4.0)
View
2  gemfiles/rails-3.0.3-database-mysql2.gemfile
@@ -2,7 +2,9 @@
source "http://rubygems.org"
gem "rails", "3.0.3"
+gem "rspec-rails", ">= 2.4.0"
gem "mocha"
gem "mysql2"
gem "appraisal"
+gem "capybara", ">= 0.4.0"
gem "factory_girl_rails"
View
41 gemfiles/rails-3.0.3-database-mysql2.gemfile.lock
@@ -33,13 +33,30 @@ GEM
rake
arel (2.0.7)
builder (2.1.2)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.7)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
i18n (0.5.0)
+ json_pure (1.4.6)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -49,6 +66,7 @@ GEM
mocha (0.9.10)
rake
mysql2 (0.2.6)
+ nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
@@ -69,17 +87,40 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ rspec-rails (2.4.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.4.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
appraisal
+ capybara (>= 0.4.0)
factory_girl_rails
mocha
mysql2
rails (= 3.0.3)
+ rspec-rails (>= 2.4.0)
View
2  gemfiles/rails-3.0.3-database-pg.gemfile
@@ -3,6 +3,8 @@
source "http://rubygems.org"
gem "pg"
gem "rails", "3.0.3"
+gem "rspec-rails", ">= 2.4.0"
gem "mocha"
gem "appraisal"
+gem "capybara", ">= 0.4.0"
gem "factory_girl_rails"
View
41 gemfiles/rails-3.0.3-database-pg.gemfile.lock
@@ -33,13 +33,30 @@ GEM
rake
arel (2.0.7)
builder (2.1.2)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.7)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
i18n (0.5.0)
+ json_pure (1.4.6)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -48,6 +65,7 @@ GEM
mime-types (1.16)
mocha (0.9.10)
rake
+ nokogiri (1.4.4)
pg (0.10.1)
polyglot (0.3.1)
rack (1.2.1)
@@ -69,17 +87,40 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ rspec-rails (2.4.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.4.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
appraisal
+ capybara (>= 0.4.0)
factory_girl_rails
mocha
pg
rails (= 3.0.3)
+ rspec-rails (>= 2.4.0)
View
2  gemfiles/rails-3.0.3-database-sqlite3-ruby.gemfile
@@ -3,6 +3,8 @@
source "http://rubygems.org"
gem "rails", "3.0.3"
gem "sqlite3-ruby"
+gem "rspec-rails", ">= 2.4.0"
gem "mocha"
gem "appraisal"
+gem "capybara", ">= 0.4.0"
gem "factory_girl_rails"
View
41 gemfiles/rails-3.0.3-database-sqlite3-ruby.gemfile.lock
@@ -33,13 +33,30 @@ GEM
rake
arel (2.0.7)
builder (2.1.2)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.7)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
i18n (0.5.0)
+ json_pure (1.4.6)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -48,6 +65,7 @@ GEM
mime-types (1.16)
mocha (0.9.10)
rake
+ nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
@@ -68,6 +86,25 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ rspec-rails (2.4.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.4.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
@@ -75,13 +112,17 @@ GEM
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
appraisal
+ capybara (>= 0.4.0)
factory_girl_rails
mocha
rails (= 3.0.3)
+ rspec-rails (>= 2.4.0)
sqlite3-ruby
View
18 test/associations_test.rb → spec/associations_spec.rb
@@ -1,8 +1,8 @@
-require 'test_helper'
+require 'spec_helper'
-class AssociationsTest < ActiveSupport::TestCase
+describe 'Associations' do
- setup do
+ before do
@comment_user = Factory :user
@post_user = Factory :user
@both_user = Factory :user
@@ -17,16 +17,16 @@ class AssociationsTest < ActiveSupport::TestCase
Factory :post, :owner => @both_user, :created_at => 3.days.ago
end
- test "set the correct options for a recent methods for one association" do
- assert_equal [@comment_user, @both_user], User.recent_comments_since(5.days.ago)
+ it "should set the correct options for a recent methods for one association" do
+ User.recent_comments_since(5.days.ago).should == [@comment_user, @both_user]
end
- test "set the correct options for a recent methods combining associations with or" do
- assert_equal [@comment_user, @post_user, @both_user], User.recent_posts_or_comments_since(5.days.ago)
+ it "should set the correct options for a recent methods combining associations with or" do
+ User.recent_posts_or_comments_since(5.days.ago).should == [@comment_user, @post_user, @both_user]
end
- test "set the correct options for a recent methods combining associations with and" do
- assert_equal [@both_user], User.recent_posts_and_comments_since(5.days.ago)
+ it "should set the correct options for a recent methods combining associations with and" do
+ User.recent_posts_and_comments_since(5.days.ago).should == [@both_user]
end
end
View
30 spec/boolean_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe 'Boolean' do
+
+ before do
+ @one = Factory :user, :admin => true
+ @two = Factory :user, :admin => true
+ @three = Factory :user, :admin => true
+ @four = Factory :user, :admin => false
+ @five = Factory :user, :admin => false
+ end
+
+ it "should set the correct expected values for a boolean column method" do
+ User.admin.should == [@one, @two, @three]
+ end
+
+ it "should set the correct expected values for a not_ boolean column method" do
+ User.not_admin.should == [@four, @five]
+ end
+
+ it "should return correct value for balance class method when true greater than false" do
+ User.admin_balance.should == 1
+ end
+
+ it "should return correct value for balance class method when true less than false" do
+ 3.times { Factory :user, :admin => false }
+ User.admin_balance.should == -2
+ end
+
+end
View
85 spec/datetime_spec.rb
@@ -0,0 +1,85 @@
+require 'spec_helper'
+
+describe 'Datetime' do
+
+ before do
+ date = DateTime.parse '2000-01-01'
+ @abe = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+
+ date = DateTime.parse '2005-05-05'
+ @bob = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+
+ date = DateTime.parse '2010-10-10'
+ @fox = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+ end
+
+ [:created_at, :rejected_at, :updated_at, :last_posted_on, :approved_at].each do |column|
+ it "should set the correct expected values for a #{column}_before method" do
+ date = DateTime.parse '2003-01-01'
+ User.send(:"#{column}_before", date).should == [@abe]
+ end
+
+ it "should set the correct expected values for a #{column}_after datetime column method" do
+ date = DateTime.parse '2007-01-01'
+ User.send(:"#{column}_after", date).should == [@fox]
+ end
+
+ it "should set the correct expected values for a #{column}_in_past method without a zone default" do
+ Time.zone_default = nil
+ Time.zone_default.should == nil
+ now = DateTime.parse '2007-01-01'
+ User.stubs(:now).returns now
+ User.send(:"#{column}_in_past").should == [@abe, @bob]
+ end
+
+ it "should set the correct expected values for a #{column}_in_future datetime column method without a zone default" do
+ Time.zone_default = nil
+ Time.zone_default.should == nil
+ now = DateTime.parse '2007-01-01'
+ User.stubs(:now).returns now
+ User.send(:"#{column}_in_future").should == [@fox]
+ end
+
+ it "should set the correct expected values for a #{column}_in_past method given a zone_default" do
+ Time.zone_default = Time.__send__(:get_zone, "UTC")
+ now = DateTime.parse '2007-01-01'
+ Time.zone_default.stubs(:now).returns now
+ User.send(:"#{column}_in_past").should == [@abe, @bob]
+ Time.zone_default = nil
+ end
+
+ it "should set the correct expected values for a #{column}_in_future datetime column method given a zone_default" do
+ Time.zone_default = Time.__send__(:get_zone, "UTC")
+ now = DateTime.parse '2007-01-01'
+ Time.zone_default.stubs(:now).returns now
+ User.send(:"#{column}_in_future").should == [@fox]
+ Time.zone_default = nil
+ end
+
+ it "should set the correct expected values for a #{column}_inside method" do
+ start = DateTime.parse '2003-01-01'
+ stop = DateTime.parse '2007-01-01'
+ User.send(:"#{column}_inside", start, stop).should == [@bob]
+ end
+
+ it "should set the correct expected values for a #{column}_outside method" do
+ start = DateTime.parse '2003-01-01'
+ stop = DateTime.parse '2007-01-01'
+ User.send(:"#{column}_outside", start, stop).should == [@abe, @fox]
+ end
+
+ it "should set the correct expected values for a #{column}_in_year method" do
+ User.send(:"#{column}_in_year", '2000').should == [@abe]
+ end
+
+ it "should set the correct expected values for a #{column}_in_month method" do
+ User.send(:"#{column}_in_month", '05').should == [@bob]
+ end
+
+ it "should set the correct expected values for a #{column}_in_day method" do
+ User.send(:"#{column}_in_day", '10').should == [@fox]
+ end
+
+ end
+
+end
View
0  test/dummy/Rakefile → spec/dummy/Rakefile
File renamed without changes
View
0  ...app/controllers/application_controller.rb → ...app/controllers/application_controller.rb
File renamed without changes
View
0  test/dummy/app/helpers/application_helper.rb → spec/dummy/app/helpers/application_helper.rb
File renamed without changes
View
0  test/dummy/app/models/article.rb → spec/dummy/app/models/article.rb
File renamed without changes
View
0  test/dummy/app/models/comment.rb → spec/dummy/app/models/comment.rb
File renamed without changes
View
0  test/dummy/app/models/mammal.rb → spec/dummy/app/models/mammal.rb
File renamed without changes
View
0  test/dummy/app/models/post.rb → spec/dummy/app/models/post.rb
File renamed without changes
View
0  test/dummy/app/models/user.rb → spec/dummy/app/models/user.rb
File renamed without changes
View
0  ...my/app/views/layouts/application.html.erb → ...my/app/views/layouts/application.html.erb
File renamed without changes
View
0  test/dummy/config.ru → spec/dummy/config.ru
File renamed without changes
View
0  test/dummy/config/application.rb → spec/dummy/config/application.rb
File renamed without changes
View
0  test/dummy/config/boot.rb → spec/dummy/config/boot.rb
File renamed without changes
View
0  test/dummy/config/database.yml → spec/dummy/config/database.yml
File renamed without changes
View
0  test/dummy/config/environment.rb → spec/dummy/config/environment.rb
File renamed without changes
View
0  .../dummy/config/environments/development.rb → .../dummy/config/environments/development.rb
File renamed without changes
View
0  test/dummy/config/environments/production.rb → spec/dummy/config/environments/production.rb
File renamed without changes
View
0  test/dummy/config/environments/test.rb → spec/dummy/config/environments/test.rb
File renamed without changes
View
0  ...onfig/initializers/backtrace_silencers.rb → ...onfig/initializers/backtrace_silencers.rb
File renamed without changes
View
0  .../dummy/config/initializers/inflections.rb → .../dummy/config/initializers/inflections.rb
File renamed without changes
View
0  test/dummy/config/initializers/mime_types.rb → spec/dummy/config/initializers/mime_types.rb
File renamed without changes
View
2  ...dummy/config/initializers/secret_token.rb → ...dummy/config/initializers/secret_token.rb
@@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-Dummy::Application.config.secret_token = '513e6767391489274e2294d66792d5d4b13b939227783f15902a64fb647b9fc2781675ac575b454d9c4af6ff400e845ce20204b345280f8218c0510aafa9e3ef'
+Dummy::Application.config.secret_token = 'c3cd37229cbffa5cac592d2d511a60bc1cbd27ac529f49894372c39a6e08c2f99ff7a5eecbeb13533c6aa08f37639a94453f2c1c761bdbdd91c2c4c4ffa2faf8'
View
0  ...ummy/config/initializers/session_store.rb → ...ummy/config/initializers/session_store.rb
File renamed without changes
View
0  test/dummy/config/locales/en.yml → spec/dummy/config/locales/en.yml
File renamed without changes
View
0  test/dummy/config/routes.rb → spec/dummy/config/routes.rb
File renamed without changes
View
0  ...b/migrate/20100419201348_create_schema.rb → ...b/migrate/20100419201348_create_schema.rb
File renamed without changes
View
0  test/dummy/public/404.html → spec/dummy/public/404.html
File renamed without changes
View
0  test/dummy/public/422.html → spec/dummy/public/422.html
File renamed without changes
View
0  test/dummy/public/500.html → spec/dummy/public/500.html
File renamed without changes
View
0  test/dummy/public/favicon.ico → spec/dummy/public/favicon.ico
File renamed without changes
View
0  test/dummy/public/javascripts/application.js → spec/dummy/public/javascripts/application.js
File renamed without changes
View
0  test/dummy/public/javascripts/controls.js → spec/dummy/public/javascripts/controls.js
File renamed without changes
View
0  test/dummy/public/javascripts/dragdrop.js → spec/dummy/public/javascripts/dragdrop.js
File renamed without changes
View
0  test/dummy/public/javascripts/effects.js → spec/dummy/public/javascripts/effects.js
File renamed without changes
View
0  test/dummy/public/javascripts/prototype.js → spec/dummy/public/javascripts/prototype.js
File renamed without changes
View
0  test/dummy/public/javascripts/rails.js → spec/dummy/public/javascripts/rails.js
File renamed without changes
View
0  test/dummy/public/stylesheets/.gitkeep → spec/dummy/public/stylesheets/.gitkeep
File renamed without changes
View
0  test/dummy/script/rails → spec/dummy/script/rails
File renamed without changes
View
22 spec/duration_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'Duration' do
+
+ before do
+ @same_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 15.days.ago.midnight
+ @updated_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 1.days.ago.midnight
+ end
+
+ it "should set the correct expected values for a with_duration_of datetime column method" do
+ User.with_duration_of(14, :created_at, :updated_at).should == [@updated_user]
+ end
+
+ it "should set the correct expected values for a with_duration_over datetime column method" do
+ User.with_duration_over(10, :created_at, :updated_at).should == [@updated_user]
+ end
+
+ it "should set the correct expected values for a with_duration_under datetime column method" do
+ User.with_duration_under(10, :created_at, :updated_at).should == [@same_user]
+ end
+
+end
View
0  test/factories.rb → spec/factories.rb
File renamed without changes
View
49 spec/helpers_spec.rb
@@ -0,0 +1,49 @@
+require 'spec_helper'
+
+describe 'Helpers' do
+
+ it "should A class without a db table should return an empty array when asked about #safe_columns" do
+ columns = Article.send :safe_columns
+ columns.should == []
+ end
+
+ it "should A class without a db table should survive an include of Pacecar" do
+ lambda { Article.send :include, Pacecar }.should_not raise_error
+ end
+
+ it "should A class with a db table should return columns for #safe_column_names" do
+ column_names = Comment.safe_column_names
+ column_names.should == ['id', 'user_id', 'description', 'created_at', 'updated_at']
+ end
+
+ it "should A class with many column types should return boolean columns for #boolean_column_names" do
+ column_names = User.boolean_column_names
+ column_names.should == ['admin']
+ end
+
+ it "should A class with many column types should return non boolean columns for #non_boolean_column_names" do
+ column_names = User.non_boolean_column_names
+ column_names.should == ['id', 'approved_at', 'rejected_at', 'last_posted_on', 'first_name', 'last_name', 'description', 'age', 'rating', 'created_at', 'updated_at']
+ end
+
+ it "should A class with many column types should return datetime columns for #datetime_column_names" do
+ column_names = User.datetime_column_names
+ column_names.should == ['approved_at', 'rejected_at', 'last_posted_on', 'created_at', 'updated_at']
+ end
+
+ it "should A class with many column types should return text and string columns for #text_and_string_column_names" do
+ column_names = User.text_and_string_column_names
+ column_names.should == ['first_name', 'last_name', 'description']
+ end
+
+ it "should A class with many column types should return numeric columns for #numeric_column_names" do
+ column_names = User.numeric_column_names
+ column_names.should == ['id', 'age', 'rating']
+ end
+
+ it "should A class with a state column should return all non state text and string columns for #non_state_text_and_string_column_names" do
+ column_names = Post.non_state_text_and_string_columns
+ column_names.should == ['title', 'body']
+ end
+
+end
View
9 spec/integration/navigation_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe "Navigation" do
+ include Capybara
+
+ it "should be a valid app" do
+ ::Rails.application.should be_a(Dummy::Application)
+ end
+end
View
25 spec/limit_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe 'Limit' do
+
+ before do
+ 50.times { Factory :user }
+ end
+
+ it "should set the correct expected values for a by_ column method" do
+ User.count.should == 50
+ User.limited.all.size.should == 10
+ end
+
+ it "should set the correct expected values for a by_ column method when sent args" do
+ User.count.should == 50
+ User.limited(20).all.size.should == 20
+ end
+
+ it "should set the correct expected values for a by_ column method when per_page defined" do
+ User.expects(:per_page).returns 30
+ User.count.should == 50
+ User.limited.all.size.should == 30
+ end
+
+end
View
43 spec/numeric_spec.rb
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+describe 'Numeric' do
+
+ before do
+ @young = Factory :user, :age => 11, :rating => 10.0
+ @legal = Factory :user, :age => 21, :rating => 7.5
+ @older = Factory :user, :age => 31, :rating => 5.0
+ end
+
+ it "should set the correct expected values for a _greater_than column method for an integer column" do
+ User.age_greater_than(21).should == [@older]
+ end
+
+ it "should set the correct expected values for a _greater_than_or_equal_to column method for an integer column" do
+ User.age_greater_than_or_equal_to(21).should == [@legal, @older]
+ end
+
+ it "should set the correct expected values for a _less_than column method for an integer column" do
+ User.age_less_than(21).should == [@young]
+ end
+
+ it "should set the correct expected values for a _less_than_or_equal_to column method for an integer column" do
+ User.age_less_than_or_equal_to(21).should == [@young, @legal]
+ end
+
+ it "should set the correct expected values for a _greater_than column method for a float column" do
+ User.rating_greater_than(7.5).should == [@young]
+ end
+
+ it "should set the correct expected values for a _greater_than_or_equal_to column method for a float column" do
+ User.rating_greater_than_or_equal_to(7.5).should == [@young, @legal]
+ end
+
+ it "should set the correct expected values for a _less_than column method for a float column" do
+ User.rating_less_than(7.5).should == [@older]
+ end
+
+ it "should set the correct expected values for a _less_than_or_equal_to column method for a float column" do
+ User.rating_less_than_or_equal_to(7.5).should == [@legal, @older]
+ end
+
+end
View
22 spec/order_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'Order' do
+
+ before do
+ @first = Factory :user, :first_name => 'Abe'
+ @last = Factory :user, :first_name => 'Zed'
+ end
+
+ it "should set the correct expected values for a by_ column method with no args" do
+ User.by_first_name.should == [@first, @last]
+ end
+
+ it "should set the correct expected values for a by_ column method with asc args" do
+ User.by_first_name(:asc).should == [@first, @last]
+ end
+
+ it "should set the correct expected values for a by_ column method with desc args" do
+ User.by_first_name(:desc).should == [@last, @first]
+ end
+
+end
View
7 spec/pacecar_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper'
+
+describe Pacecar do
+ it "should be valid" do
+ Pacecar.should be_a(Module)
+ end
+end
View
18 spec/polymorph_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe 'Polymorph' do
+
+ before do
+ @owned_by_user = Factory :post, :owner_type => 'User'
+ @owned_by_mammal = Factory :post, :owner_type => 'Mammal'
+ end
+
+ it "should set the correct expected values on a _for column method with Class" do
+ Post.for_owner_type(User).should == [@owned_by_user]
+ end
+
+ it "should set the correct expected values on a _for column method with String" do
+ Post.for_owner_type('User').should == [@owned_by_user]
+ end
+
+end
View
23 spec/presence_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'Presence' do
+
+ before do
+ @not_null = Factory :user, :first_name => 'Fake'
+ @null = Factory :user, :first_name => nil
+ end
+
+ it "should set the correct expected values for a _present column method" do
+ User.first_name_present.should == [@not_null]
+ end
+
+ it "should set the correct expected values for a _missing column method" do
+ User.first_name_missing.should == [@null]
+ end
+
+ it "should not setup methods for boolean columns" do
+ lambda { User.admin_missing }.should raise_error(NoMethodError)
+ lambda { User.admin_present }.should raise_error(NoMethodError)
+ end
+
+end
View
21 spec/ranking_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'Ranking' do
+
+ before do
+ @many = Factory :user
+ 5.times { Factory :comment, :user => @many }
+ @few = Factory :user
+ 2.times { Factory :comment, :user => @few }
+ @none = Factory :user
+ end
+
+ it "should set the correct expected values on a maximum_ column method" do
+ User.maximum_comments.should == [@many, @few]
+ end
+
+ it "should set the correct expected values on a minimum_ column method" do
+ User.minimum_comments.should == [@few, @many]
+ end
+
+end
View
63 spec/search_spec.rb
@@ -0,0 +1,63 @@
+require 'spec_helper'
+
+describe 'Search' do
+
+ before do
+ @abe = Factory :user, :first_name => 'Abe', :last_name => 'Anderson', :description => 'Apple'
+ @bob = Factory :user, :first_name => 'Bob', :last_name => 'Babson', :description => 'Banana'
+ @cindy = Factory :user, :first_name => 'Cindy', :last_name => 'Clarkson', :description => 'Cookie'
+ @dave = Factory :user, :first_name => 'Dave'
+ @ed = Factory :user, :last_name => 'Dave'
+ @frank = Factory :user, :description => 'Dave'
+ @george = Factory :user, :first_name => 'Dave', :last_name => 'Dave', :description => 'Dave'
+
+ @null = Factory :user, :first_name => nil, :last_name => nil, :description => nil
+ end
+
+ it "should set the correct expected values for a _equals column method" do
+ User.first_name_equals('Abe').should == [@abe]
+ end
+
+ it "should set the correct expected values for a _equals column method with an Array as value" do
+ User.first_name_equals(['Abe', 'Bob']).should == [@abe, @bob]
+ end
+
+ it "should set the correct expected values for a _equals column method with nil as value" do
+ User.first_name_equals(nil).should == [@ed, @frank, @null]
+ end
+
+ it "should set the correct expected values for a _matches column method" do
+ User.first_name_matches('ind').should == [@cindy]
+ User.first_name_matches('IND').should == [@cindy]
+ end
+
+ it "should set the correct expected values for a _starts_with column method" do
+ User.first_name_starts_with('Ab').should == [@abe]
+ User.first_name_starts_with('aB').should == [@abe]
+ end
+
+ it "should set the correct expected values for a _ends_with column method" do
+ User.first_name_ends_with('ob').should == [@bob]
+ User.first_name_ends_with('Ob').should == [@bob]
+ end
+
+ it "should set the correct expected values for a search_for method" do
+ User.search_for('Dave').should == [@dave, @ed, @frank, @george]
+ User.search_for('dave').should == [@dave, @ed, @frank, @george]
+ end
+
+ it "should set the correct expected values for a search_for method with :on option" do
+ User.search_for('Dave', :on => [:first_name, :description]).should == [@dave, @frank, @george]
+ User.search_for('dave', :on => [:first_name, :description]).should == [@dave, @frank, @george]
+ end
+
+ it "should set the correct expected values for a search_for method with an :require option" do
+ User.search_for('Dave', :require => :all).should == [@george]
+ User.search_for('dave', :require => :all).should == [@george]
+ end
+
+ it "should set the correct expected values for a search_for method on a class with no columns" do
+ Mammal.search_for('test').should == []
+ end
+
+end
View
38 spec/spec_helper.rb
@@ -0,0 +1,38 @@
+# Configure Rails Envinronment
+ENV["RAILS_ENV"] = "test"
+
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
+require "rails/test_help"
+require "rspec/rails"
+
+ActionMailer::Base.delivery_method = :test
+ActionMailer::Base.perform_deliveries = true
+ActionMailer::Base.default_url_options[:host] = "test.com"
+
+Rails.backtrace_cleaner.remove_silencers!
+
+# Configure capybara for integration testing
+require "capybara/rails"
+Capybara.default_driver = :rack_test
+Capybara.default_selector = :css
+
+# Run any available migration
+ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
+
+# Load support files
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
+
+RSpec.configure do |config|
+ # Remove this line if you don't want RSpec's should and should_not
+ # methods or matchers
+ require 'rspec/expectations'
+ config.include RSpec::Matchers
+
+ # == Mock Framework
+ config.mock_with :mocha
+
+ config.use_transactional_fixtures = true
+end
+
+require 'factory_girl'
+require 'spec/factories'
View
69 spec/state_spec.rb
@@ -0,0 +1,69 @@
+require 'spec_helper'
+
+describe 'State' do
+
+ before do
+ @draft_post = Factory :post, :publication_state => 'Draft'
+ @final_post = Factory :post, :publication_state => 'Final'
+ @free_post = Factory :post, :post_type => 'Free'
+ @open_post = Factory :post, :post_type => 'Open'
+
+ @post = Post.new
+ Post::PUBLICATION_STATES.should_not be_nil
+ end
+
+ it "should set the correct expected values for a column_state _state method" do
+ Post.publication_state_draft.should == [@draft_post]
+ end
+
+ it "should set the correct expected values for a column_not_state _state method" do
+ Post.publication_state_not_draft.should == [@final_post]
+ end
+
+ it "should set the correct expected values for a column_state _type method" do
+ Post.post_type_free.should == [@free_post]
+ end
+
+ it "should set the correct expected values for a column_not_state _type method" do
+ Post.post_type_not_free.should == [@open_post]
+ end
+
+ it "should set the correct expected values for a column_state method" do
+ Post.post_type('Open').should == [@open_post]
+ end
+
+ it "should set the correct expected values for a column_state_not method" do
+ Post.post_type_not('Open').should == [@free_post]
+ end
+
+ Post::PUBLICATION_STATES.each do |state|
+ it "should have a query method for a #{state} state value" do
+ @post.should respond_to("publication_state_#{state.downcase}?")
+ end
+
+ it "should have a non query method for a #{state} state value" do
+ @post.should respond_to("publication_state_not_#{state.downcase}?")
+ end
+
+ it "should respond true to query method for a #{state} state value when in that state" do
+ @post.publication_state = state
+ @post.send("publication_state_#{state.downcase}?").should be_true
+ end
+
+ it "should respond false to not query method for a #{state} state value when in that state" do
+ @post.publication_state = state
+ @post.send("publication_state_not_#{state.downcase}?").should be_false
+ end
+
+ it "should respond false to query method for a #{state} state value when not in that state" do
+ @post.publication_state = 'Invalid'
+ @post.send("publication_state_#{state.downcase}?").should be_false
+ end
+
+ it "should respond true to not query method for a #{state} state value when not in that state" do
+ @post.publication_state = 'Invalid'
+ @post.send("publication_state_not_#{state.downcase}?").should be_true
+ end
+ end
+
+end
View
0  test/test_helper.rb → spec/test_helper.rb
File renamed without changes
View
30 test/boolean_test.rb
@@ -1,30 +0,0 @@
-require 'test_helper'
-
-class BooleanTest < ActiveSupport::TestCase
-
- setup do
- @one = Factory :user, :admin => true
- @two = Factory :user, :admin => true
- @three = Factory :user, :admin => true
- @four = Factory :user, :admin => false
- @five = Factory :user, :admin => false
- end
-
- test "set the correct expected values for a boolean column method" do
- assert_equal [@one, @two, @three], User.admin
- end
-
- test "set the correct expected values for a not_ boolean column method" do
- assert_equal [@four, @five], User.not_admin
- end
-
- test "return correct value for balance class method when true greater than false" do
- assert_equal 1, User.admin_balance
- end
-
- test "return correct value for balance class method when true less than false" do
- 3.times { Factory :user, :admin => false }
- assert_equal -2, User.admin_balance
- end
-
-end
View
83 test/datetime_test.rb
@@ -1,83 +0,0 @@
-require 'test_helper'
-
-class DatetimeTest < ActiveSupport::TestCase
-
- setup do
- date = DateTime.parse '2000-01-01'
- @abe = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
-
- date = DateTime.parse '2005-05-05'
- @bob = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
-
- date = DateTime.parse '2010-10-10'
- @fox = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
- end
-
- [:created_at, :rejected_at, :updated_at, :last_posted_on, :approved_at].each do |column|
- test "set the correct expected values for a #{column}_before method" do
- date = DateTime.parse '2003-01-01'
- assert_equal [@abe], User.send(:"#{column}_before", date)
- end
-
- test "set the correct expected values for a #{column}_after datetime column method" do
- date = DateTime.parse '2007-01-01'
- assert_equal [@fox], User.send(:"#{column}_after", date)
- end
-
- test "set the correct expected values for a #{column}_in_past method without a zone default" do
- assert_nil Time.zone_default
- now = DateTime.parse '2007-01-01'
- User.stubs(:now).returns now
- assert_equal [@abe, @bob], User.send(:"#{column}_in_past")
- end
-
- test "set the correct expected values for a #{column}_in_future datetime column method without a zone default" do
- assert_nil Time.zone_default
- now = DateTime.parse '2007-01-01'
- User.stubs(:now).returns now
- assert_equal [@fox], User.send(:"#{column}_in_future")
- end
-
- test "set the correct expected values for a #{column}_in_past method given a zone_default" do
- Time.zone_default = Time.__send__(:get_zone, "UTC")
- now = DateTime.parse '2007-01-01'
- Time.zone_default.stubs(:now).returns now
- assert_equal [@abe, @bob], User.send(:"#{column}_in_past")
- Time.zone_default = nil
- end
-
- test "set the correct expected values for a #{column}_in_future datetime column method given a zone_default" do
- Time.zone_default = Time.__send__(:get_zone, "UTC")
- now = DateTime.parse '2007-01-01'
- Time.zone_default.stubs(:now).returns now
- assert_equal [@fox], User.send(:"#{column}_in_future")
- Time.zone_default = nil
- end
-
- test "set the correct expected values for a #{column}_inside method" do
- start = DateTime.parse '2003-01-01'
- stop = DateTime.parse '2007-01-01'
- assert_equal [@bob], User.send(:"#{column}_inside", start, stop)
- end
-
- test "set the correct expected values for a #{column}_outside method" do
- start = DateTime.parse '2003-01-01'
- stop = DateTime.parse '2007-01-01'
- assert_equal [@abe, @fox], User.send(:"#{column}_outside", start, stop)
- end
-
- test "set the correct expected values for a #{column}_in_year method" do
- assert_equal [@abe], User.send(:"#{column}_in_year", '2000')
- end
-
- test "set the correct expected values for a #{column}_in_month method" do
- assert_equal [@bob], User.send(:"#{column}_in_month", '05')
- end
-
- test "set the correct expected values for a #{column}_in_day method" do
- assert_equal [@fox], User.send(:"#{column}_in_day", '10')
- end
-
- end
-
-end
View
5 test/dummy/config/initializers/run_migrations.rb
@@ -1,5 +0,0 @@
-# Delete DB from previous runs for sqlite3
-FileUtils.rm File.expand_path("../dummy/db/test.sqlite3", __FILE__), :force => true
-
-# Migrate up for all
-ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
View
42 test/dummy/db/schema.rb
@@ -1,42 +0,0 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of Active Record to incrementally modify your database, and
-# then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 20100419201348) do
-
- create_table "comments", :force => true do |t|
- t.integer "user_id"
- t.text "description"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "posts", :force => true do |t|
- t.string "owner_type"
- t.integer "owner_id"
- t.string "publication_state"
- t.string "post_type"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "users", :force => true do |t|
- t.boolean "admin", :default => false, :null => false
- t.datetime "approved_at"
- t.datetime "rejected_at"
- t.date "last_posted_on"
- t.string "first_name"
- t.string "last_name"
- t.text "description"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
-end
View
22 test/duration_test.rb
@@ -1,22 +0,0 @@
-require 'test_helper'
-
-class DurationTest < ActiveSupport::TestCase
-
- setup do
- @same_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 15.days.ago.midnight
- @updated_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 1.days.ago.midnight
- end
-
- test "set the correct expected values for a with_duration_of datetime column method" do
- assert_equal [@updated_user], User.with_duration_of(14, :created_at, :updated_at)
- end
-
- test "set the correct expected values for a with_duration_over datetime column method" do
- assert_equal [@updated_user], User.with_duration_over(10, :created_at, :updated_at)
- end
-
- test "set the correct expected values for a with_duration_under datetime column method" do
- assert_equal [@same_user], User.with_duration_under(10, :created_at, :updated_at)
- end
-
-end
View
51 test/helpers_test.rb
@@ -1,51 +0,0 @@
-require 'test_helper'
-
-class HelpersTest < ActiveSupport::TestCase
-
- test "A class without a db table should return an empty array when asked about #safe_columns" do
- columns = Article.send :safe_columns
- assert_equal [], columns
- end
-
- test "A class without a db table should survive an include of Pacecar" do
- assert_nothing_raised do
- Article.send :include, Pacecar
- end
- end
-
- test "A class with a db table should return columns for #safe_column_names" do
- column_names = Comment.safe_column_names
- assert_equal ['id', 'user_id', 'description', 'created_at', 'updated_at'], column_names
- end
-
- test "A class with many column types should return boolean columns for #boolean_column_names" do
- column_names = User.boolean_column_names
- assert_equal ['admin'], column_names
- end
-
- test "A class with many column types should return non boolean columns for #non_boolean_column_names" do
- column_names = User.non_boolean_column_names
- assert_equal ['id', 'approved_at', 'rejected_at', 'last_posted_on', 'first_name', 'last_name', 'description', 'age', 'rating', 'created_at', 'updated_at'], column_names
- end
-
- test "A class with many column types should return datetime columns for #datetime_column_names" do
- column_names = User.datetime_column_names
- assert_equal ['approved_at', 'rejected_at', 'last_posted_on', 'created_at', 'updated_at'], column_names
- end
-
- test "A class with many column types should return text and string columns for #text_and_string_column_names" do
- column_names = User.text_and_string_column_names
- assert_equal ['first_name', 'last_name', 'description'], column_names
- end
-
- test "A class with many column types should return numeric columns for #numeric_column_names" do
- column_names = User.numeric_column_names
- assert_equal ['id', 'age', 'rating'], column_names
- end
-
- test "A class with a state column should return all non state text and string columns for #non_state_text_and_string_column_names" do
- column_names = Post.non_state_text_and_string_columns
- assert_equal ['title', 'body'], column_names
- end
-
-end
View
7 test/integration/navigation_test.rb
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class NavigationTest < ActiveSupport::IntegrationCase
- test "truth" do
- assert_kind_of Dummy::Application, Rails.application
- end
-end
View
25 test/limit_test.rb
@@ -1,25 +0,0 @@
-require 'test_helper'
-
-class LimitTest < ActiveSupport::TestCase
-
- setup do
- 50.times { Factory :user }
- end
-
- test "set the correct expected values for a by_ column method" do
- assert_equal 50, User.count
- assert_equal 10, User.limited.all.size
- end
-
- test "set the correct expected values for a by_ column method when sent args" do
- assert_equal 50, User.count
- assert_equal 20, User.limited(20).all.size
- end
-
- test "set the correct expected values for a by_ column method when per_page defined" do
- User.expects(:per_page).returns 30
- assert_equal 50, User.count
- assert_equal 30, User.limited.all.size
- end
-
-end
View
43 test/numeric_test.rb
@@ -1,43 +0,0 @@
-require 'test_helper'
-
-class NumericTest < ActiveSupport::TestCase
-
- setup do
- @young = Factory :user, :age => 11, :rating => 10.0
- @legal = Factory :user, :age => 21, :rating => 7.5
- @older = Factory :user, :age => 31, :rating => 5.0
- end
-
- test "set the correct expected values for a _greater_than column method for an integer column" do
- assert_equal [@older], User.age_greater_than(21)
- end
-
- test "set the correct expected values for a _greater_than_or_equal_to column method for an integer column" do
- assert_equal [@legal, @older], User.age_greater_than_or_equal_to(21)
- end
-
- test "set the correct expected values for a _less_than column method for an integer column" do
- assert_equal [@young], User.age_less_than(21)
- end
-
- test "set the correct expected values for a _less_than_or_equal_to column method for an integer column" do
- assert_equal [@young, @legal], User.age_less_than_or_equal_to(21)
- end
-
- test "set the correct expected values for a _greater_than column method for a float column" do
- assert_equal [@young], User.rating_greater_than(7.5)
- end
-
- test "set the correct expected values for a _greater_than_or_equal_to column method for a float column" do
- assert_equal [@young, @legal], User.rating_greater_than_or_equal_to(7.5)
- end
-
- test "set the correct expected values for a _less_than column method for a float column" do
- assert_equal [@older], User.rating_less_than(7.5)
- end
-
- test "set the correct expected values for a _less_than_or_equal_to column method for a float column" do
- assert_equal [@legal, @older], User.rating_less_than_or_equal_to(7.5)
- end
-
-end
View
22 test/order_test.rb
@@ -1,22 +0,0 @@
-require 'test_helper'
-
-class OrderTest < ActiveSupport::TestCase
-
- setup do
- @first = Factory :user, :first_name => 'Abe'
- @last = Factory :user, :first_name => 'Zed'
- end
-
- test "set the correct expected values for a by_ column method with no args" do
- assert_equal [@first, @last], User.by_first_name
- end
-
- test "set the correct expected values for a by_ column method with asc args" do
- assert_equal [@first, @last], User.by_first_name(:asc)
- end
-
- test "set the correct expected values for a by_ column method with desc args" do
- assert_equal [@last, @first], User.by_first_name(:desc)
- end
-
-end
View
9 test/pacecar_test.rb
@@ -1,9 +0,0 @@
-require 'test_helper'
-
-class PacecarTest < ActiveSupport::TestCase
-
- test "truth" do
- assert_kind_of Module, Pacecar
- end
-
-end
View
18 test/polymorph_test.rb
@@ -1,18 +0,0 @@
-require 'test_helper'
-
-class PolymorphTest < ActiveSupport::TestCase
-
- setup do
- @owned_by_user = Factory :post, :owner_type => 'User'
- @owned_by_mammal = Factory :post, :owner_type => 'Mammal'
- end
-
- test "set the correct expected values on a _for column method with Class" do
- assert_equal [@owned_by_user], Post.for_owner_type(User)
- end
-
- test "set the correct expected values on a _for column method with String" do
- assert_equal [@owned_by_user], Post.for_owner_type('User')
- end
-
-end
View
23 test/presence_test.rb
@@ -1,23 +0,0 @@
-require 'test_helper'
-
-class PresenceTest < ActiveSupport::TestCase
-
- setup do
- @not_null = Factory :user, :first_name => 'Fake'
- @null = Factory :user, :first_name => nil
- end
-
- test "set the correct expected values for a _present column method" do
- assert_equal [@not_null], User.first_name_present
- end
-
- test "set the correct expected values for a _missing column method" do
- assert_equal [@null], User.first_name_missing
- end
-
- test "not setup methods for boolean columns" do
- assert_raise(NoMethodError) { User.admin_missing }
- assert_raise(NoMethodError) { User.admin_present }
- end
-
-end
View
21 test/ranking_test.rb
@@ -1,21 +0,0 @@
-require 'test_helper'
-
-class RankingTest < ActiveSupport::TestCase
-
- setup do
- @many = Factory :user
- 5.times { Factory :comment, :user => @many }
- @few = Factory :user
- 2.times { Factory :comment, :user => @few }
- @none = Factory :user
- end
-
- test "set the correct expected values on a maximum_ column method" do
- assert_equal [@many, @few], User.maximum_comments
- end
-
- test "set the correct expected values on a minimum_ column method" do
- assert_equal [@few, @many], User.minimum_comments
- end
-
-end
View
63 test/search_test.rb
@@ -1,63 +0,0 @@
-require 'test_helper'
-
-class SearchTest < ActiveSupport::TestCase
-
- setup do
- @abe = Factory :user, :first_name => 'Abe', :last_name => 'Anderson', :description => 'Apple'
- @bob = Factory :user, :first_name => 'Bob', :last_name => 'Babson', :description => 'Banana'
- @cindy = Factory :user, :first_name => 'Cindy', :last_name => 'Clarkson', :description => 'Cookie'
- @dave = Factory :user, :first_name => 'Dave'
- @ed = Factory :user, :last_name => 'Dave'
- @frank = Factory :user, :description => 'Dave'
- @george = Factory :user, :first_name => 'Dave', :last_name => 'Dave', :description => 'Dave'
-
- @null = Factory :user, :first_name => nil, :last_name => nil, :description => nil
- end
-
- test "set the correct expected values for a _equals column method" do
- assert_equal [@abe], User.first_name_equals('Abe')
- end
-
- test "set the correct expected values for a _equals column method with an Array as value" do
- assert_equal [@abe, @bob], User.first_name_equals(['Abe', 'Bob'])
- end
-
- test "set the correct expected values for a _equals column method with nil as value" do
- assert_equal [@ed, @frank, @null], User.first_name_equals(nil)
- end
-
- test "set the correct expected values for a _matches column method" do
- assert_equal [@cindy], User.first_name_matches('ind')
- assert_equal [@cindy], User.first_name_matches('IND')
- end
-
- test "set the correct expected values for a _starts_with column method" do
- assert_equal [@abe], User.first_name_starts_with('Ab')
- assert_equal [@abe], User.first_name_starts_with('aB')
- end
-
- test "set the correct expected values for a _ends_with column method" do
- assert_equal [@bob], User.first_name_ends_with('ob')
- assert_equal [@bob], User.first_name_ends_with('Ob')
- end
-
- test "set the correct expected values for a search_for method" do
- assert_equal [@dave, @ed, @frank, @george], User.search_for('Dave')
- assert_equal [@dave, @ed, @frank, @george], User.search_for('dave')
- end
-
- test "set the correct expected values for a search_for method with :on option" do
- assert_equal [@dave, @frank, @george], User.search_for('Dave', :on => [:first_name, :description])
- assert_equal [@dave, @frank, @george], User.search_for('dave', :on => [:first_name, :description])
- end
-
- test "set the correct expected values for a search_for method with an :require option" do
- assert_equal [@george], User.search_for('Dave', :require => :all)
- assert_equal [@george], User.search_for('dave', :require => :all)
- end
-
- test "set the correct expected values for a search_for method on a class with no columns" do
- assert_equal [], Mammal.search_for('test')
- end
-
-end
View
69 test/state_test.rb
@@ -1,69 +0,0 @@
-require 'test_helper'
-
-class StateTest < ActiveSupport::TestCase
-
- setup do
- @draft_post = Factory :post, :publication_state => 'Draft'
- @final_post = Factory :post, :publication_state => 'Final'
- @free_post = Factory :post, :post_type => 'Free'
- @open_post = Factory :post, :post_type => 'Open'
-
- @post = Post.new
- assert_not_nil Post::PUBLICATION_STATES
- end
-
- test "set the correct expected values for a column_state _state method" do
- assert_equal [@draft_post], Post.publication_state_draft
- end
-
- test "set the correct expected values for a column_not_state _state method" do
- assert_equal [@final_post], Post.publication_state_not_draft
- end
-
- test "set the correct expected values for a column_state _type method" do
- assert_equal [@free_post], Post.post_type_free
- end
-
- test "set the correct expected values for a column_not_state _type method" do
- assert_equal [@open_post], Post.post_type_not_free
- end
-
- test "set the correct expected values for a column_state method" do
- assert_equal [@open_post], Post.post_type('Open')
- end
-
- test "set the correct expected values for a column_state_not method" do
- assert_equal [@free_post], Post.post_type_not('Open')
- end
-
- Post::PUBLICATION_STATES.each do |state|
- test "have a query method for a #{state} state value" do
- assert @post.respond_to?("publication_state_#{state.downcase}?")
- end
-
- test "have a non query method for a #{state} state value" do
- assert @post.respond_to?("publication_state_not_#{state.downcase}?")
- end
-
- test "respond true to query method for a #{state} state value when in that state" do
- @post.publication_state = state
- assert @post.send("publication_state_#{state.downcase}?")
- end
-
- test "respond false to not query method for a #{state} state value when in that state" do
- @post.publication_state = state
- assert ! @post.send("publication_state_not_#{state.downcase}?")
- end
-
- test "respond false to query method for a #{state} state value when not in that state" do
- @post.publication_state = 'Invalid'
- assert ! @post.send("publication_state_#{state.downcase}?")
- end
-
- test "respond true to not query method for a #{state} state value when not in that state" do
- @post.publication_state = 'Invalid'
- assert @post.send("publication_state_not_#{state.downcase}?")
- end
- end
-
-end
View
5 test/support/integration_case.rb
@@ -1,5 +0,0 @@
-# # Define a bare test case to use with Capybara
-class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
- # include Capybara
- include Rails.application.routes.url_helpers
-end
Please sign in to comment.
Something went wrong with that request. Please try again.