Commit 3a0fecb4 authored by Valery Sizov's avatar Valery Sizov

Spec for bitbucket page

parent 314c4746
...@@ -23,6 +23,7 @@ module Bitbucket ...@@ -23,6 +23,7 @@ module Bitbucket
def parse_values(raw, bitbucket_rep_class) def parse_values(raw, bitbucket_rep_class)
return [] unless raw['values'] && raw['values'].is_a?(Array) return [] unless raw['values'] && raw['values'].is_a?(Array)
bitbucket_rep_class.decorate(raw['values']) bitbucket_rep_class.decorate(raw['values'])
end end
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment