Sha256: 3f0e9bf7d093af31c09012abccdef948172bb43c0af86ceb777c0cad9c78d587

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require "#{File.dirname(__FILE__)}/../../../spec_helper"

describe UserMeeting do
  it 'create johns meeting' do
    expect do
      FactoryGirl.create(:johns_meeting)
    end.to change(UserMeeting, :count).by(1)
  end

  context 'Validation with scope' do
    before do
      FactoryGirl.create(:johns_meeting)
    end

    OVERLAP_TIME_RANGES.each do |description, time_range|
      it "is not valid if exists johns meeting which #{description}" do
        meeting = FactoryGirl.build(:johns_meeting, starts_at: time_range.first, ends_at: time_range.last)
        expect(UserMeeting.count).to eq 1
        expect(meeting).not_to be_valid
        expect(meeting.errors[:starts_at]).not_to be_empty
        expect(meeting.errors[:ends_at]).to be_empty
      end
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
validates_overlap-1.0.0 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.8.6 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.8.5 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.8.4 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.8.2 spec/dummy/spec/models/user_meeting_spec.rb
validates_overlap-0.8.1 spec/dummy/spec/models/user_meeting_spec.rb