Skip to content

Commit

Permalink
Merge pull request #48 from MaximeD/fix_blank_source_code_uri
Browse files Browse the repository at this point in the history
FIX rubygems returning blank values
  • Loading branch information
MaximeD committed Oct 27, 2015
2 parents db27015 + 72ed332 commit e313de2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# master (unreleased)

Fix:
* considering `''` as a valid url to parse

# 0.4.3 (October 15, 2015)

Enhancement:
Expand Down
6 changes: 5 additions & 1 deletion lib/gem_updater/ruby_gems_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def uri_from_rubygems
end

if response
response[ "source_code_uri" ] || response[ "homepage_uri" ]
response[
%w( source_code_uri homepage_uri ).find do |key|
response[ key ] && !response[ key ].empty?
end
]
end
end

Expand Down
14 changes: 13 additions & 1 deletion spec/gem_updater/ruby_gems_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end
end

context 'none is present' do
context 'when none is present' do
before do
allow( subject ).to receive_message_chain( :open, :read ) { {}.to_json }
allow( subject ).to receive( :uri_from_other_sources )
Expand All @@ -49,6 +49,18 @@
expect( subject ).to have_received( :uri_from_other_sources )
end
end

context 'when both returns empty string' do
before do
allow( subject ).to receive_message_chain( :open, :read ) { { source_code_uri: '', homepage_uri: '' }.to_json }
allow( subject ).to receive( :uri_from_other_sources )
subject.source_uri
end

it 'looks in other sources' do
expect( subject ).to have_received( :uri_from_other_sources )
end
end
end

context 'when gem does not exists on rubygems.org' do
Expand Down

0 comments on commit e313de2

Please sign in to comment.