Skip to main content

Posts

Showing posts from March, 2015

Adding code to Rails projects other than MVC

I wanted to have development code separate from the M V C of the rails code so I added a folder lib/rubyscripts Then in config/application.rb, added this line to load the code there automatically config.autoload_paths << Rails .root.join( " lib/rubyscripts " ) After this, I can access code from this area in my controllers etc by using require "class_name" What is funny about this setup though is that, unlike in the controllers (where I can just use require "class_name" ) I still have to use the relative location rubyscripts/class_name in my spec files when referring to this code, don't exactly know why! For example, spec/lib/rubyscripts/count_finder_spec.rb @@ -0,0 +1,14 @@ + require " spec_helper " + require " rubyscripts/countFinder " + + # Test for lib/rubyscripts/count_finder.rb + + RSpec .describe " CountFinder " do + it " calculates counts " do + cc = Cou