Sha256: 04366b62e69460bae2648640c3fd2264392c5e5319a831a4a1ced141bde1779c

Contents?: true

Size: 1.58 KB

Versions: 34

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
require 'new_relic/control/class_methods'

class BaseClassMethods
  # stub class to enable testing of the module
  include NewRelic::Control::ClassMethods
end

class NewRelic::Control::ClassMethodsTest < Minitest::Test
  def setup
    @base = ::BaseClassMethods.new
    super
  end

  def test_instance
    assert_equal(nil, @base.instance_variable_get('@instance'), 'instance should start out nil')
    @base.expects(:new_instance).returns('a new instance')
    assert_equal('a new instance', @base.instance, "should return the result from the #new_instance call")
  end

  def test_load_test_framework
    local_env = mock('local env')
    # a loose requirement here because the tests will *all* break if
    # this does not work.
    NewRelic::Control::Frameworks::Test.expects(:new).with(local_env, instance_of(String))
    @base.expects(:local_env).returns(local_env)
    @base.load_test_framework
  end

  def test_load_framework_class_existing
    %w[rails rails3 sinatra ruby merb external].each do |type|
      @base.load_framework_class(type)
    end
  end

  def test_load_framework_class_missing
    # this is used to allow other people to insert frameworks without
    # having the file in our agent, i.e. define your own
    # NewRelic::Control::Framework::FooBar
    assert_raises(NameError) do
      @base.load_framework_class('missing')
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
newrelic_rpm-3.16.2.321 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.16.1.320 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.16.0.318 test/new_relic/control/class_methods_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.15.2.317 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.15.1.316 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.15.0.314 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.14.3.313 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.14.2.312 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.14.1.311 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.13.1.300 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.13.0.299 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.12.1.298 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.12.0.288 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.11.2.286 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.11.1.284 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.11.0.283 test/new_relic/control/class_methods_test.rb
newrelic_rpm-3.10.0.279 test/new_relic/control/class_methods_test.rb