Skip to content

Commit

Permalink
fix rspec deprecated warning (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkobayash authored Apr 17, 2024
1 parent 075f812 commit 4dd9173
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions spec/backlog_kit/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@
allow_any_instance_of(Faraday::Connection).to receive(:send).and_raise(Faraday::ConnectionFailed, message)
end

subject { -> { response } }
it { is_expected.to raise_error(BacklogKit::Error, "ConnectionError - #{message}") }
it { expect { subject }.to raise_error(BacklogKit::Error, "ConnectionError - #{message}") }
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/backlog_kit/response/raise_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

describe '#on_complete' do
subject { -> { response.on_complete(faraday_env_mock) } }
subject { response.on_complete(faraday_env_mock) }

context 'when error code contains 1' do
let(:error_code) { 1 }
Expand Down Expand Up @@ -79,27 +79,27 @@

context 'when error code contains unexpected code' do
let(:error_code) { 99 }
it { is_expected.to raise_error(BacklogKit::Error, "[ERROR 1] UnexpectedError - エラー1 (CODE: #{error_code}), [ERROR 2] UnexpectedError - エラー2 (CODE: #{error_code})") }
it { expect { subject }.to raise_error(BacklogKit::Error, "[ERROR 1] UnexpectedError - エラー1 (CODE: #{error_code}), [ERROR 2] UnexpectedError - エラー2 (CODE: #{error_code})") }
end

context 'when status code is 204' do
let(:faraday_env_status) { 204 }
it { is_expected.not_to raise_error }
it { expect { subject }.not_to raise_error }
end

context 'when content type is not json' do
let(:faraday_env_headers) { { 'content-type' => 'image/gif' } }
it { is_expected.not_to raise_error }
it { expect { subject }.not_to raise_error }
end

context 'when json body is array' do
let(:faraday_env_body) { [{ 'key1' => 'value1' }].to_json }
it { is_expected.not_to raise_error }
it { expect { subject }.not_to raise_error }
end

context 'when json body does not contains error' do
let(:faraday_env_body) { { 'key1' => 'value1' }.to_json }
it { is_expected.not_to raise_error }
it { expect { subject }.not_to raise_error }
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/support/shared_examples_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1095,15 +1095,15 @@
end

shared_examples_for 'a invalid request error' do
subject { -> { response.body } }
it { is_expected.to raise_error(BacklogKit::Error, "[ERROR 1] InvalidRequestError - error.unknownParameter : #{invalid_param_key} (CODE: 7)") }
subject { response.body }
it { expect { subject }.to raise_error(BacklogKit::Error, "[ERROR 1] InvalidRequestError - error.unknownParameter : #{invalid_param_key} (CODE: 7)") }
end

shared_examples_for 'raise errors' do
let(:error_class_name) do
BacklogKit::Response::RaiseError::CODE_ERRORS[error_code].name.demodulize
end

subject { -> { response.on_complete(faraday_env_mock) } }
it { is_expected.to raise_error(BacklogKit::Error, "[ERROR 1] #{error_class_name} - エラー1 (CODE: #{error_code}), [ERROR 2] #{error_class_name} - エラー2 (CODE: #{error_code})") }
subject { response.on_complete(faraday_env_mock) }
it { expect { subject }.to raise_error(BacklogKit::Error, "[ERROR 1] #{error_class_name} - エラー1 (CODE: #{error_code}), [ERROR 2] #{error_class_name} - エラー2 (CODE: #{error_code})") }
end

0 comments on commit 4dd9173

Please sign in to comment.