Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/helpers/snowplow_helpers.rb')
-rw-r--r--spec/support/helpers/snowplow_helpers.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/support/helpers/snowplow_helpers.rb b/spec/support/helpers/snowplow_helpers.rb
index 15eac1b24fc..70a4eadd8de 100644
--- a/spec/support/helpers/snowplow_helpers.rb
+++ b/spec/support/helpers/snowplow_helpers.rb
@@ -31,7 +31,31 @@ module SnowplowHelpers
# )
# end
# end
- def expect_snowplow_event(category:, action:, **kwargs)
+ #
+ # Passing context:
+ #
+ # Simply provide a hash that has the schema and data expected.
+ #
+ # expect_snowplow_event(
+ # category: 'Experiment',
+ # action: 'created',
+ # context: [
+ # {
+ # schema: 'iglu:com.gitlab/.../0-3-0',
+ # data: { key: 'value' }
+ # }
+ # ]
+ # )
+ def expect_snowplow_event(category:, action:, context: nil, **kwargs)
+ if context
+ kwargs[:context] = []
+ context.each do |c|
+ expect(SnowplowTracker::SelfDescribingJson).to have_received(:new)
+ .with(c[:schema], c[:data]).at_least(:once)
+ kwargs[:context] << an_instance_of(SnowplowTracker::SelfDescribingJson)
+ end
+ end
+
expect(Gitlab::Tracking).to have_received(:event) # rubocop:disable RSpec/ExpectGitlabTracking
.with(category, action, **kwargs).at_least(:once)
end