Sha256: d04fa63ea835b9abb9890e2bc29315b98dfe5fa3eb3d3eb528b4d4d1ff00db23

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

require 'spec_helper'

RSpec.describe Fish0::Repository do
  let(:repository) { Fish0::Repository.new('articles') }
  let(:scoped_repository) { Fish0::Repository.new('articles') }

  describe '#scope' do
    before do
      scoped_repository.scope :by_slug, -> (slug) { where(slug: slug) }
    end

    it 'has no scoped method :by_slug for new repository' do
      expect(repository).not_to respond_to(:by_slug)
    end

    it 'has scoped method :by_slug for scoped repository' do
      expect(scoped_repository).to respond_to(:by_slug)
    end

    it 'returns self and therefore supports chaining' do
      expect(scoped_repository.by_slug('news')).to be_an(Fish0::Repository)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fish0-0.1.2 spec/lib/repository_spec.rb
fish0-0.1.1 spec/lib/repository_spec.rb
fish0-0.1.0 spec/lib/repository_spec.rb
fish0-0.0.18 spec/lib/repository_spec.rb
fish0-0.0.17 spec/lib/repository_spec.rb