Sha256: e09215074d85553c30fa07fd1e85d5bc0be7eaa4a947738d0acf4d4ad867484a

Contents?: true

Size: 624 Bytes

Versions: 3

Compression:

Stored size: 624 Bytes

Contents

TestController = Struct.new(:env) do
  include Rack::Tracker::Controller

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


RSpec.describe Rack::Tracker::Controller do
  describe '#tracker' do
    let(:event) { Rack::Tracker::GoogleAnalytics::Send.new(category: 'foo') }
    let(:controller) { TestController.new({}) }

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-tracker-0.2.1 spec/tracker/controller_spec.rb
rack-tracker-0.2.0 spec/tracker/controller_spec.rb
rack-tracker-0.1.3 spec/tracker/controller_spec.rb