spec/unit/models/paginated_resource_spec.rb in ably-0.7.0 vs spec/unit/models/paginated_resource_spec.rb in ably-0.7.1
- old
+ new
@@ -42,10 +42,24 @@
it 'is iterable' do
expect(subject.map { |d| d }).to eql(body)
end
+ context '#each' do
+ it 'returns an enumerator' do
+ expect(subject.each).to be_a(Enumerator)
+ end
+
+ it 'yields each item' do
+ items = []
+ subject.each do |item|
+ items << item
+ end
+ expect(items).to eq(body)
+ end
+ end
+
it 'provides [] accessor method' do
expect(subject[0][:id]).to eql(body[0][:id])
expect(subject[1][:id]).to eql(body[1][:id])
expect(subject[2]).to be_nil
end
@@ -112,10 +126,10 @@
expect(next_page[0][:added_attribute_from_block]).to eql("id:#{body_page2[0][:id]}")
expect(next_page[0][:id]).to_not eql(page_1_first_id)
end
end
- if defined?(EventMachine)
+ if defined?(Ably::Realtime)
context 'with option async_blocking_operations: true' do
include RSpec::EventMachine
subject do
paginated_resource_class.new(http_response, full_url, paged_client, async_blocking_operations: true)