summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-12-12 17:29:25 +0200
committerValery Sizov <valery@gitlab.com>2016-12-12 17:29:25 +0200
commit3a0fecb4924f1a6dbcc3e61041e0cac95ec3b21b (patch)
tree785fc6ed07680f79f04916ddea4d57f30587b817 /spec/lib/bitbucket
parent314c4746bc24a31efe88b142cd83ab36c3473cc9 (diff)
downloadgitlab-ce-3a0fecb4924f1a6dbcc3e61041e0cac95ec3b21b.tar.gz
Spec for bitbucket page
Diffstat (limited to 'spec/lib/bitbucket')
-rw-r--r--spec/lib/bitbucket/page_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/bitbucket/page_spec.rb b/spec/lib/bitbucket/page_spec.rb
new file mode 100644
index 00000000000..04d5a0470b1
--- /dev/null
+++ b/spec/lib/bitbucket/page_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe Bitbucket::Page do
+ let(:response) { { 'values' => [{ 'username' => 'Ben' }], 'pagelen' => 2, 'next' => '' } }
+
+ before do
+ # Autoloading hack
+ Bitbucket::Representation::User.new({})
+ end
+
+ describe '#items' do
+ it 'returns collection of needed objects' do
+ page = described_class.new(response, :user)
+
+ expect(page.items.first).to be_a(Bitbucket::Representation::User)
+ expect(page.items.count).to eq(1)
+ end
+ end
+
+ describe '#attrs' do
+ it 'returns attributes' do
+ page = described_class.new(response, :user)
+
+ expect(page.attrs.keys).to include(:pagelen, :next)
+ end
+ end
+
+ describe '#next?' do
+ it 'returns true' do
+ page = described_class.new(response, :user)
+
+ expect(page.next?).to be_truthy
+ end
+
+ it 'returns false' do
+ response['next'] = nil
+ page = described_class.new(response, :user)
+
+ expect(page.next?).to be_falsey
+ end
+ end
+
+ describe '#next' do
+ it 'returns next attribute' do
+ page = described_class.new(response, :user)
+
+ expect(page.next).to eq('')
+ end
+ end
+end