Sha256: f8cdf4bc95a764626274c34a001c8728731380b48c5e9396968f1232c0b5e82f

Contents?: true

Size: 1.31 KB

Versions: 25

Compression:

Stored size: 1.31 KB

Contents

require 'rails_helper'

shared_examples_for :seo do
  let(:model) { described_class }
  let(:klass) { model.to_s.underscore.to_sym }
  let(:instance) { create(klass) }

  describe '#seo' do
    it 'always returns a meta object' do
      expect(instance.seo(:nl).class).to eq Meta
    end

    describe 'fetch locale specific meta object' do
      it 'new' do
        instance.seo(:nl) == instance.seo(:nl)
      end

      it 'saved' do
        meta = instance.meta.create(locale: 'nl', slug: 'test')
        expect(instance.seo(:nl)).to eq meta
      end
    end
  end

  describe '.find_by_slug' do
    it :result do
      instance.meta.create!(locale: 'nl', slug: 'test')
      expect(model.find_by_slug('test', locale: :nl)).to eq instance
    end

    it 'no result' do
      expect(model.find_by_slug('test', locale: :nl)).to eq nil
    end
  end

  describe '.find_by_slug!' do
    it :result do
      instance.meta.create!(locale: 'nl', slug: 'test')
      expect(model.find_by_slug!('test', locale: :nl)).to eq instance
    end

    it 'no result' do
      expect{ model.find_by_slug!('test', locale: :nl) }.to raise_exception RuntimeError
    end
  end

  it '#respond_to?' do
    expect(build(klass)).to respond_to(:meta, :seo)
  end

  it '.respond_to?' do
    expect(model).to respond_to(:find_by_slug, :find_by_slug!)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
udongo-6.6.3 spec/support/concerns/seo.rb
udongo-6.6.2 spec/support/concerns/seo.rb
udongo-6.6.1 spec/support/concerns/seo.rb
udongo-6.6.0 spec/support/concerns/seo.rb
udongo-6.5.2 spec/support/concerns/seo.rb
udongo-6.5.1 spec/support/concerns/seo.rb
udongo-6.5.0 spec/support/concerns/seo.rb
udongo-6.4.1 spec/support/concerns/seo.rb
udongo-6.4.0 spec/support/concerns/seo.rb
udongo-6.3.2 spec/support/concerns/seo.rb
udongo-6.3.1 spec/support/concerns/seo.rb
udongo-6.3.0 spec/support/concerns/seo.rb
udongo-6.2.1 spec/support/concerns/seo.rb
udongo-6.2.0 spec/support/concerns/seo.rb
udongo-6.1.0 spec/support/concerns/seo.rb
udongo-6.0.0 spec/support/concerns/seo.rb
udongo-5.9.0 spec/support/concerns/seo.rb
udongo-5.8.0 spec/support/concerns/seo.rb
udongo-5.7.0 spec/support/concerns/seo.rb
udongo-5.6.0 spec/support/concerns/seo.rb