Call original method for rspec track matcher
Let's assume the following scenario when using Snowplow for tracking:
# in gitlab specs
it :experiment do
expect(experiment).to track(:some_event, property: 1)
end
The event gets stubbed away and we just check if it's called. However, in production, Snowplow gets called and will run a runtime-type check. In the case above, it will fail in runtime, because property
needs to be a String
. We already had s2 and s4 incidents and introduced SnowplowHelper in GitLab because of this: gitlab-org/gitlab!40748 (merged).
To overcome the issue, we need to call the original track
method, so we perform the type check in the specs as well.
After this MR (and when gitlab-org/gitlab!55072 (merged) is merged)
it :experiment do
expect(experiment).to track(:some_event, property: 1) # => Will fail with a snowplow error, as expected
end
I know that we already added a .and_call_original
to the , but I guess the expect
below overrides that.
Specs are failing since we actually override the method with the block, I need to figure out what's the best plan to fix this.
MR on the gitlab side: gitlab-org/gitlab!55072 (merged)