spec/unit/models/paginated_resource_spec.rb in ably-0.6.2 vs spec/unit/models/paginated_resource_spec.rb in ably-0.7.0
- old
+ new
@@ -56,20 +56,20 @@
specify '#last gets the last item in page' do
expect(subject.last[:id]).to eql(body[1][:id])
end
- context 'with coercion' do
+ context 'with coercion', :api_private do
let(:paginated_resource_options) { { coerce_into: 'OpenStruct' } }
it 'returns coerced objects' do
expect(subject.first).to be_a(OpenStruct)
expect(subject.first.id).to eql(body.first[:id])
end
end
- context 'paged transformations' do
+ context 'paged transformations', :api_private do
let(:headers) do
{
'link' => [
'<./history?index=1>; rel="next"'
].join(', ')
@@ -112,42 +112,44 @@
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
- context 'with option async_blocking_operations: true' do
- include RSpec::EventMachine
+ if defined?(EventMachine)
+ 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)
- end
-
- context '#next_page' do
- it 'returns a deferrable object' do
- run_reactor do
- expect(subject.next_page).to be_a(EventMachine::Deferrable)
- stop_reactor
- end
+ subject do
+ paginated_resource_class.new(http_response, full_url, paged_client, async_blocking_operations: true)
end
- it 'allows a success callback block to be added' do
- run_reactor do
- subject.next_page do |paginated_resource|
- expect(paginated_resource).to be_a(Ably::Models::PaginatedResource)
+ context '#next_page' do
+ it 'returns a deferrable object' do
+ run_reactor do
+ expect(subject.next_page).to be_a(EventMachine::Deferrable)
stop_reactor
end
end
- end
- end
- context '#first_page' do
- it 'calls the errback callback when first page headers are missing' do
- run_reactor do
- subject.next_page do |paginated_resource|
- deferrable = subject.first_page
- deferrable.errback do |error|
- expect(error).to be_a(Ably::Exceptions::InvalidPageError)
+ it 'allows a success callback block to be added' do
+ run_reactor do
+ subject.next_page do |paginated_resource|
+ expect(paginated_resource).to be_a(Ably::Models::PaginatedResource)
stop_reactor
+ end
+ end
+ end
+ end
+
+ context '#first_page' do
+ it 'calls the errback callback when first page headers are missing' do
+ run_reactor do
+ subject.next_page do |paginated_resource|
+ deferrable = subject.first_page
+ deferrable.errback do |error|
+ expect(error).to be_a(Ably::Exceptions::InvalidPageError)
+ stop_reactor
+ end
end
end
end
end
end