Sha256: 6affc6466e14fbcb839458d8c74d4c0db04ec49dcdc73d7d49696ddeebff49c4
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
if respond_to?(:require_relative, true) require_relative 'common' else require File.dirname(__FILE__) + '/common' end describe RestGraph do after do reset_webmock RR.verify end it 'would get the next/prev page' do rg = RestGraph.new %w[next previous].each{ |type| kind = "#{type}_page" rg.send(kind, {}) .should == nil rg.send(kind, {'paging' => []}).should == nil rg.send(kind, {'paging' => {}}).should == nil mock(rg).request(:get, 'zzz', {}){ 'ok' } rg.send(kind, {'paging' => {type => 'zzz'}}).should == 'ok' } end it 'would merge all pages into one' do rg = RestGraph.new %w[next previous].each{ |type| kind = "#{type}_page" data = {'paging' => {type => 'zzz'}, 'data' => ['z']} # invalid pages or just the page itself (-1..1).each{ |page| rg.for_pages(data, page, kind).should == data } (2..4).each{ |pages| # merge data mock(rg).request(:get, 'zzz', {}){ {'data' => ['y']} } rg.for_pages(data, pages, kind).should == {'data' => %w[z y]} # this data cannot be merged mock(rg).request(:get, 'zzz', {}){ {'data' => 'y'} } rg.for_pages(data, pages, kind).should == {'data' => %w[z]} } mock(rg).request(:get, 'zzz', {}){ {'paging' => {type => 'yyy'}, 'data' => ['y']} } mock(rg).request(:get, 'yyy', {}){ {'data' => ['x']} } rg.for_pages(data, 3, kind).should == {'data' => %w[z y x]} } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rest-graph-1.5.0 | test/test_page.rb |