newrelic_rpm 3.5.5.540.dev → 3.5.6.42.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +1 -1
  2. data/CHANGELOG +7 -0
  3. data/Rakefile +9 -18
  4. data/lib/new_relic/agent/agent.rb +51 -83
  5. data/lib/new_relic/agent/configuration/manager.rb +12 -0
  6. data/lib/new_relic/agent/configuration/yaml_source.rb +5 -1
  7. data/lib/new_relic/agent/cross_process_monitoring.rb +164 -20
  8. data/lib/new_relic/agent/error_collector.rb +2 -0
  9. data/lib/new_relic/agent/event_listener.rb +39 -0
  10. data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +17 -7
  11. data/lib/new_relic/agent/stats_engine/transactions.rb +1 -0
  12. data/lib/new_relic/build.rb +1 -0
  13. data/lib/new_relic/control/frameworks/rails.rb +17 -3
  14. data/lib/new_relic/rack/agent_hooks.rb +20 -0
  15. data/lib/new_relic/rack/error_collector.rb +11 -1
  16. data/lib/new_relic/recipes.rb +32 -10
  17. data/lib/new_relic/version.rb +10 -15
  18. data/newrelic.yml +6 -0
  19. data/newrelic_rpm.gemspec +23 -454
  20. data/test/multiverse/lib/multiverse/suite.rb +2 -0
  21. data/test/multiverse/suites/active_record/Envfile +1 -1
  22. data/test/multiverse/suites/active_record/config/newrelic.yml +2 -2
  23. data/test/multiverse/suites/agent_only/Envfile +2 -1
  24. data/test/multiverse/suites/agent_only/config/newrelic.yml +3 -1
  25. data/test/multiverse/suites/agent_only/cross_process_test.rb +56 -0
  26. data/test/multiverse/suites/{logging → agent_only}/logging_test.rb +24 -23
  27. data/test/multiverse/suites/agent_only/no_dns_resolv.rb +17 -0
  28. data/test/multiverse/suites/{rum_auto_instrumentation/sanity_test.rb → agent_only/rum_instrumentation_test.rb} +25 -46
  29. data/test/multiverse/suites/{no_load → agent_only}/start_up_test.rb +0 -0
  30. data/test/multiverse/suites/agent_only/testing_app.rb +17 -0
  31. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +6 -5
  32. data/test/multiverse/suites/datamapper/config/newrelic.yml +1 -1
  33. data/test/multiverse/suites/{rails_3_queue_time → rails}/Envfile +3 -0
  34. data/test/multiverse/suites/{rails_3_views → rails}/app/views/foos/_foo.html.haml +0 -0
  35. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_a_partial.html.erb +0 -0
  36. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_mid_partial.html.erb +0 -0
  37. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_top_partial.html.erb +0 -0
  38. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/deep_partial.html.erb +0 -0
  39. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/haml_view.html.haml +0 -0
  40. data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/index.html.erb +0 -0
  41. data/test/multiverse/suites/rails/app.rb +49 -0
  42. data/test/multiverse/suites/{rails_3_error_tracing → rails}/config/newrelic.yml +0 -0
  43. data/test/multiverse/suites/{rails_3_error_tracing → rails}/error_tracing_test.rb +13 -68
  44. data/test/multiverse/suites/{rails_3_gc/instrumentation_test.rb → rails/gc_instrumentation_test.rb} +14 -35
  45. data/test/multiverse/suites/{rails_3_queue_time → rails}/queue_time_test.rb +3 -23
  46. data/test/multiverse/suites/{rails_3_views → rails}/view_instrumentation_test.rb +21 -61
  47. data/test/multiverse/suites/resque/config/newrelic.yml +1 -1
  48. data/test/multiverse/suites/sinatra/config/newrelic.yml +1 -2
  49. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +1 -1
  50. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +1 -1
  51. data/test/new_relic/agent/agent/connect_test.rb +17 -74
  52. data/test/new_relic/agent/agent/start_worker_thread_test.rb +3 -3
  53. data/test/new_relic/agent/agent_test.rb +59 -2
  54. data/test/new_relic/agent/configuration/manager_test.rb +28 -0
  55. data/test/new_relic/agent/configuration/yaml_source_test.rb +12 -2
  56. data/test/new_relic/agent/cross_process_monitoring_test.rb +144 -31
  57. data/test/new_relic/agent/event_listener_test.rb +46 -0
  58. data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +57 -30
  59. data/test/new_relic/agent/worker_loop_test.rb +1 -1
  60. data/test/new_relic/fake_collector.rb +17 -4
  61. data/test/new_relic/rack/agent_hooks_test.rb +30 -0
  62. data/test/new_relic/rack/error_collector_test.rb +16 -0
  63. data/test/new_relic/version_number_test.rb +6 -30
  64. data/test/script/ci.sh +6 -5
  65. data/test/test_contexts.rb +1 -0
  66. data/test/test_helper.rb +2 -4
  67. metadata +34 -42
  68. data/newrelic_rpm.gemspec.erb +0 -53
  69. data/test/fixtures/gemspec_no_build.rb +0 -442
  70. data/test/fixtures/gemspec_with_build.rb +0 -442
  71. data/test/fixtures/gemspec_with_build_and_stage.rb +0 -442
  72. data/test/multiverse/suites/logging/Envfile +0 -4
  73. data/test/multiverse/suites/logging/config/newrelic.yml +0 -22
  74. data/test/multiverse/suites/monitor_mode_false/Envfile +0 -2
  75. data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +0 -25
  76. data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +0 -29
  77. data/test/multiverse/suites/no_load/Envfile +0 -2
  78. data/test/multiverse/suites/no_load/config/newrelic.yml +0 -22
  79. data/test/multiverse/suites/rails_3_error_tracing/Envfile +0 -15
  80. data/test/multiverse/suites/rails_3_gc/Envfile +0 -8
  81. data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +0 -167
  82. data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +0 -165
  83. data/test/multiverse/suites/rails_3_views/.gitignore +0 -3
  84. data/test/multiverse/suites/rails_3_views/Envfile +0 -16
  85. data/test/multiverse/suites/rails_3_views/config/newrelic.yml +0 -164
  86. data/test/multiverse/suites/rum_auto_instrumentation/Envfile +0 -4
  87. data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +0 -24
  88. data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +0 -5000
