moving model spec to good old fashioed minitests
This commit is contained in:
@ -1,45 +0,0 @@
|
||||
require 'rails_helper'
|
||||
require "git"
|
||||
|
||||
module Merged
|
||||
RSpec.describe Card, type: :model do
|
||||
let(:first) {Card.first}
|
||||
|
||||
it "has Card.all" do
|
||||
expect(Card.all.length).to be 20
|
||||
end
|
||||
it "has cards" do
|
||||
expect(first.class).to be Card
|
||||
end
|
||||
it "has index" do
|
||||
expect(first.index).to eq 1
|
||||
end
|
||||
|
||||
it "first has no previous" do
|
||||
expect(first.index).to be 1
|
||||
expect(first.previous_card).to be nil
|
||||
end
|
||||
it "first has next" do
|
||||
expect(first.next_card.index).to be 2
|
||||
end
|
||||
|
||||
it "create a new" do
|
||||
card = Card.new_card("card_normal_square" , 1 , 1)
|
||||
expect(card.index).to eq 1
|
||||
end
|
||||
|
||||
it "deletes " do
|
||||
id = first.id
|
||||
first.delete
|
||||
expect{Card.find(id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
|
||||
it "destroys " do
|
||||
id = first.id
|
||||
first.delete
|
||||
Card.reload
|
||||
expect{Card.find(id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,17 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe CardStyle, type: :model do
|
||||
let(:first_card) {CardStyle.all.first}
|
||||
|
||||
it "has .all" do
|
||||
expect(CardStyle.all.length).to be 5
|
||||
end
|
||||
|
||||
it "has fields" do
|
||||
expect(first_card.fields.class).to be Array
|
||||
expect(first_card.fields.length).to be 2
|
||||
expect(first_card.fields.first).to eq "header"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,25 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe Image, type: :model do
|
||||
let(:first) {Image.first}
|
||||
|
||||
it "has Image.all" do
|
||||
expect(Image.all.length).to be 17
|
||||
end
|
||||
it "has image" do
|
||||
expect(first.class).to be Image
|
||||
end
|
||||
it "has name" do
|
||||
expect(first.name).to eq "Common spaces"
|
||||
end
|
||||
it "has height and width" do
|
||||
expect(first.height).to eq 300
|
||||
expect(first.width).to eq 560
|
||||
end
|
||||
it "has height and width" do
|
||||
expect(first.aspect_ratio).to eq [13,7]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe OptionDefinition, type: :model do
|
||||
let(:first) {OptionDefinition.first}
|
||||
|
||||
it "has OptionDefinition.first" do
|
||||
expect(OptionDefinition.first.class).to be OptionDefinition
|
||||
end
|
||||
it "there are options" do
|
||||
expect(OptionDefinition.all.length).to be 18
|
||||
end
|
||||
it "has option objects" do
|
||||
expect(first.class).to be OptionDefinition
|
||||
end
|
||||
it "has values" do
|
||||
expect(first.values.class).to be Array
|
||||
end
|
||||
end
|
||||
end
|
@ -1,61 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe Page, type: :model do
|
||||
let(:index) {Page.find_by_name('index')}
|
||||
|
||||
it "has Pages.all" do
|
||||
expect(Page.all.length).to be 2
|
||||
end
|
||||
it "has index page" do
|
||||
expect(index.class).to be Page
|
||||
end
|
||||
it "has sections" do
|
||||
expect(index.sections.length).to be 10
|
||||
end
|
||||
it "has section array" do
|
||||
expect(index.sections.first.class).to be Section
|
||||
end
|
||||
it "has section indexes" do
|
||||
index.sections.each_with_index do |section, index|
|
||||
expect(section.index).to be index + 1 # because we have human index
|
||||
end
|
||||
end
|
||||
it "deletes " do
|
||||
id = index.id
|
||||
index.delete
|
||||
expect{Page.find(id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
it "destroys " do
|
||||
id = index.id
|
||||
index.destroy
|
||||
Section.reload
|
||||
expect{Page.find(id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
it "destroys sections" do
|
||||
id = index.sections.first.id
|
||||
index.destroy
|
||||
Section.reload
|
||||
expect{Page.find(id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
it "creates simple section" do
|
||||
s = index.new_section("section_spacer")
|
||||
expect(s).not_to be nil
|
||||
expect(s.template).to eq "section_spacer"
|
||||
end
|
||||
it "creates section with right index" do
|
||||
should_be = index.sections.last.index + 1
|
||||
s = index.new_section("section_spacer")
|
||||
expect(s.index).to eq should_be
|
||||
end
|
||||
it "creates page" do
|
||||
name = "randomname"
|
||||
page = Page.new_page( name)
|
||||
expect(page.name).to eq name
|
||||
end
|
||||
|
||||
it "has type" do
|
||||
expect(index.type).to eq "page"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,19 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe PageStyle, type: :model do
|
||||
let(:first) {PageStyle.all.first}
|
||||
|
||||
it "finds stye" do
|
||||
spacer = PageStyle.find_by_type("page")
|
||||
expect(spacer).not_to be nil
|
||||
end
|
||||
|
||||
it "has Style.sections" do
|
||||
expect(PageStyle.all.length).to be 1
|
||||
end
|
||||
it "Spacer has no fields" do
|
||||
expect(first.description).not_to be nil
|
||||
end
|
||||
end
|
||||
end
|
@ -1,79 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe Section, type: :model do
|
||||
let(:first) {Section.first}
|
||||
let(:last) {Section.last}
|
||||
|
||||
it "has Sections.all" do
|
||||
expect(Section.all.length).to be 14
|
||||
end
|
||||
it "has index page" do
|
||||
expect(last.class).to be Section
|
||||
end
|
||||
it "has index" do
|
||||
expect(last.index).to eq 10
|
||||
end
|
||||
it "has cards" do
|
||||
expect(last.cards.length).to eq 5
|
||||
end
|
||||
it "has cards array" do
|
||||
expect(last.cards.class).to be ActiveHash::Relation
|
||||
end
|
||||
it "has options" do
|
||||
expect(last.options.class).to be Hash
|
||||
expect(first.options.length).to be 4
|
||||
end
|
||||
it "has option_definitions" do
|
||||
expect(last.option_definitions.class).to be Array
|
||||
expect(last.option_definitions.length).to be 4
|
||||
expect(last.option_definitions.second.class).to be OptionDefinition
|
||||
expect(last.option_definitions.second.name).to eq "handler"
|
||||
end
|
||||
it "last has previous" do
|
||||
expect(last.previous_section.index).to be 9
|
||||
end
|
||||
it "first has no previous" do
|
||||
expect(first.index).to be 1
|
||||
expect(first.previous_section).to be nil
|
||||
end
|
||||
it "first has next" do
|
||||
expect(first.next_section.index).to be 2
|
||||
end
|
||||
it "last has no next" do
|
||||
expect(last.next_section).to be nil
|
||||
end
|
||||
|
||||
it "creates new spacer section" do
|
||||
s = Section.new_section("section_spacer" , 1 , 1)
|
||||
expect(s.template).to eq "section_spacer"
|
||||
end
|
||||
|
||||
it "creates card with right index" do
|
||||
s = Section.find_by_template("section_cards")
|
||||
length = s.cards.length
|
||||
c = s.new_card
|
||||
expect(c.index).to eq length + 1
|
||||
end
|
||||
|
||||
it "deletes " do
|
||||
last_id = last.id
|
||||
last.delete
|
||||
expect{Section.find(last_id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
|
||||
it "destroys " do
|
||||
last_id = last.id
|
||||
last.destroy
|
||||
Section.reload
|
||||
expect{Section.find(last_id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
it "destroys cards" do
|
||||
card_id = last.cards.first.id
|
||||
last.destroy
|
||||
Section.reload
|
||||
expect{Card.find(card_id) }.to raise_error(ActiveHash::RecordNotFound)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,28 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe SectionStyle, type: :model do
|
||||
let(:first_section) {SectionStyle.all.first}
|
||||
|
||||
it "finds stye" do
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
expect(spacer).not_to be nil
|
||||
end
|
||||
|
||||
it "has Style.sections" do
|
||||
expect(SectionStyle.all.length).to be 7
|
||||
end
|
||||
it "Finds section by template" do
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
expect(spacer).not_to eq nil
|
||||
end
|
||||
it "Spacer has no fields" do
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
expect(spacer.fields).to be nil
|
||||
end
|
||||
it "Spacer has no fields" do
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
expect(spacer.fields).to be nil
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user