Sha256: e005c51428107b374e871c645b90dfdfbe566ac229a736a9706a2c4e7586b4bc

Contents?: true

Size: 789 Bytes

Versions: 6

Compression:

Stored size: 789 Bytes

Contents

describe OverlapValidator do


  context "validation message" do

    it "should have default message" do
      subject = OverlapValidator.new({:attributes => [:starts_at, :ends_at]})
      meeting = Meeting.new
      subject.stub(:find_crossed){true}
      subject.validate(meeting)
      meeting.errors[:starts_at].should 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
      subject.stub(:find_crossed){true}
      subject.stub(:options){ {:message_title => :optional_key, :message_content => "Message content"} }
      subject.validate(meeting)
      meeting.errors[:optional_key].should eq ["Message content"]
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
validates_overlap-0.6.0 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.5.2 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.5.1 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.5.0 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.4.0 spec/dummy/spec/overlap_validator_spec.rb
validates_overlap-0.3.0 spec/dummy/spec/overlap_validator_spec.rb