Sha256: b9551cfe482fa4c76690e283d6c2ff5582f54c9dce7bf82d93fffe06022f7c84
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 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 "#available_status" do it "returns `unavailable` for Entries not available" do entry = build(:entry, :unavailable) expect(entry.available_status).to eq("unavailable") end it "returns `future-available` for Entries available in the future" do entry = build(:entry, :future) expect(entry.available_status).to eq("future-available") end it "returns `available` for Entries available in the past" do entry = build(:entry) expect(entry.available_status).to eq("available") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
archangel-0.0.7 | spec/models/archangel/entry_spec.rb |