Sha256: 161b6b60924cda4f63431ab47c957e975dfb92675849ab3ce4a00cf467385af8

Contents?: true

Size: 1.84 KB

Versions: 214

Compression:

Stored size: 1.84 KB

Contents

describe Appsignal::EventFormatter::ActionView::RenderFormatter do
  let(:klass) { Appsignal::EventFormatter::ActionView::RenderFormatter }

  if DependencyHelper.rails_present?
    require "action_view"

    context "when in a Rails app" do
      let(:formatter) { klass.new }
      before { allow(Rails.root).to receive(:to_s).and_return("/var/www/app/20130101") }

      it "registers render_partial.action_view and render_template.action_view" do
        expect(Appsignal::EventFormatter.registered?("render_partial.action_view", klass)).to be_truthy
        expect(Appsignal::EventFormatter.registered?("render_template.action_view", klass)).to be_truthy
      end

      describe "#root_path" do
        subject { formatter.root_path }

        it "returns Rails root path" do
          is_expected.to eq "/var/www/app/20130101/"
        end
      end

      describe "#format" do
        subject { formatter.format(payload) }

        context "with an identifier" do
          let(:payload) { { :identifier => "/var/www/app/20130101/app/views/home/index/html.erb" } }

          it { is_expected.to eq ["app/views/home/index/html.erb", nil] }
        end

        context "with a frozen identifier" do
          let(:payload) { { :identifier => "/var/www/app/20130101/app/views/home/index/html.erb".freeze } }

          it { is_expected.to eq ["app/views/home/index/html.erb", nil] }
        end

        context "without an identifier" do
          let(:payload) { {} }

          it { is_expected.to be_nil }
        end
      end
    end
  else
    context "when not in a Rails app" do
      it "does not register the event formatter" do
        expect(Appsignal::EventFormatter.registered?("render_partial.action_view", klass)).to be_falsy
        expect(Appsignal::EventFormatter.registered?("render_template.action_view", klass)).to be_falsy
      end
    end
  end
end

Version data entries

214 entries across 214 versions & 1 rubygems

Version Path
appsignal-3.3.11-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.11 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.4.0-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.4.0 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.10-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.10 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.9-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.9 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.8-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.8 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.7-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.7 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.6-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.6 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.5-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.5 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.4-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.4 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.3-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.3.3 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb