Sha256: a53dee59c437e172dd8f5e882664afe468721199ff63e725d7c76852d813a99c

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

class SomeController
  include Rack::Tracker::Controller

  attr_accessor :env

  def initialize
    @env = {}
  end

  def index
    tracker do |t|
      t.google_analytics category: 'foo'
    end
  end
end


RSpec.describe Rack::Tracker::Controller do
  context 'controller' do
    let(:event) { Rack::Tracker::GoogleAnalytics::Event.new(category: 'foo') }

    it 'writes the event into env' do
      controller = SomeController.new
      expect {
        controller.index
      }.to change {
        controller.env
      }.from({}).to('tracker' => {'google_analytics' => [event]})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-tracker-0.0.4 spec/tracker/controller_spec.rb