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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Ruby 3.0] improve specs for Slack action #18512
[Ruby 3.0] improve specs for Slack action #18512
Conversation
b25addd
to
c82b36a
Compare
c82b36a
to
40ca684
Compare
def self.generate_slack_attachments(options) | ||
UI.deprecation('`Fastlane::Actions::Slack.generate_slack_attachments` is subject to be removed as Slack recommends migrating `attachments` to Block Kit. fastlane will also the same direction.') | ||
Runner.generate_slack_attachments(options) |
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've got feedback to keep this method working here.
#18537 (comment)
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 UX comment, other than that this PR LGTM 馃挭
end | ||
a.merge(b, &merger) | ||
def self.generate_slack_attachments(options) | ||
UI.deprecated('`Fastlane::Actions::Slack.generate_slack_attachments` is subject to be removed as Slack recommends migrating `attachments` to Block Kit. fastlane will also follow the same direction.') |
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.
Since we don't support Block Kit yet (do we?), I'm concerned to be marking something as deprecated without offering an alternative to users yet 馃
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.
What do you think about this?
#18512 (comment)
I guess UI.deprecated
is not necessarily meant to provide alternatives and can be used to announce future removal 馃 I mean most users won't see this message. Only plugin users whose plugins refer to this method directly, like this plugin, will see it.
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.
This is such a high quality code change! I鈥檓 learning so much about better code architecture from you 馃槏
Congratulations! 馃帀 This was released as part of fastlane 2.181.0 馃殌 |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
As per the plan #17931 for Ruby 3.0, I've been working on fixing Ruby 2.7's deprecation warnings which will crash on Ruby 3.0. There is an issue where one of the fastlane's dependencies
slack-notifier
, which is not maintained any more, keeps producing that warning.There would be some options in solving that issue -
fastlane-slack-notifier
In my opinion, 1 is too little hope and 2 would be too much. I would go with 3 as I've got this rewritten one tailored for fastlane's use-case within 60 LoC, which I think is fair to have its own implementation. #18537
So, in order to migrate the Slack action, I'd like to prepare for it by improving the testability of it. Prior to this PR,
slack_spec.rb
uses a hack that makes it return specific objects to verify instead of performing its process entirely. That pulls outSlack::Notifier
object from the gem to unit tests. Meaning the unit tests will be completely broken when removing the dependency. This PR makes the test cases independent from the gem.Description
There are two parts to this PR. The first one is to extract logic in
Fastlane::SlackAction.run
into a runner class that allows me to mock a network request to Slack byexpect(..).to receive(...).with(...)
inrspec-mocks
. It is a simpler approach than using theHelper.test?
hack. The second one is to use argument matcher to describe what parameters are given to the method handling network requests without having to depend onslack-notifier
gem.Argument Matcher is much more descriptive than using many assertions to verify a big
Hash
object馃檨Testing Steps
Add a lane like below to
fastlane/Fastfile
in this repo's clone.