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

Stub response_target #2898

Closed
tke578 opened this issue Aug 13, 2023 · 7 comments
Closed

Stub response_target #2898

tke578 opened this issue Aug 13, 2023 · 7 comments
Labels
guidance Question that needs advice or information.

Comments

@tke578
Copy link

tke578 commented Aug 13, 2023

Describe the issue

I am trying to stub the response_target in the get_object function call.
I currently have this setup in my test suite

Aws.config[:s3] = {
                     stub_responses: {
                       list_buckets: {
                         buckets: [name: 'bucket_name'
                       },
                       list_objects_v2: {
                         contents: [{key: "some_key"}]
                       },
                       get_object: {
                         body: "lorem ipsum",
                         response_target: "trying_to_stub/this"
                       }

                     }
                   }

I get a ArgumentError: unexpected value at params[:response_target]
I don't see any documentation on this.
If I remove the response_target key, it will try to create the file(which i don't want)

Links

https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ClientStubs.html

@tke578 tke578 added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2023
@mullermp
Copy link
Contributor

mullermp commented Aug 13, 2023

response_target isn't a member of the API so it's not something that can be stubbed. Are you using rspec? You should be able to mock that with expect(File).to receive(:write)... or something equivalent. I can look to see if we can add an easier way to do this.

@tke578
Copy link
Author

tke578 commented Aug 13, 2023

@mullermp that makes sense then. It looks like its handed by the Seahorse client.

As a temp solution, I was able to have the file exist(file fixture) in my test suite so something like rails_root_project/test/fixtures/files/the_name_of_the_file and making sure that $the_name_of_the_file is the same name in my test suite(response_target)

No, I am not using Rspec.
Thanks!

@mullermp
Copy link
Contributor

Just curious, how are you testing if not with rspec? With mini test?

You can also consider Tempfile somehow, but I'm not sure what your current test setup and logic looks like.

@tke578
Copy link
Author

tke578 commented Aug 13, 2023

Apologies. Yes, minitest.
That could also work.

@tke578
Copy link
Author

tke578 commented Aug 13, 2023

@mullermp Should I close this issue since its outside the scope of this gem?

@mullermp
Copy link
Contributor

Yes. Thank you. Sorry that you ran into this, but I do believe mocking is correct for this feature.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@mullermp mullermp added guidance Question that needs advice or information. and removed documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants