Sha256: ff848a6e20539411ed07f49a83fe728a562c93f2f52116fcb87e679a12694fcc

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Rails controller integration" do
  
  class ApplicationController < ActionController::Base
    
    before_filter :track_impression
    
    private
    
      def track_impression
        RestfulMetrics::Client.add_metric("foo.bar.org", "impression", 1, restful_metrics_cookie)
      end

  end
  
  class TestController < ApplicationController

    def index
      @distinct_id = restful_metrics_cookie
      RestfulMetrics::Client.add_metric("foo.bar.org", "custom", 1, @distinct_id)
      render :text => "OK"
    end

    def rescue_action(e); raise(e); end
  end
  ActionController::Routing::Routes.draw {|map| map.resources :test }
  
  before(:each) do
    RestfulMetrics::Connection.any_instance.stubs(:post).returns(true)
    RestfulMetrics::Client.set_credentials('xyz123')
    @request = ActionController::TestRequest.new
    @request.action = 'index'
    @request.path = "/index"
  end
  
  it "should track all metrics in the stack" do
    RestfulMetrics::Client.expects(:add_metric).twice.returns(true)
    TestController.new.process(@request, ActionController::TestResponse.new).code.should == "200"
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restful_metrics-1.0.1 spec/cookie_integration_spec.rb
restful_metrics-1.0.0 spec/cookie_integration_spec.rb
restful_metrics-0.5.4 spec/cookie_integration_spec.rb
restful_metrics-0.5.2 spec/cookie_integration_spec.rb
restful_metrics-0.5.1 spec/cookie_integration_spec.rb