@@ -56,6 +56,8 @@ module Multiverse
56
56
  if RUBY_VERSION > '1.8.7'
57
57
  f.puts " gem 'test-unit', :require => 'test/unit'"
58
58
  f.puts " gem 'debugger'" if include_debugger
59
+ else
60
+ f.puts " gem 'ruby-debug'" if include_debugger
59
61
  end
60
62
  end
61
63
  puts yellow("Gemfile set to:") if verbose?
@@ -7,7 +7,7 @@ gemfile <<-RB
7
7
  gem 'activerecord'
8
8
  else
9
9
  gem 'activerecord'
10
- gem 'sqlite3'
10
+ gem 'sqlite3', '~> 1.3.5'
11
11
  end
12
12
 
13
13
  RB
@@ -11,8 +11,8 @@ development:
11
11
  app_name: test
12
12
  host: 127.0.0.1
13
13
  api_host: 127.0.0.1
14
- port: 30303
15
- transaction_tracer:
14
+ port: <%= 30_000 + ($$ % 10_000) %>
15
+ transaction_trace:
16
16
  record_sql: obfuscated
17
17
  enabled: true
18
18
  stack_trace_threshold: 0.5
@@ -1,4 +1,5 @@
1
1
  gemfile <<-RB
2
2
  gem 'rack'
3
+ gem 'rack-test'
3
4
  gem 'mocha', '< 0.13'
4
- RB
5
+ RB
@@ -11,7 +11,7 @@ development:
11
11
  app_name: test
12
12
  host: 127.0.0.1
