Sha256: cdaded61d0ab530375a4594975cc71c14bb2f0b10bf75fea73a8c8038f3490c4
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true require "rails_helper" module Archangel RSpec.describe Entry, type: :model do context "validations" do it { is_expected.to validate_presence_of(:collection_id) } it { is_expected.to validate_presence_of(:value) } it { is_expected.to allow_value(nil).for(:available_at) } it { is_expected.to allow_value("").for(:available_at) } it { is_expected.to allow_value(Time.current).for(:available_at) } it { is_expected.to_not allow_value("invalid").for(:available_at) } end context "associations" do it { is_expected.to belong_to(:collection) } end context ".available?" do it "is available" do entry = build(:entry) expect(entry.available?).to be_truthy end it "is available in the future" do entry = build(:entry, available_at: 1.week.from_now) expect(entry.available?).to be_truthy end it "is not available" do entry = build(:entry, :unavailable) expect(entry.available?).to be_falsey end end context "#status" do it "returns `unavailable` for Entries not available" do entry = build(:entry, :unavailable) expect(entry.status).to eq("unavailable") end it "returns `future-available` for Entries available in the future" do entry = build(:entry, :future) expect(entry.status).to eq("future-available") end it "returns `available` for Entries available in the past" do entry = build(:entry) expect(entry.status).to eq("available") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
archangel-0.3.0 | spec/models/archangel/entry_spec.rb |
archangel-0.0.8 | spec/models/archangel/entry_spec.rb |