|
3 | 3 |
|
4 | 4 | RSpec.describe Slack::Web::Api::Endpoints::Files do |
5 | 5 | let(:client) { Slack::Web::Client.new } |
6 | | - let(:valid_params) do |
| 6 | + let(:required_params) do |
7 | 7 | { filename: 'test.txt', content: 'Test File Contents', channels: 'C08AZ76CA4V' } |
8 | 8 | 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 |
9 | 12 |
|
10 | 13 | context 'when filename is missing from options' do |
11 | 14 | before do |
12 | | - valid_params.delete(:filename) |
| 15 | + required_params.delete(:filename) |
13 | 16 | end |
14 | 17 |
|
15 | 18 | 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 |
17 | 20 | end |
18 | 21 | end |
19 | 22 |
|
20 | 23 | context 'when channels is missing from options' do |
21 | 24 | before do |
22 | | - valid_params.delete(:channels) |
| 25 | + required_params.delete(:channels) |
23 | 26 | end |
24 | 27 |
|
25 | 28 | 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 |
27 | 30 | end |
28 | 31 | end |
29 | 32 |
|
30 | 33 | context 'when content is missing from options' do |
31 | 34 | before do |
32 | | - valid_params.delete(:content) |
| 35 | + required_params.delete(:content) |
33 | 36 | end |
34 | 37 |
|
35 | 38 | 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 |
37 | 40 | end |
38 | 41 | end |
39 | 42 |
|
40 | 43 | context 'when all required options are sent', vcr: { cassette_name: 'web/files_upload_v2' } do |
41 | 44 | 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) |
43 | 52 | end |
44 | 53 | end |
45 | 54 | end |
0 commit comments