13
13
  api_host: 127.0.0.1
14
- port: 30303
14
+ port: <%= 30_000 + ($$ % 10_000) %>
15
15
  transaction_tracer:
16
16
  record_sql: obfuscated
17
17
  enabled: true
@@ -20,3 +20,5 @@ development:
20
20
  capture_params: false
21
21
  log_level: debug
22
22
  log_file_path: agent.log
23
+ browser_monitoring:
24
+ auto_instrument: true
@@ -0,0 +1,56 @@
1
+ require 'rack/test'
2
+ require 'fake_collector'
3
+ require './testing_app'
4
+
5
+ class CrossProcessTest < Test::Unit::TestCase
6
+
7
+ # Important because the hooks are global that we only wire one AgentHooks up
8
+ @@app = TestingApp.new
9
+ @@wrapper_app = NewRelic::Rack::AgentHooks.new(@@app)
10
+
11
+ def setup
12
+ $collector ||= NewRelic::FakeCollector.new
13
+ $collector.reset
14
+ $collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
15
+ $collector.run
16
+
17
+ NewRelic::Agent.manual_start(
18
+ :cross_process_id => "boo",
19
+ :encoding_key => "\0",
20
+ :trusted_account_ids => [1])
21
+
22
+ NewRelic::Agent.instance.events.notify(:finished_configuring)
23
+
24
+ @@app.reset_headers
25
+ @@app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
26
+ end
27
+
28
+ def teardown
29
+ NewRelic::Agent.shutdown
30
+ end
31
+
32
+ include Rack::Test::Methods
33
+
34
+ def app
35
+ @@wrapper_app
36
+ end
37
+
38
+ def test_cross_process_doesnt_modify_without_header
39
+ get '/'
40
+ assert_nil last_response.headers["X-NewRelic-App-Data"]
41
+ end
42
+
43
+ def test_cross_process_doesnt_modify_with_invalid_header
44
+ get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
45
+ assert_nil last_response.headers["X-NewRelic-App-Data"]
46
+ end
47
+
48
+ def test_cross_process_writes_out_information
49
+ get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
50
+ assert_not_nil last_response.headers["X-NewRelic-App-Data"]
51
+
52
+ metric = NewRelic::Agent.instance.stats_engine.lookup_stats('ClientApplication/1#234/all')
53
+ assert_equal 1, metric.call_count
54
+ end
55
+ end
56
+
@@ -36,27 +36,31 @@ class LoggingTest < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  def test_logs_raw_sql_warning
39
- NewRelic::Agent.config.apply_config(:'transaction_tracer.record_sql' => 'obfuscated')
40
-
41
39
  running_agent_writes_to_log(
42
- {:'transaction_tracer.record_sql' => 'raw'},
43
- "Agent is configured to send raw SQL to the service")
40
+ {:'transaction_tracer.record_sql' => 'obfuscated'},
41
+ "Agent is configured to send raw SQL to the service") do
42
+
43
+ NewRelic::Agent.config.apply_config(:'transaction_tracer.record_sql' => 'raw')
44
+ end
45
+
44
46
  end
45
47
 
46
48
  def test_logs_if_sending_errors_on_change
47
- NewRelic::Agent.config.apply_config(:'error_collector.enabled' => false)
48
-
49
49
  running_agent_writes_to_log(
50
- {:'error_collector.enabled' => true},
51
- "Errors will be sent")
50
+ {:'error_collector.enabled' => false},
51
+ "Errors will be sent") do
52
+
53
+ NewRelic::Agent.config.apply_config(:'error_collector.enabled' => true)
54
+ end
52
55
  end
53
56
 
54
57
  def test_logs_if_not_sending_errors_on_change
55
- NewRelic::Agent.config.apply_config(:'error_collector.enabled' => true)
56
-
57
58
  running_agent_writes_to_log(
58
- {:'error_collector.enabled' => false},
59
- "Errors will not be sent")
59
+ {:'error_collector.enabled' => true},
60
+ "Errors will not be sent") do
61
+
62
+ NewRelic::Agent.config.apply_config(:'error_collector.enabled' => false)
63
+ end
60
64
  end
