Sha256: e8ebc248b96bb8d55174d0039c1711a7f389da3b3129369487bc75c95f5db366

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

require 'spec_helper'

describe Datagrid::Core do

  context 'with 2 persisted entries' do
    before { 2.times { Entry.create } }

    let(:limit) { Entry.limit(1) }
    let(:report_class) do
      test_report_class do
        scope { Entry }
      end
    end

    describe '#scope' do
      context 'in the class' do
        let(:report) { report_class.new }

        it { expect(report.scope).to have(2).item }
      end

      context 'changes scope on the fly' do
        let(:report) do
          report_class.new.tap do |r|
            r.scope { limit }
          end
        end

        it { expect(report.scope).to have(1).item }
      end

      context 'changes scope by initializer' do
        let(:report) { report_class.new { limit } }

        it { expect(report.scope).to have(1).item }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datagrid-0.9.2 spec/datagrid/core_spec.rb