gitlab-org--gitlab-foss/spec/support/matchers/gitaly_matchers.rb
Stan Hu 645c7f9631 Fix order-dependent Gitaly specs failing
If `spec/tasks/gitlab/cleanup_rake_spec.rb` preceded any of the Gitaly
request specs, it would import the `cleanup.rake` and the global
function `limit`. For some reason, the Protobuf implementation would use
the global function instead of the getter method. For example:

```
def limit
  puts "hi"
end

req = Gitaly::WikiGetAllPagesRequest.new
req.send(:limit)
hi
=> nil
```

To fix this problem, access the field value using the [] operator
instead.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64006
2019-07-02 20:33:02 -07:00

14 lines
410 B
Ruby

RSpec::Matchers.define :gitaly_request_with_path do |storage_name, relative_path|
match do |actual|
repository = actual.repository
repository.storage_name == storage_name &&
repository.relative_path == relative_path
end
end
RSpec::Matchers.define :gitaly_request_with_params do |params|
match do |actual|
params.reduce(true) { |r, (key, val)| r && actual[key.to_s] == val }
end
end