Skip to content

How can I stub response including nil value? #763

@dtan4

Description

@dtan4

Hello,

I'm developing a tool using aws-sdk gem v2, and implmenting tests with stubbed API requests.

I'd like to stub response including nil value, like this:

client = Aws::RDS::Client.new

client.describe_db_parameters(db_parameter_group_name: "hoge").parameters[2]
=> #<struct
 parameter_name="archive_timeout",
 parameter_value="300",
 description= "Timeout seconds for archiving",
 source="system",
 apply_type="dynamic",
 data_type="integer",
 allowed_values="0-2147483647",
 is_modifiable=false,
 minimum_engine_version=nil,
 apply_method=nil>

However, the actual stubbed response is this:

client = Aws::RDS::Client.new(stub_responses: true)
db_parameters = [
  {
    parameter_name: "archive_timeout",
    parameter_value: "300",
    description: "Timeout seconds for archiving",
    source: "system",
    apply_type: "dynamic",
    data_type: "integer",
    allowed_values: "0-214748364",
    is_modifiable: false,
    minimum_engine_version: nil,
    apply_method: nil
  }
]
client.stub_responses(:describe_db_parameters, db_parameters)

client.describe_db_parameters(db_parameter_group_name: "hoge").parameters[0]
=> #<struct
 parameter_name="archive_timeout",
 parameter_value="300",
 description="Timeout seconds for archiving",
 source="system",
 apply_type="dynamic",
 data_type="integer",
 allowed_values="0-214748364",
 is_modifiable=false,
 minimum_engine_version="String",
 apply_method="ApplyMethod">

nil value is converted to another default value by #stub_scalar method.

Is there any way to stub nil-included response?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions