moving models to the oh so clean active_hash, puny tests work

This commit is contained in:
2022-12-10 23:11:17 +02:00
parent 04e189f913
commit b710541ee3
10 changed files with 1639 additions and 122 deletions

View File

@ -2,16 +2,16 @@ require 'rails_helper'
module Merged
RSpec.describe Card, type: :model do
let(:first) {Card.all.values.first}
let(:first) {Card.first}
it "has Card.all" do
expect(Card.all.class).to be Hash
expect(Card.all.length).to be 46
end
it "has cards" do
expect(first.class).to be Card
end
it "has index" do
expect(first.index).to eq 0
expect(first.index).to eq 1
end
end
end

View File

@ -2,19 +2,19 @@ require 'rails_helper'
module Merged
RSpec.describe Page, type: :model do
let(:index) {Page.find('index')}
let(:index) {Page.find_by_name('index')}
it "has Pages.all" do
expect(Page.all.class).to be Hash
expect(Page.all.length).to be 6
end
it "has index page" do
expect(index.class).to be Page
end
it "has sections" do
expect(index.sections.length).to be 1
expect(index.sections.length).to be 10
end
it "has section array" do
expect(index.sections.class).to be Array
expect(index.sections.first.class).to be Section
end
end
end

View File

@ -2,22 +2,22 @@ require 'rails_helper'
module Merged
RSpec.describe Section, type: :model do
let(:first) {Section.all.values.first}
let(:first) {Section.last}
it "has Sections.all" do
expect(Section.all.class).to be Hash
expect(Section.all.length).to be 40
end
it "has index page" do
expect(first.class).to be Section
end
it "has index" do
expect(first.index).to eq 0
expect(first.index).to eq 10
end
it "has cards" do
expect(first.cards.length).to eq 2
expect(first.cards.length).to eq 5
end
it "has cards array" do
expect(first.cards.class).to be Array
expect(first.cards.class).to be ActiveHash::Relation
end
end
end