Skip to content

Commit

Permalink
use rspec expect syntax to test the error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Oct 18, 2019
1 parent 620c4d1 commit c4ebca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 48 deletions.
28 changes: 4 additions & 24 deletions spec/faraday/deprecate_spec.rb
Expand Up @@ -41,39 +41,19 @@ def initialize(foo = nil)
end

it 'allows rescuing of a current error with a deprecated error' do
begin
raise SampleClass, nil
rescue SampleDeprecatedClass
rescue StandardError => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise SampleClass, nil }.to raise_error(SampleDeprecatedClass)
end

it 'allows rescuing of a current error with a current error' do
begin
raise SampleClass, nil
rescue SampleClass
rescue StandardError => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise SampleClass, nil }.to raise_error(SampleClass)
end

it 'allows rescuing of a deprecated error with a deprecated error' do
begin
raise SampleDeprecatedClass, nil
rescue SampleDeprecatedClass
rescue StandardError => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise SampleDeprecatedClass, nil }.to raise_error(SampleDeprecatedClass)
end

it 'allows rescuing of a deprecated error with a current error' do
begin
raise SampleDeprecatedClass, nil
rescue SampleClass
rescue StandardError => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise SampleDeprecatedClass, nil }.to raise_error(SampleClass)
end


Expand Down
28 changes: 4 additions & 24 deletions spec/faraday/error_spec.rb
Expand Up @@ -73,39 +73,19 @@
end

it 'allows rescuing of a current error with a deprecated error' do
begin
raise Faraday::ClientError, nil
rescue Faraday::Error::ClientError
rescue Faraday::Error => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise Faraday::ClientError, nil }.to raise_error(Faraday::Error::ClientError)
end

it 'allows rescuing of a current error with a current error' do
begin
raise Faraday::ClientError, nil
rescue Faraday::ClientError
rescue Faraday::Error => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise Faraday::ClientError, nil }.to raise_error(Faraday::ClientError)
end

it 'allows rescuing of a deprecated error with a deprecated error' do
begin
raise Faraday::Error::ClientError, nil
rescue Faraday::Error::ClientError
rescue Faraday::Error => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise Faraday::Error::ClientError, nil }.to raise_error(Faraday::Error::ClientError)
end

it 'allows rescuing of a deprecated error with a current error' do
begin
raise Faraday::Error::ClientError, nil
rescue Faraday::ClientError
rescue Faraday::Error => exc
fail "rescued #{exc.class.name} instead"
end
expect { raise Faraday::Error::ClientError, nil }.to raise_error(Faraday::ClientError)
end
end

Expand Down

0 comments on commit c4ebca8

Please sign in to comment.