Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#583](https://github.com/slack-ruby/slack-ruby-client/pull/583): Not found errors raised by id_for use more specific error classes when they exist - [@eizengan](https://github.com/eizengan).
* [#585](https://github.com/slack-ruby/slack-ruby-client/pull/585): Fix ci not triggering on automated api update prs - [@Copilot](https://github.com/Copilot).
* [#588](https://github.com/slack-ruby/slack-ruby-client/pull/588): Fix text/markdown_text mutual exclusion in chat methods - [@dblock](https://github.com/dblock).
* [#589](https://github.com/slack-ruby/slack-ruby-client/pull/589): Fix Ruby-version-dependent hash literal syntax in generated specs - [@dblock](https://github.com/dblock).
* Your contribution here.

### 3.1.0 (2025/11/15)
Expand Down
17 changes: 16 additions & 1 deletion lib/slack/web/api/templates/method_spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ require 'spec_helper'

RSpec.describe Slack::Web::Api::Endpoints::<%= group.gsub(".", "_").camelize %> do
let(:client) { Slack::Web::Client.new }
<%
# Renders a Ruby literal as source code deterministically, regardless of the
# Ruby version used to run the generator (Hash#inspect's format for symbol
# keys changed in Ruby 3.4, which would otherwise cause spurious diffs).
ruby_literal = lambda do |val|
case val
when Hash
"{#{val.map { |k, v| "#{k}: #{ruby_literal.call(v)}" }.join(', ')}}"
when Array
"[#{val.map { |v| ruby_literal.call(v) }.join(', ')}]"
else
val.inspect
end
end
%>
<% names.sort.each_with_index do |(name, data), index| %>
<% next if data['mixin'] %>
<% group_required_params = data['arg_groups']&.map { |grp| grp['args'].first if grp['args'].size > 1 } || [] %>
Expand Down Expand Up @@ -59,7 +74,7 @@ RSpec.describe Slack::Web::Api::Endpoints::<%= group.gsub(".", "_").camelize %>
<% end %>
<% if json_params.any? %>
<% example_json_params = json_params.to_h { |name| [name, {data: ['data']}] } %>
<% params = example_params.merge(example_json_params).map { |name, val| val = val.is_a?(String) ? "%q[#{val}]" : val; "#{name}: #{val}" }.join(', ') %>
<% params = example_params.merge(example_json_params).map { |name, val| val = val.is_a?(String) ? "%q[#{val}]" : ruby_literal.call(val); "#{name}: #{val}" }.join(', ') %>
<% expected_params = example_params.merge(example_json_params.transform_values { |v| JSON.dump(v) }).map { |name, val| val = "%q[#{val}]"; "#{name}: #{val}" }.join(', ') %>
it 'encodes <%= json_params.join(', ') %> as json' do
expect(client).to receive(:post).with('<%= group %>.<%= name %>', {<%= expected_params %>})
Expand Down
Loading