61
65
 
62
66
  def test_logs_transaction_tracing_disabled
@@ -103,8 +107,7 @@ class LoggingTest < Test::Unit::TestCase
103
107
  $collector.run
104
108
 
105
109
  NewRelic::Agent.reset_config
106
- NewRelic::Agent.agent = NewRelic::Agent::Agent.new
107
- NewRelic::Control.instance(true)
110
+ NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
108
111
 
109
112
  @logger = NewRelic::Agent::MemoryLogger.new
110
113
  NewRelic::Agent.logger = @logger
@@ -113,25 +116,23 @@ class LoggingTest < Test::Unit::TestCase
113
116
 
114
117
  def teardown
115
118
  $collector.reset
119
+
120
+ # Really clear out our agent instance since we set bad license keys
121
+ NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
116
122
  end
117
123
 
118
124
  # Helpers
119
125
  def running_agent_writes_to_log(options, msg)
120
- run_agent_with(options) do
121
- saw?(msg)
122
- end
126
+ NewRelic::Agent.manual_start(options)
127
+ yield if block_given?
128
+ NewRelic::Agent.shutdown
129
+ saw?(msg)
123
130
  end
124
131
 
125
132
  def with_connect_response(status=200, response={})
126
133
  $collector.mock['connect'] = [status, response]
127
134
  end
128
135
 
129
- def run_agent_with(options = {})
130
- NewRelic::Agent.manual_start(options)
131
- NewRelic::Agent.shutdown
132
- yield
133
- end
134
-
135
136
  def saw?(*expected_messages)
136
137
  flattened = @logger.messages.flatten
137
138
  expected_messages.each do |expected|
@@ -0,0 +1,17 @@
1
+
2
+ class NoDnsResolv < Test::Unit::TestCase
3
+ def test_should_no_resolve_hostname_when_agent_is_disabled
4
+ Resolv.expects(:getaddress).never
5
+ NewRelic::Agent.manual_start(:monitor_mode => false)
6
+ end
7
+
8
+ def setup
9
+ NewRelic::Agent::Agent.instance_variable_set(:@instance, NewRelic::Agent::Agent.new)
10
+ end
11
+
12
+ def teardown
13
+ $collector.reset
14
+ NewRelic::Agent.shutdown
15
+ NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
16
+ end
17
+ end
@@ -1,68 +1,47 @@
1
- require 'test/unit'
2
- require "rack/test"
1
+ require 'rack/test'
3
2
  require 'new_relic/rack/browser_monitoring'
4
- require 'benchmark'
5
-
6
- class MyApp
7
- # allow tests to set up the response they want.
8
- class << self
9
- def reset_headers
10
- @headers = {'Content-Type' => 'text/html'}
11
- end
12
- attr_accessor :response
13
- attr_accessor :headers
14
- def add_header(key, value)
15
- @headers[key] = value
16
- @headers
17
- end
18
- end
19
-
20
-
21
-
22
- def call(env)
23
- [200, self.class.headers, [self.class.response]]
24
- end
25
- end
26
-
27
- NewRelic::Agent.manual_start(:browser_key => 'browserKey', :application_id => 'appId',
28
- :beacon => 'beacon', :episodes_file => 'this_is_my_file')
29
- NewRelic::Agent.instance.instance_eval do
30
- @beacon_configuration = NewRelic::Agent::BeaconConfiguration.new
31
- end
3
+ require './testing_app'
32
4
 
33
5
  class RumAutoTest < Test::Unit::TestCase
34
- def setup
35
- MyApp.reset_headers
36
- end
37
6
 
7
+ attr_reader :app
38
8
  include Rack::Test::Methods
39
9
 
