mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
Mongoid 3.0 appraisal and failing specs
This commit is contained in:
parent
b463b4356a
commit
bbb16cb093
@ -25,3 +25,7 @@ end
|
|||||||
appraise "mongoid_2_4" do
|
appraise "mongoid_2_4" do
|
||||||
gem "mongoid", "~> 2.4.0"
|
gem "mongoid", "~> 2.4.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
appraise "mongoid_3_0" do
|
||||||
|
gem "mongoid", "~> 3.0.0"
|
||||||
|
end
|
||||||
|
|||||||
3
Gemfile
3
Gemfile
@ -13,7 +13,8 @@ gem 'appraisal'
|
|||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
|
|
||||||
group :mongoid do
|
group :mongoid do
|
||||||
gem 'mongoid', '~> 2.3.0'
|
gem 'mongoid', '~> 3.0.0'
|
||||||
|
gem 'mongo'
|
||||||
gem 'bson_ext'
|
gem 'bson_ext'
|
||||||
gem 'system_timer', :platforms => [:ruby_18]
|
gem 'system_timer', :platforms => [:ruby_18]
|
||||||
end
|
end
|
||||||
|
|||||||
16
gemfiles/mongoid_3_0.gemfile
Normal file
16
gemfiles/mongoid_3_0.gemfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "rails", "~> 3.2.6"
|
||||||
|
gem "rspec", "~> 2.8"
|
||||||
|
gem "rspec-rails", "~> 2.8"
|
||||||
|
gem "timecop"
|
||||||
|
gem "rspec_tag_matchers"
|
||||||
|
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
||||||
|
gem "debugger", :platforms=>[:ruby_19]
|
||||||
|
gem "appraisal"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "mongoid", "~> 3.0.0"
|
||||||
|
|
||||||
|
gemspec :path=>"../"
|
||||||
16
gemfiles/mongoid_3_1.gemfile
Normal file
16
gemfiles/mongoid_3_1.gemfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "rails", "~> 3.2.6"
|
||||||
|
gem "rspec", "~> 2.8"
|
||||||
|
gem "rspec-rails", "~> 2.8"
|
||||||
|
gem "timecop"
|
||||||
|
gem "rspec_tag_matchers"
|
||||||
|
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
||||||
|
gem "debugger", :platforms=>[:ruby_19]
|
||||||
|
gem "appraisal"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "mongoid", "~> 3.1.0"
|
||||||
|
|
||||||
|
gemspec :path=>"../"
|
||||||
6
spec/support/mongoid.yml
Normal file
6
spec/support/mongoid.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
test:
|
||||||
|
sessions:
|
||||||
|
default:
|
||||||
|
database: mongoid
|
||||||
|
hosts:
|
||||||
|
- localhost:27017
|
||||||
@ -4,13 +4,19 @@ require 'spec_helper'
|
|||||||
begin
|
begin
|
||||||
|
|
||||||
require 'mongoid'
|
require 'mongoid'
|
||||||
|
require 'mongoid/version'
|
||||||
require 'validates_timeliness/orm/mongoid'
|
require 'validates_timeliness/orm/mongoid'
|
||||||
|
|
||||||
Mongoid.configure do |config|
|
if Mongoid::VERSION >= '3.0'
|
||||||
name = "validates_timeliness_test"
|
Mongoid.load!("spec/support/mongoid.yml", :test)
|
||||||
host = "localhost"
|
else
|
||||||
config.master = Mongo::Connection.new.db(name)
|
require 'mongo'
|
||||||
config.persist_in_safe_mode = false
|
Mongoid.configure do |config|
|
||||||
|
name = "validates_timeliness_test"
|
||||||
|
host = "localhost"
|
||||||
|
config.master = Mongo::Connection.new.db(name)
|
||||||
|
config.persist_in_safe_mode = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ValidatesTimeliness, 'Mongoid' do
|
describe ValidatesTimeliness, 'Mongoid' do
|
||||||
@ -47,9 +53,19 @@ describe ValidatesTimeliness, 'Mongoid' do
|
|||||||
record.errors[:publish_date].should be_empty
|
record.errors[:publish_date].should be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should validate a invalid value string" do
|
it "should validate an invalid time value string" do
|
||||||
begin
|
begin
|
||||||
record.publish_date = 'not a date'
|
record.publish_time = 'not valid'
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
|
||||||
|
record.valid?
|
||||||
|
record.errors[:publish_time].should_not be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should validate an invalid date value string" do
|
||||||
|
begin
|
||||||
|
record.publish_date = 'not valid'
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,12 +73,36 @@ describe ValidatesTimeliness, 'Mongoid' do
|
|||||||
record.errors[:publish_date].should_not be_empty
|
record.errors[:publish_date].should_not be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should validate a nil value" do
|
it "should validate an invalid datetime value string" do
|
||||||
|
begin
|
||||||
|
record.publish_datetime = 'not valid'
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
|
||||||
|
record.valid?
|
||||||
|
record.errors[:publish_datetime].should_not be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should accept a nil time value" do
|
||||||
|
record.publish_date = nil
|
||||||
|
|
||||||
|
record.valid?
|
||||||
|
record.errors[:publish_time].should be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should accept a nil date value" do
|
||||||
record.publish_date = nil
|
record.publish_date = nil
|
||||||
|
|
||||||
record.valid?
|
record.valid?
|
||||||
record.errors[:publish_date].should be_empty
|
record.errors[:publish_date].should be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should accept a nil datetime value" do
|
||||||
|
record.publish_datetime = nil
|
||||||
|
|
||||||
|
record.valid?
|
||||||
|
record.errors[:publish_datetime].should be_empty
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should determine type for attribute' do
|
it 'should determine type for attribute' do
|
||||||
@ -105,6 +145,8 @@ describe ValidatesTimeliness, 'Mongoid' do
|
|||||||
Timeliness::Parser.should_receive(:parse)
|
Timeliness::Parser.should_receive(:parse)
|
||||||
|
|
||||||
record.publish_date = 'not valid'
|
record.publish_date = 'not valid'
|
||||||
|
|
||||||
|
record.publish_date.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should store a Date value after parsing string' do
|
it 'should store a Date value after parsing string' do
|
||||||
@ -149,6 +191,8 @@ describe ValidatesTimeliness, 'Mongoid' do
|
|||||||
Timeliness::Parser.should_receive(:parse)
|
Timeliness::Parser.should_receive(:parse)
|
||||||
|
|
||||||
record.publish_datetime = 'not valid'
|
record.publish_datetime = 'not valid'
|
||||||
|
|
||||||
|
record.publish_datetime.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should parse string into DateTime value' do
|
it 'should parse string into DateTime value' do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user