Sha256: 084b74a60796862c1f7eb1f62de88d3bb31431f50c82f8ae977409971495bf8d

Contents?: true

Size: 997 Bytes

Versions: 19

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'

class Validatable
  include ActiveModel::Validations
  attr_accessor :embargo_release_date
  validates :embargo_release_date, future_date: true
end

describe FutureDateValidator do

  subject { Validatable.new }

  before { subject.embargo_release_date = embargo_release_date }

  context 'with today as embargo release date' do
    let(:embargo_release_date) { Date.today.to_s    }
    it { should have(1).error_on(:embargo_release_date) }
  end

  context 'with past date as embargo release date' do
    let(:embargo_release_date) { (Date.today - 2).to_s  }
    it { should have(1).error_on(:embargo_release_date) }
  end

  context 'invalid date as embargo release date' do
    let(:embargo_release_date) { "invalid_ date" }
    it { should have(1).error_on(:embargo_release_date) }
  end

  context 'future date as embargo release date' do
    let(:embargo_release_date) { (Date.today + 2).to_s    }
    it { should have(:no).error_on(:embargo_release_date) }
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
curate-0.6.6 spec/validators/future_date_validator_spec.rb
curate-0.6.5 spec/validators/future_date_validator_spec.rb
curate-0.6.4 spec/validators/future_date_validator_spec.rb
curate-0.6.3 spec/validators/future_date_validator_spec.rb
curate-0.6.1 spec/validators/future_date_validator_spec.rb
curate-0.6.0 spec/validators/future_date_validator_spec.rb
curate-0.5.6 spec/validators/future_date_validator_spec.rb
curate-0.5.5 spec/validators/future_date_validator_spec.rb
curate-0.5.4 spec/validators/future_date_validator_spec.rb
curate-0.5.2 spec/validators/future_date_validator_spec.rb
curate-0.5.1 spec/validators/future_date_validator_spec.rb
curate-0.5.0 spec/validators/future_date_validator_spec.rb
curate-0.4.2 spec/validators/future_date_validator_spec.rb
curate-0.3.2 spec/validators/future_date_validator_spec.rb
curate-0.3.1 spec/validators/future_date_validator_spec.rb
curate-0.2.0 spec/validators/future_date_validator_spec.rb
curate-0.1.3 spec/validators/future_date_validator_spec.rb
curate-0.1.2 spec/validators/future_date_validator_spec.rb
curate-0.1.1 spec/validators/future_date_validator_spec.rb