mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
spec cleaning
This commit is contained in:
parent
00f01402e0
commit
2efcff2fd4
@ -1,17 +1,20 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe ValidatesTimeliness, 'ActiveRecord' do
|
describe ValidatesTimeliness, 'ActiveRecord' do
|
||||||
it 'should define class validation methods' do
|
|
||||||
|
context "validation methods" do
|
||||||
|
it 'should be defined for the class' do
|
||||||
ActiveRecord::Base.should respond_to(:validates_date)
|
ActiveRecord::Base.should respond_to(:validates_date)
|
||||||
ActiveRecord::Base.should respond_to(:validates_time)
|
ActiveRecord::Base.should respond_to(:validates_time)
|
||||||
ActiveRecord::Base.should respond_to(:validates_datetime)
|
ActiveRecord::Base.should respond_to(:validates_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should define instance validation methods' do
|
it 'should defines for the instance' do
|
||||||
ActiveRecord::Base.instance_methods.should include('validates_date')
|
ActiveRecord::Base.instance_methods.should include('validates_date')
|
||||||
ActiveRecord::Base.instance_methods.should include('validates_time')
|
ActiveRecord::Base.instance_methods.should include('validates_time')
|
||||||
ActiveRecord::Base.instance_methods.should include('validates_datetime')
|
ActiveRecord::Base.instance_methods.should include('validates_datetime')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should define _timeliness_raw_value_for instance method' do
|
it 'should define _timeliness_raw_value_for instance method' do
|
||||||
Employee.instance_methods.should include('_timeliness_raw_value_for')
|
Employee.instance_methods.should include('_timeliness_raw_value_for')
|
||||||
|
|||||||
@ -10,31 +10,33 @@ Mongoid.configure do |config|
|
|||||||
config.persist_in_safe_mode = false
|
config.persist_in_safe_mode = false
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ValidatesTimeliness, 'Mongoid' do
|
class Article
|
||||||
|
|
||||||
class Article
|
|
||||||
::ValidatesTimeliness.use_plugin_parser = true
|
::ValidatesTimeliness.use_plugin_parser = true
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
field :publish_date, :type => Date
|
field :publish_date, :type => Date
|
||||||
field :publish_time, :type => Time
|
field :publish_time, :type => Time
|
||||||
field :publish_datetime, :type => DateTime
|
field :publish_datetime, :type => DateTime
|
||||||
validates_date :publish_date
|
validates_date :publish_date, :allow_nil => true
|
||||||
validates_time :publish_time
|
validates_time :publish_time, :allow_nil => true
|
||||||
validates_datetime :publish_datetime
|
validates_datetime :publish_datetime, :allow_nil => true
|
||||||
::ValidatesTimeliness.use_plugin_parser = false
|
::ValidatesTimeliness.use_plugin_parser = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should define class validation methods' do
|
describe ValidatesTimeliness, 'Mongoid' do
|
||||||
|
|
||||||
|
context "validation methods" do
|
||||||
|
it 'should be defined on the class' do
|
||||||
Article.should respond_to(:validates_date)
|
Article.should respond_to(:validates_date)
|
||||||
Article.should respond_to(:validates_time)
|
Article.should respond_to(:validates_time)
|
||||||
Article.should respond_to(:validates_datetime)
|
Article.should respond_to(:validates_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should define instance validation methods' do
|
it 'should be defined on the instance' do
|
||||||
Article.instance_methods.should include('validates_date')
|
Article.instance_methods.should include('validates_date')
|
||||||
Article.instance_methods.should include('validates_time')
|
Article.instance_methods.should include('validates_time')
|
||||||
Article.instance_methods.should include('validates_datetime')
|
Article.instance_methods.should include('validates_datetime')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should define _timeliness_raw_value_for instance method' do
|
it 'should define _timeliness_raw_value_for instance method' do
|
||||||
Article.instance_methods.should include('_timeliness_raw_value_for')
|
Article.instance_methods.should include('_timeliness_raw_value_for')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user