Sha256: 7882df52aab752c682745e43370faa92d8d8a8f9bdf32c3ddf3438ee08032bc2

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8

require 'spec_helper'

shared_context 'lupo' do
  subject { klass.new(entries) }

  let(:entries) { [42] }

  it 'provides an #each method' do
    expect { |b| subject.each(&b) }.to yield_successive_args(*entries)
  end

  it 'includes Enumerable' do
    expect(subject).to be_kind_of(Enumerable)
  end

  it 'works without a block' do
    expect(subject.each).to be_instance_of(Enumerator)
  end

  it 'returns self from #each' do
    expect(subject.each {}).to be(subject)
  end
end

describe Lupo do
  context '.enumerable' do
    include_context 'lupo'

    let(:klass) do
      Class.new do
        include Lupo.enumerable(:entries)
        def initialize(entries)
          @entries = entries
        end
      end
    end
  end

  context '.collection' do
    include_context 'lupo'

    let(:klass) do
      Class.new do
        include Lupo.collection(:entries)
      end
    end

    it 'should include a concord instance' do
      expect(klass.ancestors).to include(Concord.new(:entries))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lupo-0.0.1 spec/lupo_spec.rb