Sha256: f95649b041720eddbe85d53c826408946598a737f595090ea143a5caa0c33e2d

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module BitCore
  describe ContentProvider do
    describe "validations" do
      it "should validate the existence of the template path" do
        p = ContentProvider.new(template_path: "foobaz")
        p.valid?

        expect(p.errors[:template_path].length).to eq 1

        p.template_path = "layouts"
        p.valid?

        expect(p.errors[:template_path].length).to eq 0
      end

      it "should validate the existence of the data class" do
        p = ContentProvider.new(data_class_name: "foobaz")
        p.valid?

        expect(p.errors[:data_class_name].length).to eq 1

        p.data_class_name = "BitCore::ContentProvider"
        p.valid?

        expect(p.errors[:data_class_name].length).to eq 0
      end

      it "should validate the existence of the data attributes" do
        p = ContentProvider.new(
          data_class_name: "BitCore::Tool",
          data_attributes: %w(baz)
        )
        p.valid?

        expect(p.errors[:data_attributes].length).to eq 1

        p.data_attributes = %w(id title)
        p.valid?

        expect(p.errors[:data_attributes].length).to eq 0
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bit_core-1.4.7 spec/models/bit_core/content_provider_spec.rb
bit_core-2.0.0.beta2 spec/models/bit_core/content_provider_spec.rb