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.1.2-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.1.2 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.1.1-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.1.1 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.1.0-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.1.0 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.27-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.27 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.26-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.26 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.25-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.25 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.24-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.24 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.23-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.23 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.22-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.22 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.21-java spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
appsignal-3.0.21 spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb