Skip to content

Commit 64069e2

Browse files
committed
add a spec for using all params, rename the valid_params to required_params
1 parent 8633092 commit 64069e2

File tree

2 files changed

+243
-8
lines changed

2 files changed

+243
-8
lines changed

spec/fixtures/slack/web/files_upload_v2_with_all_options.yml

Lines changed: 226 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/slack/web/api/endpoints/custom_specs/files_spec.rb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,52 @@
33

44
RSpec.describe Slack::Web::Api::Endpoints::Files do
55
let(:client) { Slack::Web::Client.new }
6-
let(:valid_params) do
6+
let(:required_params) do
77
{ filename: 'test.txt', content: 'Test File Contents', channels: 'C08AZ76CA4V' }
88
end
9+
let(:all_params) do
10+
required_params.merge!({ title: 'title', alt_txt: 'alt_txt', snippet_type: 'text', initial_comment: 'initial_comment' })
11+
end
912

1013
context 'when filename is missing from options' do
1114
before do
12-
valid_params.delete(:filename)
15+
required_params.delete(:filename)
1316
end
1417

1518
it 'throws argument error' do
16-
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
19+
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
1720
end
1821
end
1922

2023
context 'when channels is missing from options' do
2124
before do
22-
valid_params.delete(:channels)
25+
required_params.delete(:channels)
2326
end
2427

2528
it 'throws argument error' do
26-
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
29+
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
2730
end
2831
end
2932

3033
context 'when content is missing from options' do
3134
before do
32-
valid_params.delete(:content)
35+
required_params.delete(:content)
3336
end
3437

3538
it 'throws argument error' do
36-
expect { client.files_upload_v2(valid_params) }.to raise_error ArgumentError
39+
expect { client.files_upload_v2(required_params) }.to raise_error ArgumentError
3740
end
3841
end
3942

4043
context 'when all required options are sent', vcr: { cassette_name: 'web/files_upload_v2' } do
4144
it 'completes the upload' do
42-
client.files_upload_v2(valid_params)
45+
client.files_upload_v2(required_params)
46+
end
47+
end
48+
49+
context 'when all options specified', vcr: { cassette_name: 'web/files_upload_v2_with_all_options' } do
50+
it 'completes the upload' do
51+
client.files_upload_v2(all_params)
4352
end
4453
end
4554
end

0 commit comments

Comments
 (0)