-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Minitest/GlobalExpectations
triggers google-cloud-storage unit test failures
#68
Comments
First of all, Thanks for your feedback! As far as I've investigated, I think Minitest warnings cannot be fixed with simple substitutions. it "raises when creating a bucket without authentication" do
+ p self.class.to_s #=> "Google::Cloud::Storage::Project::anonymous::mock_storage"
+ p self.respond_to?(:_) #=> true
+ p self.method(:_).owner #=> Minitest::Spec::DSL::InstanceMethods
stub = Object.new
def stub.insert_bucket *args
+ p self.class.to_s #=> "Object"
+ p self.respond_to?(:_) #=> false
args.first.must_be_nil # project
raise Google::Apis::AuthorizationError.new("unauthorized", status_code: 401)
end There are several possible approaches for the issue.
I think the former is realistic. diff --git a/google-cloud-storage/test/google/cloud/storage/project_anonymous_test.rb b/google-cloud-storage/test/google/cloud/storage/project_anonymous_test.rb
index 2767f361f..5fe3c3e35 100644
--- a/google-cloud-storage/test/google/cloud/storage/project_anonymous_test.rb
+++ b/google-cloud-storage/test/google/cloud/storage/project_anonymous_test.rb
@@ -20,7 +20,7 @@ describe Google::Cloud::Storage::Project, :anonymous, :mock_storage do
let(:anonymous_storage) { Google::Cloud::Storage.anonymous }
it "raises when creating a bucket without authentication" do
- stub = Object.new
+ stub = self
def stub.insert_bucket *args
_(args.first).must_be_nil # project
raise Google::Apis::AuthorizationError.new("unauthorized", status_code: 401)
@@ -31,7 +31,7 @@ describe Google::Cloud::Storage::Project, :anonymous, :mock_storage do
end
it "raises when listing buckets without authentication" do
- stub = Object.new
+ stub = self
def stub.list_buckets *args
_(args.first).must_be_nil # project
raise Google::Apis::AuthorizationError.new("unauthorized", status_code: 401) Either way, I think it's difficult to solve with RuboCop Minitest. Thank you. |
Thanks for the deep investigation. Agreed that these two failures should be addressed by google-cloud-storage gem or minitest. |
Follow up #65 (comment)
Expected behavior
Minitest/GlobalExpectations
auto-correction does not cause unit test failures.Actual behavior
Minitest/GlobalExpectations
auto-correct causes two google-cloud-storage unit test failures.Steps to reproduce the problem
RuboCop version
I understand this is not the latest version of RuboCop, which is restricted by https://github.com/googleapis/ruby-style/blob/master/google-style.gemspec#L31
The text was updated successfully, but these errors were encountered: