Sha256: 6199f78f24909ce0f8f56b4a12c370bb38cca958e027027a5cc691ab7810da41

Contents?: true

Size: 917 Bytes

Versions: 5

Compression:

Stored size: 917 Bytes

Contents

require 'spec_helper'

describe Encore::Serializer do
  let(:serializer) { Encore::Serializer::Instance }
  let(:objects) { User.all }
  let(:serialized) { serializer.new(objects, skip_paging: true).as_json }

  let(:run_migrations!) do
    run_migration do
      create_table(:users, force: true) do |t|
        t.string :name, default: nil
        t.string :discarded_attribute, default: nil
      end
    end
  end

  let(:spawn_objects!) do
    spawn_model('User')
    spawn_serializer('UserSerializer') do
      attributes :name
    end
  end

  let(:create_records!) do
    User.create name: 'Allan'
    User.create name: 'Doe'
    User.create name: 'Ding'
    User.create name: 'Bob'
  end

  before do
    expect(User).to receive(:page).never
    run_migrations!
    spawn_objects!
    create_records!
  end

  it { expect(serialized[:meta]).to eq({}) }
  it { expect(serialized[:users].count).to eq(4) }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
encore-0.2.3 spec/encore/serializer/no_paging_spec.rb
encore-0.2.2 spec/encore/serializer/no_paging_spec.rb
encore-0.2.1 spec/encore/serializer/no_paging_spec.rb
encore-0.2 spec/encore/serializer/no_paging_spec.rb
encore-0.1 spec/encore/serializer/no_paging_spec.rb