Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rspec deprecated warning #5

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix rspec deprecated warning
hkobayash committed Apr 17, 2024
commit a2b299383be5d64741b41aac5a319b75bc66b868
3 changes: 1 addition & 2 deletions spec/backlog_kit/client_spec.rb
Original file line number Diff line number Diff line change
@@ -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

12 changes: 6 additions & 6 deletions spec/backlog_kit/response/raise_error_spec.rb
Original file line number Diff line number Diff line change
@@ -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 }
@@ -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

8 changes: 4 additions & 4 deletions spec/support/shared_examples_for.rb
Original file line number Diff line number Diff line change
@@ -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