40
- def app
41
- NewRelic::Rack::BrowserMonitoring.new(MyApp.new)
10
+ def setup
11
+ @inner_app = TestingApp.new
12
+ @app = NewRelic::Rack::BrowserMonitoring.new(@inner_app)
13
+
14
+ NewRelic::Agent.manual_start(:browser_key => 'browserKey', :application_id => 'appId',
15
+ :beacon => 'beacon', :episodes_file => 'this_is_my_file')
16
+ NewRelic::Agent.instance.instance_variable_set(
17
+ :@beacon_configuration, NewRelic::Agent::BeaconConfiguration.new)
42
18
  end
43
19
 
20
+ def teardown
21
+ NewRelic::Agent.shutdown
22
+ end
44
23
 
45
24
  def test_autoinstrumenation_is_active
46
- MyApp.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
25
+ @inner_app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
47
26
  get '/'
48
27
  assert(last_response.body =~ %r|<script|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
49
28
  assert(last_response.body =~ %r|NREUMQ|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
50
29
  end
51
30
 
52
31
  def test_autoinstrumenation_with_basic_page_puts_header_at_beggining_of_head
53
- MyApp.response = "<html><head><title>foo</title></head><body><p>Hello World</p></body></html>"
32
+ @inner_app.response = "<html><head><title>foo</title></head><body><p>Hello World</p></body></html>"
54
33
  get '/'
55
34
  assert(last_response.body.include?('<html><head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><title>foo</title></head><body>'))
56
35
  end
57
36
 
58
37
  def test_autoinstrumenation_with_body_only_puts_header_before_body
59
- MyApp.response = "<html><body><p>Hello World</p></body></html>"
38
+ @inner_app.response = "<html><body><p>Hello World</p></body></html>"
60
39
  get '/'
61
40
  assert(last_response.body.include?('<html><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><body>'))
62
41
  end
63
42
 
64
43
  def test_autoinstrumenation_with_X_UA_Compatible_puts_header_at_end_of_head
65
- MyApp.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /></head><body><p>Hello World</p></body></html>'
44
+ @inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /></head><body><p>Hello World</p></body></html>'
66
45
  get '/'
67
46
  assert(last_response.body.include?(
68
47
  '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script></head><body>'
@@ -71,21 +50,21 @@ class RumAutoTest < Test::Unit::TestCase
71
50
 
72
51
  # regression
73
52
  def test_autoinstrumenation_fails_gracefully_with_X_UA_Compatible_and_no_close_head_tag_puts_header_before_body_tag
74
- MyApp.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><body><p>Hello World</p></body></html>'
53
+ @inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><body><p>Hello World</p></body></html>'
75
54
  get '/'
76
55
  assert(!last_response.body.include?(%'NREUMQ'))
77
56
  end
78
57
 
79
58
  def test_autoinstrumenation_doesnt_run_for_crazy_shit_like_this
80
- MyApp.response = '<html><head <body </body>'
59
+ @inner_app.response = '<html><head <body </body>'
81
60
  get '/'
82
61
  assert_equal('<html><head <body </body>', last_response.body)
83
62
  end
84
63
 
85
64
  def test_content_length_is_correctly_set_if_present
86
- MyApp.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
87
- content_length = MyApp.response.length
88
- MyApp.add_header("Content-Length", content_length)
65
+ @inner_app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
66
+ content_length = @inner_app.response.length
67
+ @inner_app.headers["Content-Length"] = content_length
89
68
  get '/'
90
69
  assert(last_response.headers['Content-Length'].to_i > content_length)
91
70
  assert_equal(last_response.body.length.to_s, last_response.headers['Content-Length'])
@@ -93,8 +72,8 @@ class RumAutoTest < Test::Unit::TestCase
93
72
 
94
73
  def test_xml_responses_arent_instrumented
95
74
  body = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
96
- MyApp.response = body
97
- MyApp.add_header("Content-Type", "text/xml")
75
+ @inner_app.response = body
76
+ @inner_app.headers["Content-Type"] = "text/xml"
98
77
  get '/'
99
78
  assert_equal(last_response.body, body)
100
79
  end
@@ -0,0 +1,17 @@
1
+ class TestingApp
2
+
3
+ attr_accessor :response, :headers
4
+
5
+ def initialize
6
+ reset_headers
7
+ end
8
+
9
+ def reset_headers
10
+ @headers = {'Content-Type' => 'text/html'}
11
+ end
12
+
13
+ def call(env)
14
+ [200, headers, [response]]
15
+ end
16
+
17
+ end
@@ -4,17 +4,18 @@
4
4
  if RUBY_VERSION >= '1.9'
5
5
  class ThreadProfilingTest < Test::Unit::TestCase
6
6
  def setup
7
- NewRelic::Agent.manual_start(:'thread_profiler.enabled' => true)
8
-
9
- @agent = NewRelic::Agent.instance
10
- @thread_profiler = @agent.thread_profiler
11
-
12
7
  $collector ||= NewRelic::FakeCollector.new
13
8
  $collector.reset
14
9
  $collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
15
10
  $collector.mock['get_agent_commands'] = [200, {'return_value' => START_COMMAND}]
16
11
  $collector.mock['agent_command_results'] = [200, {'return_value' => []}]
17
12
  $collector.run
13
+
14
+ NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
15
+ NewRelic::Agent.manual_start(:'thread_profiler.enabled' => true)
16
+
17
+ @agent = NewRelic::Agent.instance
18
+ @thread_profiler = @agent.thread_profiler
18
19
  end
19
20
 
20
21
  def teardown
@@ -11,7 +11,7 @@ development:
11
11
  app_name: test
12
12
  host: 127.0.0.1
13
13
  api_host: 127.0.0.1
14
- port: 30303
14
+ port: <%= 30_000 + ($$ % 10_000) %>
15
15
  transaction_tracer:
16
16
  record_sql: obfuscated
17
17
  enabled: true
@@ -4,12 +4,15 @@ end
4
4
 
5
5
  gemfile <<-RB
6
6
  gem 'rails', '~>3.2.0'
7
+ gem 'haml'
7
8
  RB
8
9
 
9
10
  gemfile <<-RB
10
11
  gem 'rails', '~>3.1.0'
12
+ gem 'haml'
11
13
  RB
12
14
 
13
15
  gemfile <<-RB
14
16
  gem 'rails', '~>3.0.0'
17
+ gem 'haml'
15
18
  RB
@@ -0,0 +1,49 @@
1
+ require 'action_controller/railtie'
2
+
3
+ # We define our single Rails application here, one time, upon the first inclusion
4
+ # Tests should feel free to define their own Controllers locally, but if they
5
+ # need anything special at the Application level, put it here
6
+ if !defined?(MyApp)
7
+
8
+ ENV['NEW_RELIC_DISPATCHER'] = 'test'
9
+
10
+ class MyApp < Rails::Application
11
+ # We need a secret token for session, cookies, etc.
12
+ config.active_support.deprecation = :log
13
+ config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
14
+ end
15
+ MyApp.initialize!
16
+
17
+ MyApp.routes.draw do
18
+ get('/bad_route' => 'Test#controller_error',
19
+ :constraints => lambda do |_|
20
+ raise ActionController::RoutingError.new('this is an uncaught routing error')
21
+ end)
22
+ match '/:controller(/:action(/:id))'
23
+ end
24
+
25
+ class ApplicationController < ActionController::Base; end
26
+
27
+ # a basic active model compliant model we can render
28
+ class Foo
29
+ extend ActiveModel::Naming
30
+ def to_model
31
+ self
32
+ end
33
+
34
+ def valid?() true end
35
+ def new_record?() true end
36
+ def destroyed?() true end
37
+
38
+ def raise_error
39
+ raise 'this is an uncaught model error'
40
+ end
41
+
42
+ def errors
43
+ obj = Object.new
44
+ def obj.[](key) [] end
45
+ def obj.full_messages() [] end
46
+ obj
47
+ end
48
+ end
49
+ end