Add Github tests
This commit is contained in:
parent
0f2013f002
commit
067097825f
3 changed files with 142 additions and 0 deletions
26
spec/lib/github/api_spec.rb
Normal file
26
spec/lib/github/api_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Github::API do
|
||||
|
||||
describe '.base_uri' do
|
||||
it { expect(described_class.base_uri).to eq 'https://api.github.com' }
|
||||
end
|
||||
|
||||
describe '.latest_release' do
|
||||
subject { described_class.latest_release }
|
||||
|
||||
context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do
|
||||
it { expect(subject).to be_a RestClient::Response }
|
||||
it { expect(subject.code).to eq 200 }
|
||||
end
|
||||
|
||||
context 'when github is down' do
|
||||
|
||||
before do
|
||||
allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden)
|
||||
end
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
23
spec/lib/github/releases_spec.rb
Normal file
23
spec/lib/github/releases_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Github::Releases do
|
||||
|
||||
describe '.latest' do
|
||||
|
||||
subject { described_class.latest }
|
||||
|
||||
context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do
|
||||
it { expect(subject.url).to eq 'https://api.github.com/repos/sgmap/tps/releases/4685573' }
|
||||
it { expect(subject.body).to match /.*[Nouveautés].*/ }
|
||||
it { expect(subject.published_at).to match /[0-9][0-9][\/][0-9][0-9][\/][0-9][0-9][0-9][0-9]/ }
|
||||
end
|
||||
|
||||
context 'when github is down' do
|
||||
before do
|
||||
allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden)
|
||||
end
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue