Skip to content

Commit 7ef66c9

Browse files
committed
fix tests
1 parent 2220c1a commit 7ef66c9

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

lib/slack/web/faraday/connection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def connection
99
@connection ||=
1010
begin
1111
options = {
12-
headers: { 'Accept' => 'application/json, text/plain; charset=utf-8' }
12+
headers: { 'Accept' => 'application/json; charset=utf-8, text/plain; charset=utf-8' }
1313
}
1414

1515
options[:headers]['User-Agent'] = user_agent if user_agent
@@ -26,7 +26,7 @@ def connection
2626
connection.request :url_encoded
2727
connection.use ::Slack::Web::Faraday::Response::RaiseError
2828
connection.response :mashify, mash_class: Slack::Messages::Message
29-
connection.response :json, content_type: /\b*json$/
29+
connection.response :json, content_type: /\bjson$/
3030
connection.use ::Slack::Web::Faraday::Response::WrapError
3131
connection.response :logger, logger if logger
3232
connection.adapter adapter

spec/fixtures/slack/web/rtm_connect.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/slack/web/client_spec.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
it 'creates a connection with the custom user-agent' do
6262
expect(client.send(:connection).headers).to eq(
63-
'Accept' => 'application/json; charset=utf-8',
63+
'Accept' => 'application/json, text/plain; charset=utf-8',
6464
'User-Agent' => 'custom/user-agent'
6565
)
6666
end
@@ -286,19 +286,6 @@
286286
end
287287

288288
context 'parsing error' do
289-
context 'when the response is not JSON' do
290-
before do
291-
stub_slack_request.to_return(body: '<html></html>', headers: { 'Content-Type' => 'text/html' })
292-
end
293-
294-
it 'raises ParsingError' do
295-
expect { request }.to raise_error(Slack::Web::Api::Errors::ParsingError).with_message('parsing_error')
296-
expect(exception.response.body).to eq('<html></html>')
297-
expect(exception.cause).to be_a(Faraday::ParsingError)
298-
expect(exception.cause.cause).to be_a(JSON::ParserError)
299-
end
300-
end
301-
302289
context 'when the response is malformed JSON' do
303290
before { stub_slack_request.to_return(body: '{') }
304291

0 commit comments

Comments
 (0)