Sha256: 7c4ab87f26fcca8a570125d6f170e68ce53f3cbbbc56976da0fd73ce11d3c705

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

module Landable
  describe Template do
    describe 'validators' do
      # some valid seed data
      before(:each) { create :template }

      it { should validate_presence_of :name }
      it { should validate_presence_of :description }
      it { should validate_presence_of :slug }
      it { should validate_uniqueness_of :slug }
    end

    describe '#name=' do
      context 'without a slug' do
        it 'should assign a slug' do
          template = build(:template, slug: nil)
          template.name = 'Six Seven'
          template.name.should == 'Six Seven'
          template.slug.should == 'six_seven'
        end
      end

      context 'with a slug' do
        it 'should leave the slug alone' do
          template = build(:template, slug: 'six')
          template.name = 'seven'
          template.name.should == 'seven'
          template.slug.should == 'six'
        end
      end
    end

    describe '#partial?' do
      it 'returns true when template references a file' do
        template = create :template, :partial
        template.partial?.should be_true
      end

      it 'returns false when template has no file' do
        template = create :template
        template.partial?.should be_false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
landable-1.7.0 spec/models/landable/template_spec.rb