diff options
author | Valery Sizov <valery@gitlab.com> | 2016-12-12 18:20:23 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-12-12 18:20:23 +0200 |
commit | c45484ba193baa811e50aaa106a2c0ed3721d6e8 (patch) | |
tree | 9a8bd3c49462f82cdec905800c68793da278dc7b /spec/lib/bitbucket | |
parent | 3a0fecb4924f1a6dbcc3e61041e0cac95ec3b21b (diff) | |
download | gitlab-ce-c45484ba193baa811e50aaa106a2c0ed3721d6e8.tar.gz |
Spec for Bitbucket::Paginator
Diffstat (limited to 'spec/lib/bitbucket')
-rw-r--r-- | spec/lib/bitbucket/paginator_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/bitbucket/paginator_spec.rb b/spec/lib/bitbucket/paginator_spec.rb new file mode 100644 index 00000000000..2c972da682e --- /dev/null +++ b/spec/lib/bitbucket/paginator_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Bitbucket::Paginator do + let(:last_page) { double(:page, next?: false, items: ['item_2']) } + let(:first_page) { double(:page, next?: true, next: last_page, items: ['item_1']) } + + describe 'items' do + it 'return items and raises StopIteration in the end' do + paginator = described_class.new(nil, nil, nil) + + allow(paginator).to receive(:fetch_next_page).and_return(first_page) + expect(paginator.items).to match(['item_1']) + + allow(paginator).to receive(:fetch_next_page).and_return(last_page) + expect(paginator.items).to match(['item_2']) + + allow(paginator).to receive(:fetch_next_page).and_return(nil) + expect{ paginator.items }.to raise_error(StopIteration) + end + end +end |