mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 18:50:12 +01:00
all non-cucumber tests are passing
This commit is contained in:
parent
13b58f3a10
commit
63175c115b
46 changed files with 248 additions and 505 deletions
25
backup.rails2.3/spec/support/should_validate_length_of.rb
Normal file
25
backup.rails2.3/spec/support/should_validate_length_of.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module LuckySneaks
|
||||
module ModelSpecHelpers
|
||||
module ExampleGroupLevelMethods
|
||||
def it_should_validate_length_of(attribute, options={})
|
||||
maximum = options[:maximum] || (options[:within] || []).last || false
|
||||
minimum = options[:minimum] || (options[:within] || []).first || false
|
||||
raise ArgumentError unless maximum || minimum
|
||||
|
||||
it "should not be valid if #{attribute} length is more than #{maximum}" do
|
||||
instance.send "#{attribute}=", 'x'*(maximum+1)
|
||||
instance.errors_on(attribute).should include(
|
||||
options[:message_too_long] || I18n.t('activerecord.errors.messages.too_long', :count => maximum)
|
||||
)
|
||||
end if maximum
|
||||
|
||||
it "should not be valid if #{attribute} length is less than #{minimum}" do
|
||||
instance.send "#{attribute}=", 'x'*(minimum-1)
|
||||
instance.errors_on(attribute).should include(
|
||||
options[:message_to_short] || I18n.t('activerecord.errors.messages.too_short', :count => minimum)
|
||||
)
|
||||
end if minimum
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue