Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

tests on master should have no failures on any computer #2199

Closed
tute opened this issue May 10, 2016 · 14 comments
Closed

tests on master should have no failures on any computer #2199

tute opened this issue May 10, 2016 · 14 comments

Comments

@tute
Copy link
Contributor

tute commented May 10, 2016

Right now they are only green in CI. Different computers fail differently, in mine I get:

rspec ./spec/paperclip/validators_spec.rb:21 # Paperclip::Validators using the helper prevents you from attaching a file that violates that validation
rspec ./spec/paperclip/storage/s3_spec.rb:696 # Paperclip::Storage::S3 Parsing S3 credentials with a s3_host_name in them gets the right s3_host_name if the key does not exist
rspec ./spec/paperclip/attachment_processing_spec.rb:52 # Attachment Processing using validates_attachment processes attachments given a valid assignment
@tute
Copy link
Contributor Author

tute commented May 10, 2016

rspec ./spec/paperclip/validators_spec.rb:21 seem to depend on the seed, the others two fail "more reliably".

@pedrosmmoreira
Copy link
Contributor

Hi @tute, happy to help out with this one if possible. Running the specs now

@tute
Copy link
Contributor Author

tute commented May 10, 2016

Thank you! 😃

@pedrosmmoreira
Copy link
Contributor

Thank you and all the maintainers for your time and effort :)

@pedrosmmoreira
Copy link
Contributor

rspec ./spec/paperclip/storage/s3_spec.rb:696 is failing to create a new Aws::Resource on https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/storage/s3.rb#L247 as the test setup neither sets a test key nor an s3_region key. Since the Aws sdk does regex match on the passed in string, we fail on NoMethodError

I don't know how realistic this testing scenario: would not a failure to include the s3 hash in options passed to has_attached_file cause a fallback to whatever is defined in the environment? In that case, nothing being found, Paperclip would fallback to setting storage to :filesystem, correct?

Seems like we have a quick fix by just adding the test env hash with s3_region pointing to an empty string (in https://github.com/thoughtbot/paperclip/blob/master/spec/paperclip/storage/s3_spec.rb#L667).

I can PR this if you agree that's a reasonable solution.

@tute
Copy link
Contributor Author

tute commented May 10, 2016

That is a very weird spec. Why do we need the rails_env("test") block?

Seems like we have a quick fix by just adding the test env hash with s3_region pointing to an empty string (in https://github.com/thoughtbot/paperclip/blob/master/spec/paperclip/storage/s3_spec.rb#L667).

I can PR this if you agree that's a reasonable solution.

That makes sense to me. 👍 Thanks for your help!

@pedrosmmoreira
Copy link
Contributor

I'll push that PR up in a second. I'll have a look at another PR to remove the block and continue investigating failures.

@tute
Copy link
Contributor Author

tute commented May 10, 2016

I'll have a look at another PR to remove the block and continue investigating failures.

Another question: why doesn't it fail in CI?

@tute
Copy link
Contributor Author

tute commented May 10, 2016

Ohh. Those tests don't run in CI, as they need ENV vars, right? Which is another weird thing of paperclip's test suite, I think.

@pedrosmmoreira
Copy link
Contributor

Yeah, the situation is slightly strange, but with some help we can push to get this to a good place!

pedrosmmoreira added a commit to pedrosmmoreira/paperclip that referenced this issue May 10, 2016
This is part of the effort started at thoughtbot#2199)
to ensure the test suite is green locally.

This spec was failing on obtaining a S3 instance with an `nil` region
key. Since `Aws::Resource` does a regex match against the region key
passed in, we would fail on `NoMethodError`.

This corrects the issue by setting a region key to an empty string in
the test setup.
@pedrosmmoreira
Copy link
Contributor

rspec ./spec/paperclip/attachment_processing_spec.rb:52 seems to be failing due the rebuild_class before_hook being restricted to only one of the contexts (https://github.com/thoughtbot/paperclip/blob/master/spec/paperclip/attachment_processing_spec.rb#L6).
This is bound to leave the Dummy class in a bad state and cause further issues downstream. Prepping a PR for this one now.

pedrosmmoreira added a commit to pedrosmmoreira/paperclip that referenced this issue May 10, 2016
This is part of the effort started at
thoughtbot#2199 to ensure the test
suite is green locally.

The attachment processing spec was failing since the setup required done
in a before block, namely a call to `rebuild_class`, was running
restricted to one of two contexts in the test file.
This was leaving the `Dummy` class in a bad state and affected other tests.

This PR moves the `before` block to run for the both of the contexts.
@pedrosmmoreira
Copy link
Contributor

rspec ./spec/paperclip/validators_spec.rb:21 seems once again a case of incorrect setup. Adding the call to rebuild_class to https://github.com/thoughtbot/paperclip/blob/master/spec/paperclip/validators_spec.rb#L5 for it to reliably pass.

pedrosmmoreira added a commit to pedrosmmoreira/paperclip that referenced this issue May 10, 2016
This is part of the effort started at
thoughtbot#2199 to ensure the test
suite is green locally.

The validators spec was failing since the setup required was missing a
call to 'rebuild_class' and leaving the Dummy class in a bad state.

This PR adds the call to the before block setup.
@pedrosmmoreira
Copy link
Contributor

@tute let me know if you prefer these PRs to be cherry-picked into one.

tute pushed a commit that referenced this issue May 10, 2016
This is part of the effort started at
#2199 to ensure the test
suite is green locally.

The attachment processing spec was failing since the setup required done
in a before block, namely a call to `rebuild_class`, was running
restricted to one of two contexts in the test file.
This was leaving the `Dummy` class in a bad state and affected other tests.

This PR moves the `before` block to run for the both of the contexts.
@tute
Copy link
Contributor Author

tute commented May 10, 2016

Thank you, @pedrosmmoreira!

@tute tute closed this as completed May 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants