Sha256: 8ca8314f686755684313571422304139bbbb8f78e4dbaa79ddd937f449f5348c

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'rails_helper'

feature 'JavaScript Tracking', feature: true do
  before { Raygun.configuration.js_api_key = nil }
  after { Raygun.configuration.js_api_key = nil }

  it "Includes the Raygun Javascript Middleware" do
    expect(Rails.application.config.middleware).to include(Raygun::Middleware::JavascriptExceptionTracking)
  end

  it "Does not inject the JS snippet" do
    visit root_path

    expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
    expect(page.html).to_not include('rg4js(')
  end

  context 'With a JS API Key' do
    before { Raygun.configuration.js_api_key = 'Sample key' }

    it "Injects the JS snippet" do
      visit root_path

      expect(page.html).to include('cdn.raygun.io/raygun4js/raygun.min.js')
      expect(page.html).to include('rg4js(')
    end

    it "Does not inject the JS snippet" do
      visit root_path(format: :json)

      expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
      expect(page.html).to_not include('rg4js(')
    end
  end

  context "With JS version overriden" do
    before do
      Raygun.configuration.js_api_version = "2.14.1"
      Raygun.configuration.js_api_key = "Sample key"
    end

    it "Uses the overriden version" do
      visit root_path

      expect(page.html).to include('cdn.raygun.io/raygun4js/2.14.1/raygun.min.js')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
raygun4ruby-3.2.6 spec/features/javascript_spec.rb
raygun4ruby-3.2.5.pre spec/features/javascript_spec.rb
raygun4ruby-3.2.4 spec/features/javascript_spec.rb