Sha256: f21c170b87a0c75b5a686d17ec9ab98b7bf9295289746d92a02ba4fd86a7b9af

Contents?: true

Size: 951 Bytes

Versions: 14

Compression:

Stored size: 951 Bytes

Contents

RSpec.describe Rack::Tracker::GoogleTagManager do

  def env
    {
      misc: 'foobar',
      user_id: '123'
    }
  end

  describe "with events" do
    describe "default" do
      def env
        {'tracker' => {
          'google_tag_manager' => [
            { 'class_name' => 'Push', 'page' => 'Cart', 'price' => 50, 'content_ids' => ['sku_1', 'sku_2', 'sku_3'] }
          ]
        }}
      end

      subject { described_class.new(env, container: 'somebody').render_head }
      it "will show events" do
        expect(subject).to match(%r{"page":"Cart","price":50,"content_ids":\["sku_1","sku_2","sku_3"\]})
      end
    end
  end

  describe "with dynamic tracker" do
    subject { described_class.new(env, { container: lambda { |env| return env[:misc] }}).render_head }

    it 'will call tracker lambdas to obtain tracking codes' do
      expect(subject).to match(%r{\(window,document,'script','dataLayer','foobar'\)})
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rack-tracker-1.12.1 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.12.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.11.2 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.11.1 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.11.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.10.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.9.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.8.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.7.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.6.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.5.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.4.0 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.3.1 spec/handler/google_tag_manager_spec.rb
rack-tracker-1.3.0 spec/handler/google_tag_manager_spec.rb