Sha256: f849a15e7420ac644f958d02ce7ed64b5101604ed8fe4a5311be1d6ee6267d3c
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe Emites::Entities::Collection do let(:json) { File.read('spec/fixtures/nfse_list.json') } let(:response) { double(parsed_body: MultiJson.load(json)) } subject { described_class.new(response, Emites::Entities::Nfse) } describe '#build' do it 'returns self' do expect(subject.build).to eq(subject) end it 'builds a nfse collection' do expect(subject.build.count).to eq(3) expect(subject.build.first.class).to eq(Emites::Entities::Nfse) end end describe '#next_page' do it 'returns next page (3)' do expect(subject.next_page).to eq(3) end context 'when there is no next page' do let(:response) { double(parsed_body: {}) } it 'returns nil' do expect(subject.next_page).to be_nil end end end describe '#previous_page' do it 'returns previous page (1)' do expect(subject.previous_page).to eq(1) end context 'when there is no previous page' do let(:response) { double(parsed_body: {}) } it 'returns nil' do expect(subject.previous_page).to be_nil end end end describe '#total' do it 'returns one thousand' do expect(subject.total).to eq(1000) end end describe "#to_a" do it 'returns the collection as an array' do expect(subject.to_a).to be_a(Array) expect { subject.to_a.clear }.not_to change { subject.count } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
emites-client-0.1.4 | spec/emites/entities/collection_spec.rb |
emites-client-0.1.3 | spec/emites/entities/collection_spec.rb |
emites-client-0.1.2 | spec/emites/entities/collection_spec.rb |