2019-06-05 12:28:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe TrackingHelper do
|
2019-06-05 12:28:41 -04:00
|
|
|
describe '#tracking_attrs' do
|
2019-08-14 15:21:58 -04:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
let(:input) { %w(a b c) }
|
|
|
|
let(:results) do
|
|
|
|
{
|
|
|
|
no_data: {},
|
|
|
|
with_data: { data: { track_label: 'a', track_event: 'b', track_property: 'c' } }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
where(:snowplow_enabled, :environment, :result) do
|
|
|
|
true | 'production' | :with_data
|
|
|
|
false | 'production' | :no_data
|
|
|
|
true | 'development' | :no_data
|
|
|
|
false | 'development' | :no_data
|
|
|
|
true | 'test' | :no_data
|
|
|
|
false | 'test' | :no_data
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it 'returns a hash' do
|
|
|
|
stub_application_setting(snowplow_enabled: snowplow_enabled)
|
|
|
|
allow(Rails).to receive(:env).and_return(environment.inquiry)
|
|
|
|
|
|
|
|
expect(helper.tracking_attrs(*input)).to eq(results[result])
|
|
|
|
end
|
2019-06-05 12:28:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|