-
Notifications
You must be signed in to change notification settings - Fork 27
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
Ports - Amy & Ngoc #11
base: master
Are you sure you want to change the base?
Conversation
slack.rbWhat We're Looking For
|
require "table_print" | ||
require "httparty" | ||
require "colorize" | ||
require_relative "workspace" |
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.
You end up having some circular references here. It's important that you try to avoid having file A require file B and then file B requiring file A. That will give you a warning and it's bad form as if the interpreter wasn't well written it could lead to an infinite loop.
puts "Welcome to the Ada Slack CLI!" | ||
work_space = Workspace.new | ||
puts "Welcome to the Ada Slack CLI!".colorize(:color => :blue, :mode => :bold) | ||
puts "\nPlease Choose from the following options:\n1. List Users\n2. List Channels\n3. Select User\n4. Select Channel\n5. Details\n6. Send Message\n7. Quit".colorize(:color => :blue, :mode => :bold) |
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.
Just a note, if you put numbers in front of the options, people want to use the number to select the option.
if channel_info["ok"] == false | ||
raise ArgumentError, "The error code is #{channel_info.code} and the reason is: #{channel_info.message}" | ||
end | ||
return channel_info |
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.
Instead of returning the hash about the channel, I suggest returning a new Channel instance.
Something like:
return Channel.new(channel_info["name", channel_info["id"], channel_info["topic"], channel_info["members"])
Also is this method necessary? You already have a method to get a list of Channels, so why have a method to get the details about one?
if @user_info["ok"] == false | ||
raise ArgumentError, "The error code is #{@user_info.code} and the reason is: #{@user_info["error"]}" | ||
end | ||
return @user_info |
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.
Similar questions to the method in channel.rb
it "selects a known user by username" do | ||
VCR.use_cassette("Workspace") do | ||
response = Workspace.new | ||
response.select_user("ngocle") |
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.
These values that you are using over and over again would make great constants to have at the top. That way if you changed slack orgs you could just change a few constants and the tests would work.
end | ||
|
||
describe "Workspace#show_details" do | ||
it "shows details of the selected channel" do |
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.
You should also have a test that tests what happens when details is called and nothing has been selected.
end | ||
end | ||
describe "Workspace#send_message" do | ||
it "can send a valid message to a channel" do |
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.
You should also test send_message
if no user/channel has been selected.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions