Skip to content

Commit c8ab655

Browse files
author
esteban zapata
committed
Remove anonymous support due to deprecation.
Fixes #275 This change is needed due to the deprecation warning/removal made by Github on the gist tool. See https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/ for more info.
1 parent 249fb99 commit c8ab655

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

lib/gist.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def multi_gist(files, options={})
127127

128128
existing_gist = options[:update].to_s.split("/").last
129129
if options[:anonymous]
130-
access_token = nil
130+
raise 'Anonymous gist support has been removed by Github. ' \
131+
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'
131132
else
132133
access_token = (options[:access_token] || auth_token())
133134
end

spec/rawify_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
end
77

88
it "should return the raw file url" do
9-
Gist.gist("Test gist", :output => :raw_url, :anonymous => true).should == "https://gist.github.com/anonymous/XXXXXX/raw"
9+
Gist.gist("Test gist", :output => :raw_url, :anonymous => false).should == "https://gist.github.com/anonymous/XXXXXX/raw"
10+
end
11+
12+
it 'should raise an error when trying to do operations without being logged in' do
13+
error_msg = 'Anonymous gist support has been removed by Github. ' \
14+
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'
15+
16+
expect do
17+
Gist.gist("Test gist", output: :raw_url, anonymous: true)
18+
end.to raise_error(StandardError, error_msg)
1019
end
1120
end
1221

spec/shorten_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55

66
it "should return a shortened version of the URL when response is 200" do
77
stub_request(:post, "https://git.io/create").to_return(:status => 200, :body => 'XXXXXX')
8-
Gist.gist("Test gist", :output => :short_url, :anonymous => true).should == "https://git.io/XXXXXX"
8+
Gist.gist("Test gist", :output => :short_url, anonymous: false).should == "https://git.io/XXXXXX"
99
end
1010

1111
it "should return a shortened version of the URL when response is 201" do
1212
stub_request(:post, "https://git.io/create").to_return(:status => 201, :headers => { 'Location' => 'https://git.io/XXXXXX' })
13-
Gist.gist("Test gist", :output => :short_url, :anonymous => true).should == "https://git.io/XXXXXX"
13+
Gist.gist("Test gist", :output => :short_url, anonymous: false).should == "https://git.io/XXXXXX"
14+
end
15+
16+
it 'should raise an error when trying to get short urls without being logged in' do
17+
error_msg = 'Anonymous gist support has been removed by Github. ' \
18+
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'
19+
20+
expect do
21+
Gist.gist("Test gist", output: :short_url, anonymous: true)
22+
end.to raise_error(StandardError, error_msg)
1423
end
1524
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
mocks.syntax = :should
1212
end
1313
config.expect_with :rspec do |expectations|
14-
expectations.syntax = :should
14+
expectations.syntax = [:should, :expect]
1515
end
1616
end
1717

0 commit comments

Comments
 (0)