Sha256: 1b31e492279ddba1b2d3437a8e7b3f531fc85d9dcdcf05471e2072bac09aa934
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' require_relative '../../../../../lib/locomotive/steam/adapters/filesystem/yaml_loader.rb' require_relative '../../../../../lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb' describe Locomotive::Steam::Adapters::Filesystem::YAMLLoaders::ContentEntry do let(:site_path) { default_fixture_site_path } let(:content_type) { instance_double('Bands', _id: 42, slug: 'bands', associations: [], selects: []) } let(:scope) { instance_double('Scope', locale: :en, context: { content_type: content_type }) } let(:loader) { described_class.new(site_path) } describe '#load' do subject { loader.load(scope).sort { |a, b| a[:_label] <=> b[:_label] } } it 'tests various stuff' do expect(subject.size).to eq 3 expect(subject.first[:_label]).to eq 'Alice in Chains' expect(subject.first[:content_type]).to eq nil end context 'a content type with a belongs_to field' do let(:field) { instance_double('Field', name: 'band', type: :belongs_to) } let(:content_type) { instance_double('Songs', slug: 'songs', associations: [field], selects: []) } it 'adds a new attribute for the foreign key' do expect(subject.first[:band_id]).to eq 'pearl-jam' expect(subject.first[:band]).to eq nil expect(subject.first[:position_in_band]).to eq 0 end end context 'a content type with a select field' do let(:field) { instance_double('Field', name: 'kind', type: :select) } let(:content_type) { instance_double('Bands', slug: 'bands', selects: [field], associations: []) } it 'adds a new attribute for the foreign key' do expect(subject.first[:kind_id]).to eq 'grunge' expect(subject.first[:kind]).to eq nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems