Skip to content

Commit

Permalink
add a spec for using all params, rename the valid_params to required_…
Browse files Browse the repository at this point in the history
…params
  • Loading branch information
gregsaab committed Jan 31, 2025
1 parent 8633092 commit 64069e2
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 8 deletions.
226 changes: 226 additions & 0 deletions spec/fixtures/slack/web/files_upload_v2_with_all_options.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions spec/slack/web/api/endpoints/custom_specs/files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,52 @@

RSpec.describe Slack::Web::Api::Endpoints::Files do
let(:client) { Slack::Web::Client.new }
let(:valid_params) do
let(:required_params) do
{ filename: 'test.txt', content: 'Test File Contents', channels: 'C08AZ76CA4V' }
end
let(:all_params) do
required_params.merge!({ title: 'title', alt_txt: 'alt_txt', snippet_type: 'text', initial_comment: 'initial_comment' })
end

context 'when filename is missing from options' do
before do
valid_params.delete(:filename)
required_params.delete(:filename)
end

it 'throws argument error' do
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
end
end

context 'when channels is missing from options' do
before do
valid_params.delete(:channels)
required_params.delete(:channels)
end

it 'throws argument error' do
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
end
end

context 'when content is missing from options' do
before do
valid_params.delete(:content)
required_params.delete(:content)
end

it 'throws argument error' do
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
end
end

context 'when all required options are sent', vcr: { cassette_name: 'web/files_upload_v2' } do
it 'completes the upload' do
client.files_upload_v2(valid_params)
client.files_upload_v2(required_params)
end
end

context 'when all options specified', vcr: { cassette_name: 'web/files_upload_v2_with_all_options' } do
it 'completes the upload' do
client.files_upload_v2(all_params)
end
end
end

0 comments on commit 64069e2

Please sign in to comment.