specs
This commit is contained in:
@@ -48,25 +48,42 @@ shared_examples 'WpItem::Infos' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#changelog_url' do
|
describe '#changelog_url' do
|
||||||
it 'returns the correct url' do
|
after { expect(subject.changelog_url).to eql @expected }
|
||||||
expect(subject.changelog_url).to eq changelog_url
|
|
||||||
|
it 'returns nil' do
|
||||||
|
stub_request(:get, /.*/).to_return(status: 404)
|
||||||
|
@expected = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the file exists' do
|
||||||
|
%w{changelog.txt CHANGELOG.md}.each do |changelog|
|
||||||
|
it 'returns the correct url' do
|
||||||
|
url = uri.merge(changelog).to_s
|
||||||
|
@expected = url
|
||||||
|
|
||||||
|
stub_request(:get, %r{^(?!#{url})}).to_return(status: 404)
|
||||||
|
stub_request(:get, url).to_return(status: 200)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#has_changelog?' do
|
describe '#has_changelog?' do
|
||||||
after :each do
|
after do
|
||||||
stub_request(:get, subject.changelog_url).to_return(status: @status)
|
allow(subject).to receive_messages(changelog_url: @stub)
|
||||||
expect(subject.has_changelog?).to eql @expected
|
expect(subject.has_changelog?).to eql @expected
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true on a 200' do
|
context 'when changelog_url is nil'
|
||||||
@status = 200
|
it 'returns false' do
|
||||||
@expected = true
|
@stub = nil
|
||||||
|
@expected = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false otherwise' do
|
context 'when changelog_url is not nil'
|
||||||
@status = 404
|
it 'returns true' do
|
||||||
@expected = false
|
@stub = uri.merge('changelog.txt').to_s
|
||||||
|
@expected = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user