Sha256: 16a4cc61ea7e18d82771c57b5c3dfa962236c4cb5f0dcd528d29afe32c21afae

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

require 'spec_helper'

describe OverlapValidator do
  context 'validation message' do
    it 'should have default message' do
      subject = OverlapValidator.new(attributes: [:starts_at, :ends_at])
      meeting = Meeting.new
      expect(subject).to receive(:overlapped_exists?) { true }
      subject.validate(meeting)
      expect(meeting.errors[:starts_at]).to eq ['overlaps with another record']
    end

    it 'should be possible to configure message' do
      subject = OverlapValidator.new(attributes: [:starts_at, :ends_at])
      meeting = Meeting.new
      expect(subject).to receive(:overlapped_exists?) { true }
      allow(subject).to receive(:options) { { message_title: :optional_key, message_content: 'Message content' } }
      subject.validate(meeting)
      expect(meeting.errors[:optional_key]).to eq ['Message content']
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
validates_overlap-0.8.2 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.8.1 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.8.0 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.7.0 spec/dummy/spec/overlap_validator_spec.rb