clarion/spec/models/event_spec.rb

43 lines
943 B
Ruby
Raw Normal View History

2019-04-28 21:10:54 +03:00
require "rails_helper"
describe Event, type: :model do
let(:event) { build :event }
2019-04-28 21:10:54 +03:00
it "is invalid if the event agrement is not accepted" do
event.agreement = false
expect(event).to have_error_on :agreement
end
2019-04-28 21:10:54 +03:00
it "is invalid without a title" do
event.title = ""
expect(event).to have_error_on :title
end
2019-04-28 21:10:54 +03:00
describe "length" do
it "must be present" do
event.length = ""
expect(event).to have_error_on :length
end
2019-04-28 21:10:54 +03:00
it "must be a number" do
event.length = "foo"
expect(event).to have_error_on :length
end
2019-04-28 21:10:54 +03:00
it "must be larger than zero" do
event.length = "-10"
expect(event).to have_error_on :length
end
end
2019-04-28 21:10:54 +03:00
it "is invalid without an abstract" do
event.abstract = ""
expect(event).to have_error_on :abstract
end
2019-04-28 21:10:54 +03:00
it "is invalid without a description" do
event.description = ""
expect(event).to have_error_on :description
end
end