これらの AWS 例外をキャプチャできることをテストしようとしています。
begin
s3_client = S3Client.new
s3_file = s3_client.write_s3_file(bucket, file_name, file_contents)
rescue AWS::Errors::ServerError, AWS::Errors::ClientError => e
# do something
end
私のRspec 3コード:
expect_any_instance_of(S3Client).to receive(:write_s3_file).and_raise(AWS::Errors::ServerError)
しかし、このスタブをテストすると、TypeError が発生します。
exception class/object expected
AWS::Errors::ServerError を含める必要がありますか? もしそうなら、どうすればいいですか?aws-sdk-v1 gem を使用しています。
ありがとう。