Sha256: 5a7e7c8cbf92786a0ab01aa6703717ef34948cae52f8e433cf0af82d6122cb47

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Liquid::Tags::GoogleAnalytics do

  let(:context) { ::Liquid::Context.new({ 'ga_id' => '42' })}
  let(:source)  { "{% google_analytics 42 %}" }

  subject { render_template(source, context) }

  it { is_expected.to include %{<script async src="https://www.googletagmanager.com/gtag/js?id=42"></script>} }
  it { is_expected.to include "gtag('config', '42');" }

  describe 'passing a string' do

    let(:source) { "{% google_analytics 'ga-42' %}" }

    it { is_expected.to include %{<script async src="https://www.googletagmanager.com/gtag/js?id=ga-42"></script>} }
    it { is_expected.to include "gtag('config', 'ga-42');" }

  end

  describe 'passing a variable' do

    let(:source) { "{% google_analytics ga_id %}" }

    it { is_expected.to include %{<script async src="https://www.googletagmanager.com/gtag/js?id=42"></script>} }
    it { is_expected.to include "gtag('config', '42');" }

  end

  describe 'raises an error if the syntax is incorrect' do
    let(:source) { '{% google_analytics %}' }
    it { expect { subject }.to raise_exception(::Liquid::SyntaxError) }
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.7.1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.7.0 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.6.1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.6.0 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.5.3 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.5.2 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.5.1 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.5.0 spec/unit/liquid/tags/google_analytics_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/unit/liquid/tags/google_analytics_spec.rb