Skip to content

Commit

Permalink
Safely include quoted examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Oct 7, 2020
1 parent 401a2b4 commit 7f5c40a
Show file tree
Hide file tree
Showing 26 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion lib/slack/web/api/templates/method_spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RSpec.describe Slack::Web::Api::Endpoints::<%= group.gsub(".", "_").camelize %>
context '<%= group %>_<%= name %>' do
<% required_params.each do |arg_name, arg_v| %>
it 'requires <%= arg_name %>' do
<% params_except_required = required_params.reject{ |name, _| name == arg_name }.map{|var, opts| "#{var}: '#{opts['example'].gsub("'", '"')}'"}.join(', ') %>
<% params_except_required = required_params.reject{ |name, _| name == arg_name }.map{ |var, opts| "#{var}: %q[#{opts['example']}]"}.join(', ') %>
expect { client.<%= group.gsub(".", "_") %>_<%= name %><%= params_except_required.empty? ? '' : "(#{params_except_required})" %> }.to raise_error ArgumentError, /Required arguments :<%= arg_name %> missing/
end
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
let(:client) { Slack::Web::Client.new }
context 'admin.conversations.restrictAccess_addGroup' do
it 'requires channel_id' do
expect { client.admin_conversations_restrictAccess_addGroup(group_id: '') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_restrictAccess_addGroup(group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires group_id' do
expect { client.admin_conversations_restrictAccess_addGroup(channel_id: '') }.to raise_error ArgumentError, /Required arguments :group_id missing/
expect { client.admin_conversations_restrictAccess_addGroup(channel_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
end
end
context 'admin.conversations.restrictAccess_listGroups' do
Expand All @@ -20,13 +20,13 @@
end
context 'admin.conversations.restrictAccess_removeGroup' do
it 'requires channel_id' do
expect { client.admin_conversations_restrictAccess_removeGroup(group_id: '', team_id: '') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_restrictAccess_removeGroup(group_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires group_id' do
expect { client.admin_conversations_restrictAccess_removeGroup(channel_id: '', team_id: '') }.to raise_error ArgumentError, /Required arguments :group_id missing/
expect { client.admin_conversations_restrictAccess_removeGroup(channel_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
end
it 'requires team_id' do
expect { client.admin_conversations_restrictAccess_removeGroup(channel_id: '', group_id: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_conversations_restrictAccess_removeGroup(channel_id: %q[], group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
end
16 changes: 8 additions & 8 deletions spec/slack/web/api/endpoints/admin_conversations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
end
context 'admin.conversations_create' do
it 'requires is_private' do
expect { client.admin_conversations_create(name: 'mychannel') }.to raise_error ArgumentError, /Required arguments :is_private missing/
expect { client.admin_conversations_create(name: %q[mychannel]) }.to raise_error ArgumentError, /Required arguments :is_private missing/
end
it 'requires name' do
expect { client.admin_conversations_create(is_private: 'true') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_conversations_create(is_private: %q[true]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
end
context 'admin.conversations_delete' do
Expand All @@ -45,26 +45,26 @@
end
context 'admin.conversations_invite' do
it 'requires channel_id' do
expect { client.admin_conversations_invite(user_ids: 'U1234,U2345,U3456') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_invite(user_ids: %q[U1234,U2345,U3456]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires user_ids' do
expect { client.admin_conversations_invite(channel_id: 'C12345') }.to raise_error ArgumentError, /Required arguments :user_ids missing/
expect { client.admin_conversations_invite(channel_id: %q[C12345]) }.to raise_error ArgumentError, /Required arguments :user_ids missing/
end
end
context 'admin.conversations_rename' do
it 'requires channel_id' do
expect { client.admin_conversations_rename(name: '') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_rename(name: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires name' do
expect { client.admin_conversations_rename(channel_id: 'C12345') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_conversations_rename(channel_id: %q[C12345]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
end
context 'admin.conversations_setConversationPrefs' do
it 'requires channel_id' do
expect { client.admin_conversations_setConversationPrefs(prefs: '{"who_can_post":"type:admin,user:U1234,subteam:S1234"}') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_setConversationPrefs(prefs: %q[{'who_can_post':'type:admin,user:U1234,subteam:S1234'}]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires prefs' do
expect { client.admin_conversations_setConversationPrefs(channel_id: 'C1234') }.to raise_error ArgumentError, /Required arguments :prefs missing/
expect { client.admin_conversations_setConversationPrefs(channel_id: %q[C1234]) }.to raise_error ArgumentError, /Required arguments :prefs missing/
end
end
context 'admin.conversations_setTeams' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
let(:client) { Slack::Web::Client.new }
context 'admin.conversations.whitelist_add' do
it 'requires channel_id' do
expect { client.admin_conversations_whitelist_add(group_id: '') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_whitelist_add(group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires group_id' do
expect { client.admin_conversations_whitelist_add(channel_id: '') }.to raise_error ArgumentError, /Required arguments :group_id missing/
expect { client.admin_conversations_whitelist_add(channel_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
end
end
context 'admin.conversations.whitelist_listGroupsLinkedToChannel' do
Expand All @@ -20,13 +20,13 @@
end
context 'admin.conversations.whitelist_remove' do
it 'requires channel_id' do
expect { client.admin_conversations_whitelist_remove(group_id: '', team_id: '') }.to raise_error ArgumentError, /Required arguments :channel_id missing/
expect { client.admin_conversations_whitelist_remove(group_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
end
it 'requires group_id' do
expect { client.admin_conversations_whitelist_remove(channel_id: '', team_id: '') }.to raise_error ArgumentError, /Required arguments :group_id missing/
expect { client.admin_conversations_whitelist_remove(channel_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
end
it 'requires team_id' do
expect { client.admin_conversations_whitelist_remove(channel_id: '', group_id: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_conversations_whitelist_remove(channel_id: %q[], group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
end
12 changes: 6 additions & 6 deletions spec/slack/web/api/endpoints/admin_emoji_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
let(:client) { Slack::Web::Client.new }
context 'admin.emoji_add' do
it 'requires name' do
expect { client.admin_emoji_add(url: '') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_emoji_add(url: %q[]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
it 'requires url' do
expect { client.admin_emoji_add(name: '') }.to raise_error ArgumentError, /Required arguments :url missing/
expect { client.admin_emoji_add(name: %q[]) }.to raise_error ArgumentError, /Required arguments :url missing/
end
end
context 'admin.emoji_addAlias' do
it 'requires alias_for' do
expect { client.admin_emoji_addAlias(name: '') }.to raise_error ArgumentError, /Required arguments :alias_for missing/
expect { client.admin_emoji_addAlias(name: %q[]) }.to raise_error ArgumentError, /Required arguments :alias_for missing/
end
it 'requires name' do
expect { client.admin_emoji_addAlias(alias_for: '') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_emoji_addAlias(alias_for: %q[]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
end
context 'admin.emoji_remove' do
Expand All @@ -28,10 +28,10 @@
end
context 'admin.emoji_rename' do
it 'requires name' do
expect { client.admin_emoji_rename(new_name: '') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_emoji_rename(new_name: %q[]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
it 'requires new_name' do
expect { client.admin_emoji_rename(name: '') }.to raise_error ArgumentError, /Required arguments :new_name missing/
expect { client.admin_emoji_rename(name: %q[]) }.to raise_error ArgumentError, /Required arguments :new_name missing/
end
end
end
20 changes: 10 additions & 10 deletions spec/slack/web/api/endpoints/admin_teams_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@
end
context 'admin.teams.settings_setDefaultChannels' do
it 'requires channel_ids' do
expect { client.admin_teams_settings_setDefaultChannels(team_id: '') }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
expect { client.admin_teams_settings_setDefaultChannels(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
end
it 'requires team_id' do
expect { client.admin_teams_settings_setDefaultChannels(channel_ids: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_teams_settings_setDefaultChannels(channel_ids: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
context 'admin.teams.settings_setDescription' do
it 'requires description' do
expect { client.admin_teams_settings_setDescription(team_id: '') }.to raise_error ArgumentError, /Required arguments :description missing/
expect { client.admin_teams_settings_setDescription(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :description missing/
end
it 'requires team_id' do
expect { client.admin_teams_settings_setDescription(description: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_teams_settings_setDescription(description: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
context 'admin.teams.settings_setDiscoverability' do
it 'requires discoverability' do
expect { client.admin_teams_settings_setDiscoverability(team_id: '') }.to raise_error ArgumentError, /Required arguments :discoverability missing/
expect { client.admin_teams_settings_setDiscoverability(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :discoverability missing/
end
it 'requires team_id' do
expect { client.admin_teams_settings_setDiscoverability(discoverability: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_teams_settings_setDiscoverability(discoverability: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
context 'admin.teams.settings_setIcon' do
it 'requires image_url' do
expect { client.admin_teams_settings_setIcon(team_id: '') }.to raise_error ArgumentError, /Required arguments :image_url missing/
expect { client.admin_teams_settings_setIcon(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :image_url missing/
end
it 'requires team_id' do
expect { client.admin_teams_settings_setIcon(image_url: 'http://mysite.com/icon.jpeg') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_teams_settings_setIcon(image_url: %q[http://mysite.com/icon.jpeg]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
context 'admin.teams.settings_setName' do
it 'requires name' do
expect { client.admin_teams_settings_setName(team_id: '') }.to raise_error ArgumentError, /Required arguments :name missing/
expect { client.admin_teams_settings_setName(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :name missing/
end
it 'requires team_id' do
expect { client.admin_teams_settings_setName(name: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_teams_settings_setName(name: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
end
4 changes: 2 additions & 2 deletions spec/slack/web/api/endpoints/admin_teams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
let(:client) { Slack::Web::Client.new }
context 'admin.teams_create' do
it 'requires team_domain' do
expect { client.admin_teams_create(team_name: '') }.to raise_error ArgumentError, /Required arguments :team_domain missing/
expect { client.admin_teams_create(team_name: %q[]) }.to raise_error ArgumentError, /Required arguments :team_domain missing/
end
it 'requires team_name' do
expect { client.admin_teams_create(team_domain: '') }.to raise_error ArgumentError, /Required arguments :team_name missing/
expect { client.admin_teams_create(team_domain: %q[]) }.to raise_error ArgumentError, /Required arguments :team_name missing/
end
end
end
12 changes: 6 additions & 6 deletions spec/slack/web/api/endpoints/admin_usergroups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
let(:client) { Slack::Web::Client.new }
context 'admin.usergroups_addChannels' do
it 'requires channel_ids' do
expect { client.admin_usergroups_addChannels(usergroup_id: 'S00000000') }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
expect { client.admin_usergroups_addChannels(usergroup_id: %q[S00000000]) }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
end
it 'requires usergroup_id' do
expect { client.admin_usergroups_addChannels(channel_ids: 'C00000000,C00000001') }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
expect { client.admin_usergroups_addChannels(channel_ids: %q[C00000000,C00000001]) }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
end
end
context 'admin.usergroups_addTeams' do
it 'requires team_ids' do
expect { client.admin_usergroups_addTeams(usergroup_id: 'S12345678') }.to raise_error ArgumentError, /Required arguments :team_ids missing/
expect { client.admin_usergroups_addTeams(usergroup_id: %q[S12345678]) }.to raise_error ArgumentError, /Required arguments :team_ids missing/
end
it 'requires usergroup_id' do
expect { client.admin_usergroups_addTeams(team_ids: 'T12345678,T98765432') }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
expect { client.admin_usergroups_addTeams(team_ids: %q[T12345678,T98765432]) }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
end
end
context 'admin.usergroups_listChannels' do
Expand All @@ -28,10 +28,10 @@
end
context 'admin.usergroups_removeChannels' do
it 'requires channel_ids' do
expect { client.admin_usergroups_removeChannels(usergroup_id: 'S00000000') }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
expect { client.admin_usergroups_removeChannels(usergroup_id: %q[S00000000]) }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
end
it 'requires usergroup_id' do
expect { client.admin_usergroups_removeChannels(channel_ids: 'C00000000,C00000001') }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
expect { client.admin_usergroups_removeChannels(channel_ids: %q[C00000000,C00000001]) }.to raise_error ArgumentError, /Required arguments :usergroup_id missing/
end
end
end
4 changes: 2 additions & 2 deletions spec/slack/web/api/endpoints/admin_users_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
let(:client) { Slack::Web::Client.new }
context 'admin.users.session_invalidate' do
it 'requires session_id' do
expect { client.admin_users_session_invalidate(team_id: '') }.to raise_error ArgumentError, /Required arguments :session_id missing/
expect { client.admin_users_session_invalidate(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :session_id missing/
end
it 'requires team_id' do
expect { client.admin_users_session_invalidate(session_id: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
expect { client.admin_users_session_invalidate(session_id: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
end
end
context 'admin.users.session_reset' do
Expand Down
Loading

0 comments on commit 7f5c40a

Please sign in to comment.