• Nicolas Dular's avatar
    Fix Snowplow spec helper · 45ab261f
    Nicolas Dular authored
    With Ruby 2.6 using `**kwargs` here will not work because it would be an
    empty hash that we then expect to be submitted to
    `Gitlab::Tracking#event`.
    
    An example when using `expect_snowplow_event`:
    
    ```
    expect_snowplow_event(
      category: 'cluster:services:prometheus',
      action: 'enabled_manual_prometheus'
    )
    ```
    
    Error:
    ```
    Gitlab::Tracking received :event with unexpected arguments
    expected:
      ("cluster:services:prometheus", "enabled_manual_prometheus", {})
    got:
      ("cluster:services:prometheus", "disabled_manual_prometheus") (1 time)
    ("cluster:services:prometheus", "enabled_manual_prometheus") (1 time)
    ```
    
    This has not been an issue so far because the other specs we migrated
    always provided additional `kwargs`.
    
    To prevent this, we only expect the `**kwargs` parameter when it exists.
    However, this will get fixed with Ruby 2.7 and we can remove the
    condition again.
    45ab261f
snowplow_helpers.rb 1.59 KB