File tree 3 files changed +45
-0
lines changed
3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe Line ::Bot ::Request do
4
+ describe '#content_type' do
5
+ subject { request . content_type }
6
+
7
+ context 'content type is not specified' do
8
+ let ( :request ) { described_class . new }
9
+
10
+ it { is_expected . to eq 'application/json; charset=UTF-8' }
11
+ end
12
+
13
+ context 'content type is specified' do
14
+ let ( :request ) do
15
+ described_class . new do |config |
16
+ config . content_type = 'application/x-www-form-urlencoded'
17
+ end
18
+ end
19
+
20
+ it { is_expected . to eq 'application/x-www-form-urlencoded' }
21
+ end
22
+
23
+ context 'jpeg file is assigned' do
24
+ let ( :request ) do
25
+ described_class . new do |config |
26
+ config . file = File . open ( 'spec/fixtures/line/bot/preview.jpg' )
27
+ end
28
+ end
29
+
30
+ it { is_expected . to eq 'image/jpeg' }
31
+ end
32
+
33
+ context 'unsupported file is assigned' do
34
+ let ( :request ) do
35
+ described_class . new do |config |
36
+ config . file = File . open ( 'spec/fixtures/line/bot/video.mp4' )
37
+ end
38
+ end
39
+
40
+ it do
41
+ expect { subject } . to raise_error ( ArgumentError )
42
+ end
43
+ end
44
+ end
45
+ end
You can’t perform that action at this time.
0 commit comments