Sha256: 618f920a1437435a9f61e0cef9ba7cea010973ac28ce5fc3983ac7f7eb72d30f

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

require 'ostruct'

module NewRelic
  class FakeService
    attr_accessor :request_timeout, :agent_id, :agent_data, :collector, :mock
    
    def initialize
      @agent_data = []
      @supported_methods = [ :connect, :metric_data, :transaction_sample_data,
                             :error_data, :sql_trace_data, :shutdown ]
      @collector = NewRelic::Control::Server.new(:name => 'fakehost', :port => 0)
      @id_counter = 0
      @base_expectations = {
        'get_redirect_host'       => 'localhost',
        'connect'                 => { 'agent_run_id' => agent_run_id },
        'metric_data'             => { 'Some/Metric/Spec' => 1 },
        'sql_trace_data'          => nil,
        'transaction_sample_data' => nil,
        'error_data'              => nil,
        'shutdown'                => nil,
      }
      reset
    end

    def agent_run_id
      @id_counter += 1
    end

    def reset
      @mock = @base_expectations.dup
      @id_counter = 0
      @agent_data = []
    end
    
    def method_missing(method, *args)
      if @supported_methods.include?(method)
        @agent_data << OpenStruct.new(:action => method, :params => args)
        @mock[method.to_s]
      else
        super
      end
    end  
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
newrelic_rpm-3.5.2.17 test/new_relic/fake_service.rb
newrelic_rpm-3.5.1.14 test/new_relic/fake_service.rb
newrelic_rpm-3.5.1.14.beta test/new_relic/fake_service.rb
newrelic_rpm-3.5.1.beta1 test/new_relic/fake_service.rb
newrelic_rpm-3.5.0.1 test/new_relic/fake_service.rb
newrelic_rpm-3.5.1.alpha test/new_relic/fake_service.rb
newrelic_rpm-3.5.0 test/new_relic/fake_service.rb
newrelic_rpm-3.4.2.1 test/new_relic/fake_service.rb
newrelic_rpm-3.4.2 test/new_relic/fake_service.rb
newrelic_rpm-3.4.2.beta1 test/new_relic/fake_service.rb
newrelic_rpm-3.4.1 test/new_relic/fake_service.rb
newrelic_rpm-3.4.1.beta1 test/new_relic/fake_service.rb
ghazel-newrelic_rpm-3.4.0.2 test/new_relic/fake_service.rb
newrelic_rpm-3.4.0.1 test/new_relic/fake_service.rb
newrelic_rpm-3.4.0 test/new_relic/fake_service.rb
newrelic_rpm-3.4.0.beta2 test/new_relic/fake_service.rb