Sha256: 2e5a44644236980bb21f518c31f77a15c12a89d25b4886ed95c4f5e0e0e18152

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 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

9 entries across 9 versions & 1 rubygems

Version Path
raygun4ruby-4.0.2 spec/features/javascript_spec.rb
raygun4ruby-4.0.1 spec/features/javascript_spec.rb
raygun4ruby-4.0.0.pre spec/features/javascript_spec.rb
raygun4ruby-3.2.3 spec/features/javascript_spec.rb
raygun4ruby-3.2.3.pre spec/features/javascript_spec.rb
raygun4ruby-3.2.1 spec/features/javascript_spec.rb
raygun4ruby-3.2.0 spec/features/javascript_spec.rb
raygun4ruby-3.1.1 spec/features/javascript_spec.rb
raygun4ruby-3.1.0 spec/features/javascript_spec.rb