Sha256: 8faa9ee56694195f21ddc9ed2564aacc23dee01f154e4d98fa43b86e082f3215

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require_relative '../../../spec_helper'
require_relative '../factories/user_meeting'

describe UserMeeting do

  before(:all) do
    UserMeeting.delete_all
  end

  it "create johns meeting" do
    lambda {
      Factory(:johns_meeting)
    }.should change(UserMeeting, :count).by(1)
  end

  context "Validation with scope" do

    OVERLAP_TIME_RANGES.each do |description, time_range|
      it "is not valid if exists johns meeting which #{description}" do
        meeting = Factory.build(:johns_meeting, :starts_at => time_range.first, :ends_at => time_range.last)
        meeting.should_not be_valid
        meeting.errors[:starts_at].should_not be_empty
        meeting.errors[:ends_at].should be_empty
      end
    end

    OVERLAP_TIME_RANGES.each do |description, time_range|
      it "is valid if exists johns meeting which #{description}" do
        meeting = Factory.build(:peters_meeting, :starts_at => time_range.first, :ends_at => time_range.last)
        meeting.should be_valid
        meeting.errors[:starts_at].should be_empty
        meeting.errors[:ends_at].should be_empty
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
validates_overlap-0.1.0 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.0.6 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.0.5 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.0.4 spec/dummy/spec/models/user_meeting_spec.rb