Skip to content

Commit 82dc716

Browse files
move webhook spec
1 parent 243295a commit 82dc716

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

spec/line/bot/client_get_spec.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,6 @@
200200
}
201201
EOS
202202

203-
WEBHOOK_ENDPOINT_CONTENT = <<"EOS"
204-
{
205-
"endpoint": "https://example.com/test",
206-
"active": true
207-
}
208-
EOS
209-
210203
describe Line::Bot::Client do
211204
before do
212205
end
@@ -487,18 +480,4 @@ def generate_client
487480
markAsReadMode: 'manual'
488481
)
489482
end
490-
491-
it 'get webhook endpoint' do
492-
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/channel/webhook/endpoint'
493-
stub_request(:get, uri_template).to_return(body: WEBHOOK_ENDPOINT_CONTENT, status: 200)
494-
495-
client = generate_client
496-
response = client.get_webhook_endpoint
497-
498-
json = JSON.parse(response.body, symbolize_names: true)
499-
expect(json).to eq(
500-
endpoint: 'https://example.com/test',
501-
active: true
502-
)
503-
end
504483
end

spec/line/bot/webhook_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require 'spec_helper'
2+
require 'webmock/rspec'
3+
require 'json'
4+
5+
WEBHOOK_ENDPOINT_CONTENT = <<"EOS"
6+
{
7+
"endpoint": "https://example.com/test",
8+
"active": true
9+
}
10+
EOS
11+
12+
describe Line::Bot::Client do
13+
let(:client) do
14+
dummy_config = {
15+
channel_token: 'access token',
16+
}
17+
Line::Bot::Client.new do |config|
18+
config.channel_token = dummy_config[:channel_token]
19+
end
20+
end
21+
22+
it 'get webhook endpoint' do
23+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/channel/webhook/endpoint'
24+
stub_request(:get, uri_template).to_return(body: WEBHOOK_ENDPOINT_CONTENT, status: 200)
25+
26+
response = client.get_webhook_endpoint
27+
28+
json = JSON.parse(response.body, symbolize_names: true)
29+
expect(json).to eq(
30+
endpoint: 'https://example.com/test',
31+
active: true
32+
)
33+
end
34+
end

0 commit comments

Comments
 (0)