Sha256: ba9aaa1608256c5292cbc3eef6e8412f159cee95f079505ba13911378dd503e7

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require 'support/capybara_app_helper'

RSpec.describe "Rails Integration" do
  before do
    setup_app(action: :index) do |tracker|
      tracker.handler :track_all_the_things, { custom_key: 'SomeKey123' }
      tracker.handler :another_handler, { custom_key: 'AnotherKey42' }
    end

    visit '/'
  end

  subject { page.html.gsub(/^\s*/, '') }

  let(:expected_html) do
    <<-HTML.gsub(/^\s*/, '')
      <html>
        <head>
          <title>Metal Layout</title>
        <script type="text/javascript">
        myAwesomeFunction("tracks", "like", "no-one-else", "SomeKey123");
      </script>
      </head>
        <body class="do-we-support-attributes-on-the-body-tag">
          <h1>welcome to metal#index</h1>
        <script type="text/javascript">
        anotherFunction("tracks-event-from-down-under", "AnotherKey42");
      </script>
        </body>
      </html>
    HTML
  end

  it "embeds the script tag with tracking event from the controller action" do
    expect(subject).to eql(expected_html)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rack-tracker-1.11.2 spec/integration/rails_integration_spec.rb
rack-tracker-1.11.1 spec/integration/rails_integration_spec.rb
rack-tracker-1.11.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.10.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.9.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.8.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.7.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.6.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.5.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.4.0 spec/integration/rails_integration_spec.rb
rack-tracker-1.3.1 spec/integration/rails_integration_spec.rb