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

Fix failing test for creation of JPEG2000 derivatives. #142

Merged
merged 5 commits into from
Mar 31, 2017

Conversation

dlpierce
Copy link
Contributor

Fixes #118 by un-protecting some class methods that were originally not actually protected, but then made protected by rubocop. Specs for these methods coming shortly...
.jp2 derivatives tests were still broken due to .txt being used as a default mime-type and extension, so that is explicitly set now.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 83.367% when pulling af2af77 on long_dim-jp2_format into d6f371a on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 83.367% when pulling af2af77 on long_dim-jp2_format into d6f371a on master.

Copy link
Contributor

@jeremyf jeremyf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution and looking to fix JPEG2000 derivative tests.

it "executes the external utility" do
expect(described_class).to receive(:execute) { 0 }
described_class.encode('infile', 'recipe', 'outfile')
# expect(Hydra::Derivatives::Processors::ShellBasedProcessor).to have_received(:execute)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented out code. It looks like this is tested in the above expect segment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, missed it in the rush for lunch.

describe "#tmp_file" do
it "returns a temp file with the correct extension" do
f = described_class.tmp_file('test')
expect(f).to match(/sufia.*test$/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjcolvar You had made mention of being concerned about the "sufia" assumption in file names. Could you take a look here?

I'm wondering if it would be okay to ignore the sufia part of the regular expression?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That conversation was based on #99 . I agree that it seems possible to remove the sufia from the regex and maybe change this to an ends_with? ".test".

@@ -73,20 +73,18 @@ def layer_rates(layer_count, compression_numerator)
rates.map(&:to_s).join(',')
end

protected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing that the following methods are now becoming public. What was your reason for removing the protected declaration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failing spec that he fixed had this error:

8) Transcoding with an attached tiff transcodes
     Failure/Error: long_dim = self.class.long_dim(image)
     
     NoMethodError:
       protected method `long_dim' called for Hydra::Derivatives::Processors::Jpeg2kImage:Class

"protected" for class methods apparently doesn't behave in the way you might expect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @val99erie for the clarification; Always hesitant to public-ize new methods, but this sounds like a necessary reason to open the public facing methods.

Copy link
Contributor

@val99erie val99erie Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an older explanation of why it won't work to have a protected class method and then try to call it from within an instance method. The only receiver that is allowed is self; self.class won't work.
http://stackoverflow.com/questions/11461262/what-is-the-value-of-self-in-a-rails-model-and-why-arent-obvious-instance-metho/11461333#11461333

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up. I missed the context that these were class methods as well. I'm all for this change.

@@ -73,20 +73,18 @@ def layer_rates(layer_count, compression_numerator)
rates.map(&:to_s).join(',')
end

protected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up. I missed the context that these were class methods as well. I'm all for this change.

@coveralls
Copy link

coveralls commented Mar 31, 2017

Coverage Status

Coverage increased (+0.8%) to 83.367% when pulling c196e6e on long_dim-jp2_format into d6f371a on master.

@jeremyf jeremyf merged commit 44803bc into master Mar 31, 2017
@jeremyf jeremyf deleted the long_dim-jp2_format branch March 31, 2017 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants