Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/pexels/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Pexels::Photo
:url,
:user,
:src,
:avg_color
:avg_color,
:alt

def initialize(attrs)
@id = attrs.fetch('id')
Expand All @@ -19,7 +20,7 @@ def initialize(attrs)
)
@src = attrs.fetch('src')
@avg_color = attrs.fetch('avg_color')

@alt = attrs.fetch('alt')
rescue KeyError => exception
raise Pexels::MalformedAPIResponseError.new(exception)
end
Expand Down
1 change: 1 addition & 0 deletions test/photo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_get_photo
assert_equal photo.user.id, @photo.user.id
assert_equal photo.src, @photo.src
assert_equal photo.avg_color, @photo.avg_color
assert_equal photo.alt, @photo.alt

assert photo.photo?
assert_equal photo.type, 'Photo'
Expand Down