have to manually require matcher now because the presence of the Spec

namespace caused issues for shoulda when not using rspec:wq
This commit is contained in:
Adam Meehan 2009-07-07 15:32:15 +10:00
parent 14c55e3292
commit 1a31e7463d
5 changed files with 16 additions and 10 deletions

View File

@ -355,7 +355,13 @@ To sweeten the deal that little bit more, you have an Rspec matcher available fo
you model specs. Now you can easily test the validations you have just written
with the plugin or better yet *before* you write them! You just use the
validation options you want as you would with the validation method. Those
options are then verified and reported if they fail. Use it like so:
options are then verified and reported if they fail.
First require it in your spec_helper.rb
require 'validates_timeliness/matcher'
Use it like so:
@person.should validate_date(:birth_date, :before => Time.now, :before_message => 'should be before today')

View File

@ -2,7 +2,6 @@ require 'validates_timeliness/formats'
require 'validates_timeliness/parser'
require 'validates_timeliness/validator'
require 'validates_timeliness/validation_methods'
require 'validates_timeliness/spec/rails/matchers/validate_timeliness' if ENV['RAILS_ENV'] == 'test'
require 'validates_timeliness/active_record/attribute_methods'
require 'validates_timeliness/active_record/multiparameter_attributes'

View File

@ -0,0 +1 @@
require 'validates_timeliness/spec/rails/matchers/validate_timeliness'

View File

@ -28,13 +28,12 @@ module Spec
valid = test_validity
valid = test_option(:equal_to) if @options[:equal_to] && valid
valid = test_option(:before) if @options[:before] && valid
valid = test_option(:after) if @options[:after] && valid
valid = test_option(:on_or_before) if @options[:on_or_before] && valid
valid = test_option(:on_or_after) if @options[:on_or_after] && valid
valid = test_between if @options[:between] && valid
valid = test_option(:equal_to) if valid && @options[:equal_to]
valid = test_option(:before) if valid && @options[:before]
valid = test_option(:after) if valid && @options[:after]
valid = test_option(:on_or_before) if valid && @options[:on_or_before]
valid = test_option(:on_or_after) if valid && @options[:on_or_after]
valid = test_between if valid && @options[:between]
return valid
end

View File

@ -1,4 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'validates_timeliness/matcher'
class NoValidation < Person
end