Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
a53b3cc9e97d
Commit
3a0fecb4
authored
Dec 12, 2016
by
Valery Sizov
Browse files
Spec for bitbucket page
parent
e661ca9618eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/bitbucket/page.rb
View file @
a53b3cc9
...
...
@@ -23,6 +23,7 @@ def parse_attrs(raw)
def
parse_values
(
raw
,
bitbucket_rep_class
)
return
[]
unless
raw
[
'values'
]
&&
raw
[
'values'
].
is_a?
(
Array
)
bitbucket_rep_class
.
decorate
(
raw
[
'values'
])
end
...
...
spec/lib/bitbucket/page_spec.rb
0 → 100644
View file @
a53b3cc9
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment