Sha256: 84ed01e5827d512317854d41e7fe72a4a1b3ce3de36a3bc7d4cf8157845818b8
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require 'rails_helper' module WebAdmin RSpec.describe Event, :type => :model do context "Validations" do it { should validate_presence_of :title } it { should validate_presence_of :start_date } it { should validate_presence_of :end_date } it { should validate_presence_of :description } context "when end_date is greater than start_date" do it 'is valid' do subject.stub(start_date: Time.current) subject.stub(end_date: Time.current + 3.days) subject.valid? expect(subject.errors[:end_date]).to be_empty end end context "when end_date is less than start_date" do it 'is not valid' do subject.stub(start_date: Time.current) subject.stub(end_date: Time.current - 3.days) subject.valid? expect(subject.errors[:end_date]).to eq([I18n.t('activerecord.errors.messages.end_date_is_greater_than_start_date')]) end end end describe "to_s" do it 'return title' do subject.stub(title: "Primeiro Evento") expect(subject.to_s).to eq "Primeiro Evento" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
web_admin-0.1.0 | spec/models/admin_web/event_spec.rb |
web_admin-0.0.2 | spec/models/admin_web/event_spec.rb |
web_admin-0.0.1 | spec/models/admin_web/event_spec.rb |