1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
# frozen_string_literal: true
describe Octokit::Gist do
context 'when given a URL' do
it 'sets the id' do
gist = Octokit::Gist.from_url('https://gist.github.com/12345')
expect(gist.id).to eq('12345')
end
end
context 'when passed a string ID' do
before do
@gist = Octokit::Gist.new('12345')
end
it 'sets the gist ID' do
expect(@gist.id).to eq('12345')
end
it 'sets the url' do
expect(@gist.url).to eq('https://gist.github.com/12345')
end
it 'renders id as string' do
expect(@gist.to_s).to eq(@gist.id)
end
end
context 'when passed a Integer ID' do
before do
@gist = Octokit::Gist.new(12_345)
end
it 'sets the gist ID as a string' do
expect(@gist.id).to eq('12345')
end
it 'sets the url' do
expect(@gist.url).to eq('https://gist.github.com/12345')
end
it 'renders id as string' do
expect(@gist.to_s).to eq(@gist.id)
end
end
end
|