Change the Default Controller Name in Rails Functional Tests
Rails will infer the controller you want to test from the class name of the test case. For example... class PeopleControllerTest < ActionController::TestCase end will test the app/controllers/people_controller.rb. To change this is trivial. Us...
Written by Sean Behan on 10/23/2013
Testing current_user and Sessions with Sinatra and Rack Test
Assume you have your standard Sinatra application. # app.rb require 'sinatra' configure do enable :sessions end get '/' do if session[:user_id] "OK" else raise "NOT OK!" end end To test this you need to make a re...
Written by Sean Behan on 08/22/2013
How To Use Rake to Run Your Test Suite with Sinatra
If you're using Sinatra and you want to use rake to run your test suite, you will need to create a Rakefile and put this in it. require 'rake/testtask' task :default do ENV['RACK_ENV'] = 'test' Rake::Task['test'].invoke end Rake::Test...
Written by Sean Behan on 08/22/2013
How to Add Additional Sub Directories to the Default Rails Test:Unit File Structure
# Edit Rakefile in project root # # Add a new rake test task... E.g., rake test:lib, below everything else in that file... # Alternatively, add a task in lib/tasks/ directory and plop in the same code namespace :test do desc "Test lib source" ...
Written by Sean Behan on 06/17/2012
Color Output with Test:Unit, AutoTest and Ruby 1.9
If you are testing using Test:Unit (rather than RSpec) and you're using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded...
Written by Sean Behan on 06/17/2012
Manage Fixtures with Yaml DB Plugin for Rails
Get the plugin like so... script/plugin install git://github.com/adamwiggins/yaml_db.git This command will dump your data rake db:data:dump And load it back rake db:data:load Beautiful :) More info here http://blog.heroku.com/archives/2007/11/23/yam...
Written by Sean Behan on 06/17/2012
paypal ipn simulator
If you use the Paypal sandbox you'll notice that there is an IPN Simulator test tool. You must be logged to use it. This tool lets you test an IPN handler script for your application. If your script is not correct and you try to send a test IPN transactio...
Written by Sean Behan on 06/17/2012
rails fixtures: using the right timestamp
Fixtures in Rails allow you to quickly and easily populate a database with sample data. They are great when testing your app and you need to test against a condition that will rely on a certain preexisting data point. Fixtures are located in your RAILS_R...
Written by Sean Behan on 06/17/2012