Skip to content

Instantly share code, notes, and snippets.

@sbull
Last active August 29, 2015 14:15
Show Gist options
  • Save sbull/3e878e98c4ee3c0c8430 to your computer and use it in GitHub Desktop.
Save sbull/3e878e98c4ee3c0c8430 to your computer and use it in GitHub Desktop.
Test script for undefined method `url_options' for #<Module:xxx> on Rails 4.2: https://github.com/puma/puma/issues/647
$ rails runner route_helpers_debug.rb
Threads: 10, Iterations per thread: 10
Running Rails...
5/2/7/8/1/9/4/5/7/8/9/2/4/7/8/9/2/4/8/9/2/4/8/9/4/8/9/4/9/4/9/4/9/9/
Finished thread 9.
-------
ERRORS: 9
Exception in thread 0, iteration 0: undefined method `url_options' for #<Module:0x007f7cc4735210>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 1, iteration 1: undefined method `url_options' for #<Module:0x007f7cc46a6d58>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 2, iteration 4: undefined method `url_options' for #<Module:0x007f7cc4576000>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 3, iteration 0: undefined method `url_options' for #<Module:0x007f7cc47d0d28>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 4, iteration 8: undefined method `url_options' for #<Module:0x007f7cc44969f0>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 5, iteration 2: undefined method `url_options' for #<Module:0x007f7cc466f240>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 6, iteration 0: undefined method `url_options' for #<Module:0x007f7cc47bbc70>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 7, iteration 3: undefined method `url_options' for #<Module:0x007f7cc4606330>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Exception in thread 8, iteration 6: undefined method `url_options' for #<Module:0x007f7cc450b4d0>
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:218:in `call'
/home/steven/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
route_helpers_debug.rb:38:in `block in <top (required)>'
route_helpers_debug.rb:15:in `call'
route_helpers_debug.rb:15:in `block (3 levels) in run_threads'
route_helpers_debug.rb:13:in `times'
route_helpers_debug.rb:13:in `block (2 levels) in run_threads'
Running Routes...
6/7/7/8/8/8/8/9/9/9/5/5/5/5/5/0/1/1/1/1/1/1/9/9/9/9/6/6/6/6/6/6/6/1/1/1/1/2/2/2/2/0/0/0/0/0/5/5/5/7/7/7/7/7/3/3/3/3/3/5/4/4/4/4/4/4/8/2/2/2/4/4/4/4/9/9/9/7/7/7/5/6/6/3/3/3/3/3/0/0/0/0/
Finished thread 0.
2/2/2/8/8/8/8/8/
Finished thread 1.
Finished thread 2.
Finished thread 3.
Finished thread 4.
Finished thread 5.
Finished thread 6.
Finished thread 7.
Finished thread 8.
Finished thread 9.
-------
ERRORS: 0
$
# via "rails runner"
NUM_THREADS = (ARGV[0] || 10).to_i
NUM_ITERATIONS = (ARGV[1] || NUM_THREADS).to_i
puts "Threads: #{NUM_THREADS}, Iterations per thread: #{NUM_ITERATIONS}"
def run_threads(&block)
threads = []
NUM_THREADS.times do |thread_num|
threads << Thread.new(thread_num) do |num|
Thread.current.thread_variable_set('num', num)
NUM_ITERATIONS.times do |i|
Thread.current.thread_variable_set('iter', i)
print num.to_s + block.call
end
end
end
errors = []
threads.each do |thr|
begin
thr.join
print "\nFinished thread #{thr.thread_variable_get('num')}.\n"
rescue => e
errors << "\nException in thread #{thr.thread_variable_get('num')}, iteration #{thr.thread_variable_get('iter')}: #{e.message}\n"+e.backtrace.map{|bt| "\t#{bt}\n" }.join
end
end
puts "\n-------\nERRORS: #{errors.length}"
puts errors
end
puts "Running Rails..."
run_threads do
Rails.application.routes.url_helpers.root_path
end
module Routes
module UrlHelpers
include Rails.application.routes.url_helpers
end
extend UrlHelpers
def self.default_url_options
ActionMailer::Base.default_url_options
end
end
puts "Running Routes..."
run_threads do
Routes.root_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment