File: gist_spec.rb

package info (click to toggle)
ruby-octokit 10.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,092 kB
  • sloc: ruby: 13,339; sh: 99; makefile: 7; javascript: 3
file content (46 lines) | stat: -rw-r--r-- 979 bytes parent folder | download | duplicates (2)
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