breaking into the unknown…

`block in tours’: undefined method `sub’

Leave a comment

I was trying to use tourbus for load testing, when I got this error while running the test

$ tourbus -c 2 -n 3 thirdpillar_load_testing

/home/arun/.rvm/gems/ruby-1.9.3-p194@threepiller/gems/tourbus-2.0.1/lib/tourist.rb:79:in `block in tours’: undefined method `sub’ for :tour_homepage:Symbol (NoMethodError)

I looked at the line where the error is coming, it look like as below

 def tours
    methods.grep(/^tour_/).map {|m| m.sub(/^tour_/,”)}

This code worked for ruby 1.87 but not for ruby 1.9.1 and above. I thnik in new ruby version methods are treated as symbol rather then string. So, basically we are applying the sub method of string to symbol. This problem can be solved if you convert the methods to string before applying the sub method as below.

  def tours^tour_/).map {|m| m.sub(/^tour_/,”)}

But. You should not change gem file yourself. I checked the tourbus git repository. I am surprised, to see that there do exist a issue posted for this problem, and it is solved also 4 months back, but the code is not pushed to i,e the default repository from where bundle install the gem. So I decided to pass exact git path to the tourbus gem in the gem file as below

gem ‘tourbus’, :git => ‘’

Now,  on running bundle update, I find that , I got the correct code, but it is not installed at desired location (/gems folder of my gemset)where all gems are installed but instead to /bundler/gems folder of my gemset. Anyway, I decided to run the test again

$ tourbus -c 2 -n 3 thirdpillar_load_testing

But, now I getting many missing dependency errors. It is obvious as it is installed at some other folder and all other depending gems are installed at some other folder. I also felt that, the gem is not well maintained and documented so LET IT GO … I moved to other options🙂

Author: arunyadav4u

over 7 years experience in web development with Ruby on Rails.Involved in all stage of development lifecycle : requirement gathering, planing, coding, deployment & Knowledge transfer. I can adept to any situation, mixup very easily with people & can be a great friend.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s