-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop giphy dependency #89
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ | |
require 'active_support/core_ext' | ||
require 'hashie' | ||
require 'slack' | ||
require 'giphy' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
require 'giphy' | ||
|
||
Giphy::Configuration.configure do |config| | ||
config.api_key = ENV['GIPHY_API_KEY'] || 'dc6zaTOxFJmzC' # from https://github.com/Giphy/GiphyAPI | ||
begin | ||
require 'giphy' | ||
rescue LoadError | ||
else | ||
Giphy::Configuration.configure do |config| | ||
config.api_key = ENV['GIPHY_API_KEY'] || 'dc6zaTOxFJmzC' # from https://github.com/Giphy/GiphyAPI | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
|
||
RSpec::Matchers.define :respond_with_error do |error, error_message| | ||
match do |actual| | ||
allow(Giphy).to receive(:random) | ||
|
||
client = if respond_to?(:client) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to break downstream users upgrading the library. I think this needs to be put back and have a |
||
send(:client) | ||
else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
RSpec.configure do |config| | ||
config.before :each do | ||
allow(Giphy).to receive(:random) if ENV.key?('WITH_GIPHY') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you fix the above |
||
SlackRubyBot.configure do |c| | ||
c.token = 'testtoken' | ||
c.user = 'rubybot' | ||
c.user_id = 'DEADBEEF' | ||
end | ||
end | ||
|
||
config.after :each do | ||
ENV.delete 'SLACK_RUBY_BOT_SEND_GIFS' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right. If we're not setting it before in this context we shouldn't be deleting it after. |
||
SlackRubyBot::Config.reset! | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
describe SlackRubyBot::Client do | ||
describe '#send_gifs?' do | ||
context 'without giphy is false', unless: ENV.key?('WITH_GIPHY') do | ||
it 'by default' do | ||
expect(subject.send_gifs?).to be false | ||
end | ||
|
||
it 'when set to true' do | ||
subject.send_gifs = true | ||
expect(subject.send_gifs?).to be false | ||
end | ||
|
||
it 'when set to true via config' do | ||
SlackRubyBot::Config.send_gifs = true | ||
expect(SlackRubyBot::Config.send_gifs?).to be false | ||
end | ||
end | ||
|
||
context 'with giphy', if: ENV.key?('WITH_GIPHY') do | ||
it 'default is true' do | ||
expect(subject.send_gifs?).to be true | ||
end | ||
|
||
it 'defaults to SlackRubyBot::Config.send_gifs? if set' do | ||
SlackRubyBot::Config.send_gifs = false | ||
expect(subject.send_gifs?).to be false | ||
end | ||
|
||
it 'client setting takes precedence' do | ||
SlackRubyBot::Config.send_gifs = true | ||
subject.send_gifs = false | ||
expect(subject.send_gifs?).to be false | ||
SlackRubyBot::Config.send_gifs = false | ||
subject.send_gifs = true | ||
expect(subject.send_gifs?).to be true | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just call it
GIPHY
to be consistent withCONCURRENCY
, nbd though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about that as well, but since
CONCURRENCY
is a requirement andgiphy
is optional, I think theWITH_
prefix makes it's purpose a bit more clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!