diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b578d55d985..e580ab5860c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - os: ubuntu-latest ruby: "4.0" # (b/515549177): Disabled linkinator globally due to broken external doc links. - task: "--rubocop-toplevel --rubocop --build --yard" + task: "--rubocop-toplevel --rubocop --build --yard --doctest" - os: macos-latest ruby: "4.0" task: "--test" diff --git a/.toys/.lib/sample_loader.rb b/.toys/.lib/sample_loader.rb index ebbe40252232..7f5dbcd261d5 100644 --- a/.toys/.lib/sample_loader.rb +++ b/.toys/.lib/sample_loader.rb @@ -214,7 +214,7 @@ def run **params private def camelize name - ::File.basename(name, ".rb").split("_").map(&:capitalize).join + ::File.basename(name, ".rb").split(/[_-]/).map(&:capitalize).join end def traverse_name mod, name, type diff --git a/.toys/ci.rb b/.toys/ci.rb index a1cd344821c7..266c92c025cd 100644 --- a/.toys/ci.rb +++ b/.toys/ci.rb @@ -19,14 +19,15 @@ "rubocop", "build", "yard", + "doctest", "linkinator", "acceptance", "conformance", "samples-main", "samples-latest", ].freeze -OPTIONAL_TASKS = ["conformance"].freeze -ISSUE_TASKS = ["bundle", "test", "rubocop", "build", "yard", "linkinator"].freeze +OPTIONAL_TASKS = ["conformance", "doctest"].freeze +ISSUE_TASKS = ["bundle", "test", "rubocop", "build", "yard", "doctest", "linkinator"].freeze FAILURES_REPORT_PATH = "tmp/ci-failures.json" desc "Run CI tasks." diff --git a/google-cloud-bigquery/support/doctest_helper.rb b/google-cloud-bigquery/support/doctest_helper.rb index 1ed1a55ad125..2d1eb6c6ff8a 100644 --- a/google-cloud-bigquery/support/doctest_helper.rb +++ b/google-cloud-bigquery/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/bigquery" require "google/cloud/storage" diff --git a/google-cloud-bigtable/support/doctest_helper.rb b/google-cloud-bigtable/support/doctest_helper.rb index e82be8cbc9e1..7f05cef29e1c 100644 --- a/google-cloud-bigtable/support/doctest_helper.rb +++ b/google-cloud-bigtable/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/bigtable" require "grpc/errors" diff --git a/google-cloud-datastore/support/doctest_helper.rb b/google-cloud-datastore/support/doctest_helper.rb index 8610c934afa8..054242cdeb67 100644 --- a/google-cloud-datastore/support/doctest_helper.rb +++ b/google-cloud-datastore/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "grpc" require "google/cloud/datastore" diff --git a/google-cloud-dns/support/doctest_helper.rb b/google-cloud-dns/support/doctest_helper.rb index d19752acddf0..1566bc95c775 100644 --- a/google-cloud-dns/support/doctest_helper.rb +++ b/google-cloud-dns/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/dns" diff --git a/google-cloud-error_reporting/support/doctest_helper.rb b/google-cloud-error_reporting/support/doctest_helper.rb index 38392f631381..354debf796db 100644 --- a/google-cloud-error_reporting/support/doctest_helper.rb +++ b/google-cloud-error_reporting/support/doctest_helper.rb @@ -13,6 +13,7 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" require "ostruct" require "google/cloud/error_reporting" diff --git a/google-cloud-firestore/support/doctest_helper.rb b/google-cloud-firestore/support/doctest_helper.rb index 803fe40606b9..c2a08a3dcdfb 100644 --- a/google-cloud-firestore/support/doctest_helper.rb +++ b/google-cloud-firestore/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/firestore" @@ -64,7 +66,9 @@ def on_error &block def last_error end end + remove_const :DocumentListener if const_defined? :DocumentListener DocumentListener = StubbedListener + remove_const :QueryListener if const_defined? :QueryListener QueryListener = StubbedListener end end @@ -89,6 +93,11 @@ def mock_firestore doctest.skip "Google::Cloud::Firestore::V1::FirestoreClient" doctest.skip "Google::Cloud::Firestore::V1beta1::FirestoreClient" doctest.skip "Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient" + doctest.skip "#listen" + doctest.skip "#on_snapshot" + doctest.skip "Listener" + doctest.skip "Watch" + doctest.skip "Google::Cloud::Firestore::BulkWriter" doctest.before "Google::Cloud#firestore" do mock_firestore diff --git a/google-cloud-logging/support/doctest_helper.rb b/google-cloud-logging/support/doctest_helper.rb index fdaab0f0d112..acf18dfddd91 100644 --- a/google-cloud-logging/support/doctest_helper.rb +++ b/google-cloud-logging/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/storage" require "google/cloud/logging" diff --git a/google-cloud-pubsub/support/doctest_helper.rb b/google-cloud-pubsub/support/doctest_helper.rb index 53cee2b7f396..6c0b6594b174 100644 --- a/google-cloud-pubsub/support/doctest_helper.rb +++ b/google-cloud-pubsub/support/doctest_helper.rb @@ -13,6 +13,7 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" require "ostruct" require "google/cloud/pubsub" @@ -67,7 +68,7 @@ def stop! *_args def mock_pubsub Google::Cloud::PubSub.stub_new do |*args| credentials = OpenStruct.new(client: OpenStruct.new(updater_proc: Proc.new {})) - pubsub = Google::Cloud::PubSub::Project.new(Google::Cloud::PubSub::Service.new("my-project", credentials)) + pubsub = Google::Cloud::PubSub::Project.new(Google::Cloud::PubSub::Service.new("my-project", credentials, logger: Google::Cloud::PubSub::InternalLogger.new(nil))) pubsub.service.mocked_topic_admin = Minitest::Mock.new pubsub.service.mocked_subscription_admin = Minitest::Mock.new @@ -94,14 +95,14 @@ def mock_pubsub doctest.before "Google::Cloud" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") end end doctest.before "Google::Cloud::PubSub" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") end end @@ -110,7 +111,7 @@ def mock_pubsub doctest.before "Google::Cloud::PubSub::Message" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") mock_subscription_admin.expect :get_subscription, subscription_resp, subscription: subscription_path("my-topic-sub") mock_subscription_admin.expect :streaming_pull, [OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)])].to_enum, [Enumerator, Hash] @@ -125,7 +126,7 @@ def mock_pubsub doctest.before "Google::Cloud::PubSub::Project" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") end end @@ -140,7 +141,7 @@ def mock_pubsub mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] - mock_subscription_admin.expect :acknowledge, nil, ["projects/my-project/subscriptions/my-sub", ["2"], Hash] + mock_subscription_admin.expect :acknowledge_internal, nil, ["projects/my-project/subscriptions/my-sub", ["2"], Hash] end end @@ -165,14 +166,14 @@ def mock_pubsub mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] - mock_subscription_admin.expect :modify_ack_deadline, nil, [Hash] + mock_subscription_admin.expect :modify_ack_deadline_internal, nil, [Hash] end end doctest.before "Google::Cloud::PubSub::ReceivedMessage#reject!" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_subscription_admin.expect :get_subscription, subscription_resp, subscription: subscription_path("my-topic-sub") - mock_subscription_admin.expect :pull, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), [Hash] + mock_subscription_admin.expect :pull_internal, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), [Hash] mock_subscription_admin.expect :streaming_pull, [OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)])].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] @@ -190,16 +191,16 @@ def mock_pubsub mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] - mock_subscription_admin.expect :acknowledge, nil, [Hash] + mock_subscription_admin.expect :acknowledge_internal, nil, [Hash] end end doctest.before "Google::Cloud::PubSub::Subscriber#wait_for_messages" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_subscription_admin.expect :get_subscription, subscription_resp("my-topic-sub"), subscription: subscription_path("my-topic-sub") - mock_subscription_admin.expect :pull, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), + mock_subscription_admin.expect :pull_internal, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), subscription: subscription_path("my-topic-sub"), max_messages: 100, return_immediately: false - mock_subscription_admin.expect :acknowledge, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] + mock_subscription_admin.expect :acknowledge_internal, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] end end @@ -213,27 +214,27 @@ def mock_pubsub doctest.before "Google::Cloud::PubSub::Subscriber#pull@The `immediate: false` option is now recommended to avoid adverse impacts on pull operations:" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_subscription_admin.expect :get_subscription, subscription_resp("my-topic-sub"), subscription: subscription_path("my-topic-sub") - mock_subscription_admin.expect :pull, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), + mock_subscription_admin.expect :pull_internal, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), subscription: subscription_path("my-topic-sub"), max_messages: 100, return_immediately: false - mock_subscription_admin.expect :acknowledge, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] + mock_subscription_admin.expect :acknowledge_internal, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] end end doctest.before "Google::Cloud::PubSub::Subscriber#pull@A maximum number of messages returned can also be specified:" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_subscription_admin.expect :get_subscription, subscription_resp("my-topic-sub"), subscription: subscription_path("my-topic-sub") - mock_subscription_admin.expect :pull, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), + mock_subscription_admin.expect :pull_internal, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), subscription: subscription_path("my-topic-sub"), max_messages: 10, return_immediately: false - mock_subscription_admin.expect :acknowledge, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] + mock_subscription_admin.expect :acknowledge_internal, nil, subscription: subscription_path("my-topic-sub"), ack_ids: ["2"] end end doctest.before "Google::Cloud::PubSub::Subscriber#modify_ack_deadline" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_subscription_admin.expect :get_subscription, subscription_resp, subscription: subscription_path("my-topic-sub") - mock_subscription_admin.expect :pull, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), + mock_subscription_admin.expect :pull_internal, OpenStruct.new(received_messages: [Google::Cloud::PubSub::V1::ReceivedMessage.new(ack_id: "2", message: pubsub_message)]), subscription: subscription_path("my-sub"), max_messages: 100, return_immediately: false - mock_subscription_admin.expect :modify_ack_deadline, nil, subscription: subscription_path("my-sub"), ack_ids: ["2"], ack_deadline_seconds: 120 + mock_subscription_admin.expect :modify_ack_deadline_internal, nil, subscription: subscription_path("my-sub"), ack_ids: ["2"], ack_deadline_seconds: 120 end @@ -262,7 +263,7 @@ def mock_pubsub mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] - mock_subscription_admin.expect :acknowledge, nil, ["projects/my-project/subscriptions/my-ordered-topic-sub", ["2"], Hash] + mock_subscription_admin.expect :acknowledge_internal, nil, ["projects/my-project/subscriptions/my-ordered-topic-sub", ["2"], Hash] end end @@ -276,7 +277,7 @@ def mock_pubsub mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] mock_subscription_admin.expect :streaming_pull, [].to_enum, [Enumerator, Hash] - mock_subscription_admin.expect :acknowledge, nil, [Hash] + mock_subscription_admin.expect :acknowledge_internal, nil, [Hash] end end @@ -286,28 +287,34 @@ def mock_pubsub doctest.before "Google::Cloud::PubSub::Publisher" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic-only") - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] + end + end + + doctest.before "Google::Cloud::PubSub::Publisher#reload!" do + mock_pubsub do |mock_topic_admin, mock_subscription_admin| + mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") end end doctest.before "Google::Cloud::PubSub::Publisher#async_publisher" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] end end doctest.before "Google::Cloud::PubSub::Publisher#publish" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] end end doctest.before "Google::Cloud::PubSub::Publisher#publish@Additionally, a message can be published with attributes:" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-topic") - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] end end @@ -319,14 +326,14 @@ def mock_pubsub pubsub_message("task 2 completed", { "foo" => "baz" }), pubsub_message("task 3 completed", { "foo" => "bif" }) ] - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1", "2", "3"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1", "2", "3"]), [Hash] end end doctest.before "Google::Cloud::PubSub::Publisher#publish@Ordered messages are supported using ordering_key:" do mock_pubsub do |mock_topic_admin, mock_subscription_admin| mock_topic_admin.expect :get_topic, topic_resp, topic: topic_path("my-ordered-topic") - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1"]), [Hash] end end @@ -347,7 +354,7 @@ def mock_pubsub pubsub_message("task 2 completed", { "foo" => "baz" }), pubsub_message("task 3 completed", { "foo" => "bif" }) ] - mock_topic_admin.expect :publish, OpenStruct.new(message_ids: ["1", "2", "3"]), [Hash] + mock_topic_admin.expect :publish_internal, OpenStruct.new(message_ids: ["1", "2", "3"]), [Hash] end end end diff --git a/google-cloud-storage/support/doctest_helper.rb b/google-cloud-storage/support/doctest_helper.rb index b81b7bf08db1..22816b1e3335 100644 --- a/google-cloud-storage/support/doctest_helper.rb +++ b/google-cloud-storage/support/doctest_helper.rb @@ -13,6 +13,8 @@ # limitations under the License. require "minitest/focus" +require "minitest/mock" +require "ostruct" require "google/cloud/storage" require "google/cloud/pubsub" diff --git a/google-cloud-trace/support/doctest_helper.rb b/google-cloud-trace/support/doctest_helper.rb index 30a2a2fe26d4..4e4321b55cc1 100644 --- a/google-cloud-trace/support/doctest_helper.rb +++ b/google-cloud-trace/support/doctest_helper.rb @@ -16,6 +16,8 @@ require "google/cloud/trace" require "minitest/rg" require "minitest/focus" +require "minitest/mock" +require "ostruct" require "active_record" module Google diff --git a/google-cloud-translate-v2/support/doctest_helper.rb b/google-cloud-translate-v2/support/doctest_helper.rb index 89f3984930e9..891599b59878 100644 --- a/google-cloud-translate-v2/support/doctest_helper.rb +++ b/google-cloud-translate-v2/support/doctest_helper.rb @@ -14,6 +14,8 @@ require "google/cloud/translate/v2" require "minitest/focus" +require "minitest/mock" +require "ostruct" module Google module Cloud @@ -55,7 +57,7 @@ def mock_translate doctest.before "Google::Cloud::Translate::V2.new" do mock_translate do |mock| res_attrs = { detectedSourceLanguage: "en", translatedText: "Salve mundi!" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: nil, cid: nil end end @@ -64,7 +66,7 @@ def mock_translate doctest.before "Google::Cloud::Translate::V2::Api" do mock_translate do |mock| res_attrs = { detectedSourceLanguage: "en", translatedText: "Salve mundi!" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: nil, cid: nil end end @@ -82,21 +84,21 @@ def mock_translate doctest.before "Google::Cloud::Translate::V2::Api#translate" do mock_translate do |mock| res_attrs = { detectedSourceLanguage: "en", translatedText: "Salve mundi!", model: "base" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: nil, cid: nil end end doctest.before "Google::Cloud::Translate::V2::Api#translate@Using the neural machine translation model:" do mock_translate do |mock| res_attrs = { detectedSourceLanguage: "en", translatedText: "Salve mundi!", model: "nmt" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: "nmt", cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: "nmt", cid: nil end end doctest.before "Google::Cloud::Translate::V2::Api#translate@Setting the `from` language." do mock_translate do |mock| res_attrs = { detectedSourceLanguage: nil, translatedText: "Salve mundi!" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: "en", format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: "en", format: nil, model: nil, cid: nil end end @@ -104,14 +106,14 @@ def mock_translate mock_translate do |mock| res_attrs_1 = { detectedSourceLanguage: nil, translatedText: "Salve amice." } res_attrs_2 = { detectedSourceLanguage: nil, translatedText: "Vide te mox." } - mock.expect :translate, list_translations_response([res_attrs_1, res_attrs_2]), [["Hello my friend.", "See you soon."], to: "la", from: "en", format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs_1, res_attrs_2]), [["Hello my friend.", "See you soon."]], to: "la", from: "en", format: nil, model: nil, cid: nil end end doctest.before "Google::Cloud::Translate::V2::Api#translate@Preserving HTML tags." do mock_translate do |mock| res_attrs = { detectedSourceLanguage: nil, translatedText: "Salve mundi!" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: nil, cid: nil end end @@ -162,7 +164,7 @@ def mock_translate doctest.before "Google::Cloud::Translate::V2::Translation" do mock_translate do |mock| res_attrs = { detectedSourceLanguage: "en", translatedText: "Salve mundi!" } - mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"], to: "la", from: nil, format: nil, model: nil, cid: nil] + mock.expect :translate, list_translations_response([res_attrs]), [["Hello world!"]], to: "la", from: nil, format: nil, model: nil, cid: nil end end end