News: Sensation!!! Hydrochlorothiazide Nylidrin Cortisol Dont buy on black market get viagra legally Hydroxyzine Prescriptions on line phentermine Snorting xanax Methamphetamine Between difference levivia viagra Fastin Dimethothiazine Weight loss phentermine Congress viagra Lowest prices on phentermine Urine drug testing of tramadol Klonopin Clomid Hydrocodone prescription online Thiotepa Generic price viagra Fexofenadine Diet pill phentermine Ceclor Generic uk viagra Monopril Phentermine lortab online Vicodin prescription Minocin Phentermine cheapest Phentermine and methamphetamine Online viagra sale Free sample viagra Buy viagra now Glycopyrrolate Long term phentermine use Ambien prescription Buy phentermine online cod How to inject xanax pills Maxzide Clarinex Xanax high Daunorubicin Cefaclor Atropine Uk online pharmacy phentermine Generic xanax xr Xanax online overnight Probucol Foradil Information about viagra Online pharmacy phentermine Side effects of the drug tramadol Propylthiouracil Adipex meridia phentermine xenical Xanax ambien Buy phentermine online cheap Macular degeneration caused by viagra Xanax liver damage Paromomycin Xanax grapefruit juice Veterinary use of tramadol Lescol Viagrafix corporation Add a link viagra Hydroxyurea Buy xanax no perscription needed amex accepted Phentermine 37.5 diet pills Free xanax Nasacort aciphex phentermine actos imitrex Xanax overnight Etanercept Amoxicillin Colestipol Buy generic xanax Does phentermine interact with hydrocodone Hytrin Quinidine Viagra lawsuits Dangers of phentermine heart Meridia side effects Prozac Phentermine cheap no prescription Diphenhydramine Cheapest fioricet Pravastatin Phentermine side effects dangers Phentermine medication Tramadol withdrawal Tramadol side effects Ambien online Luxury hotel rome xanax description Buy generic viagra Atropine Vicodin effects Norvasc Drug testing xanax Penicillin Phentermine sameday overnight saturday delivery Molindone Hydrocodone drug Imuran Diphenoxylate Hydrocodone medication Cialis immunity Discount viagra perscription drug Diet no phentermine pill prescription Mebendazole Viagra price compare Bretylium Colace Uk viagra body building from sports supplement Herbal viagra alternatives Clarithromycin Diazepam Pantoprazole Phentermine lose weight loss diet pills Cheapest phentermine Viagra generic brand Hydrocodone info Cialis side effects Cialis levitra vs Gemfibrozil Xanax shipped cod Phentermine buy Viagra online ordering Flexeril Generic name online qoclick tramadol Phentermine eprescriptions Order phentermine diet pill Nafcillin Buy cheap no phentermine prescription Xanax cod Elidel Phentermine ship to ky Viagra 100 mg Buy cheap viagra Levivia vs viagra Xanax online no prescription Cheap online order viagra Order ambien online Levitra cialis info Add link phentermine purchase Ampicillin Line prescription viagra Cheapest viagra uk Haloperidol Bricanyl Dexfenfluramine Different types of phentermine Vincristine Prazosin Comparison viagra cialis levitra Phentermine shipped to tn Buy Zyban Viagra suppliers Phentermine referring report urls Best price for viagra in the uk Hydrocodone cough syrup Viagra and ischemic optic neuropathy Free ambien Cefonicid Methylphenidate Buying xanax online Lincomycin Adapalene Pioglitazone Cod overnight tramadol Cyclothiazide 180 tramadol 92 accepted cod phentermine Norfloxacin How does xanax work Viagra xenical Alternative new viagra Cheap phentermine 37.5 mg Dicyclomine Hydrocodone withdrawal Hydrocodone description Phentermine message boards Erection viagra Phentermine 90 day Phentermine with free shipping Symptom of vicodin addiction Phentermine diet medication Phentermine prescriptions online physiphen online Non prescription phentermine Codeine Phentermine yellow Chep phentermine Prometrium Azathioprine Viagra dosage Cyclobenzaprine Effexor Prempro Female use viagra Phentermine ky Ssri phentermine heart Natural viagra alternatives Phentermine np with hoodia Online pharmacy duromine viagra international Amiloride Phentermine pillstore Lamivudine Pictures of xanax Amaryl Viagra dangers Zantac Acetaminophen e hydrocodone 2mg xanax Tramadol drug interaction Cheap viagra Accutane Phentermine cod overnight Xanax without prescription Viagra for woman information Mexican pharmacies online+xanax Loracarbef Black market viagra Oxycontin xanax bars perclesept and lortab wha Acetazolamide Shipping phentermine to florida Cheap hydrocodone Symptom tramadol withdrawal Phentermine diet pill Climara Aminophylline Casanthranol Buy ambien online Nalorphine Buy no phentermine prescription Cyber pharmacy viagra Phentermine $70 no prescription Real phentermine Cialis tablet Phentermine ups shipped Ionamin phentermine Killer pain tramadol Dothiepin Aspirin Adipex p phentermine Colon cleanse ambien Viagra in woman Cialis tadalafil How long does phentermine stay in your body Piroxicam Biaxin Insulin Xanax withdrawal effects Fenoterol Mepenzolate Ceftin Methsuximide Meridia order Viagra pill Chlorprothixene Buy generic hydrocodone Online doctors perscriptions xanax steroids Injecting phentermine Hydralazine Buy phentermine cheap Buy phentermine online without a prescription Mirena Does phentermine really work Nutmeg Hydroxyzine Buy Wellbutrin Cholecalciferol Adipex cheap phentermine Counterfeit viagra Bromocriptine Phentermine resident sale virginia Herbal viagra for woman Tramadol pharmacy Milrinone Phentermine 37.5 adipex 37.5 mg Buy prescription tramadol without 100 mg viagra Does it viagra work Cialis versus viagra Trimethaphan Levoxyl Mechlorethamine Suicide xanax Xanax medication Online phentermine pharmacy best cheapest Phentermine a159 Herbal viagra for women Furosemide Niaspan Ethoheptazine Cyclobenzaprine Mail order viagra Bricanyl Oxycontin xanax bars percasettes and lor tabs Lisinopril with viagra Phentermine vs adipex p What does xanax look like Plicamycin Buy cheap fioricet Gatifloxacin Sell viagra online Valium vicodin Buy xanax cod Nicardipine Atenolol viagra Lovastatin Phentermine hcl side effects Buy phentermine online with paypal Where can i buy viagra Spectinomycin Cheap perscription phentermine Zoloft Alternative herbal viagra Soma gallery Isosorbide Viagra cialis levitra dose comparison Extra cheap phentermine Compare generic viagra prices Permethrin Nicoumalone Bupropion Side effects from viagra Methadone and xanax Is there a phentermine shortage Pepcid Drug viagra Dextrothyroxine Valtrex Paris france cheep viagra Mitoxantrone Cheapest phentermine online free shipping Compare ionamin phentermine Mastercard phentermine Fastin phentermine Medication drug mylan online search phentermine diet Fioricet description Tramadol active ingredient Phentermine about withdrawl Aldactone Viagra advertisement Methimazole Cleocin Buy viagra without a prescription Free viagra prescription Viagra compared to levivia Cefepime Viagra wholesale Soma side effects Xanax for sale Womans viagra Gemfibrozil Doxylamine Noroxin Hydrocodone picture Phentermine vs phentrazine Paregoric Phentermine 37.5 in round white tablets no imprint code Pentobarbital Phentermine without rx Online pharmacy phentermine cod Nitroglycerin and viagra Climara Perphenazine Altace Cialis dysfunction erectile levitra viagra Cheapest phentermine pills Compare viagra to cialis No prescription needed phentermine Pyridostigmine Phentermine drug interactions Luvox Delivery generic overnight viagra Meclizine 50mg viagra Xanax picture Flavoxate Next day delivery on phentermine Cope Phentermine success story Tramadol drug Seroquel Xanax xr Glyburide Viagra price online Droperidol Xanax withdrawl symptoms Viagra alternatives Imitrex Triazolam Lethal dose of xanax Beclomethasone Dulcolax Fill viagra prescription Meridia weight loss pill Ambien side effects Olanzapine Felbamate Phentermine prozac 10 min viagra Phentermine in stock ready to ship saturday delivery Phentermine overnight delivery no prescription Buy cod pay phentermine Trandolapril Delivery florida online pharmacy phentermine Vicodin overdose Amsterdam holland viagra Dexamethasone Viagra mexico Prescription phentermine with cod payment Clomipramine Crestor Teniposide Cialis dysfunction erectile levivia viagra Naltrexone Cialis levitra Cephradine Metformin Discount soma Viagra soft tabs Phentermine online Bulk phentermine Cialis dose Ticarcillin Phentermine delivered overnight Lunesta Buy tramadol without prescription Fluorescein Fosinopril Phentermine low price Carbenicillin Cordarone Vidarabine Tramadol medication Diovan Vicodin hp 2 mg xanax Levivia and viagra Phentermine sites that ship cash on delivery Cheap pharmacy viagra Fosamax Elavil Leflunomide Discount phentermine no prescription Soma addiction Phentermine dangers How long does phentermine stay in your system Can woman take viagra Ordering 30mg phentermine Oxycodone vs hydrocodone Ingredient phentermine Motrin Thioguanine Tramadol uses Soma cube 50 mg tramadol Tramadol ingredients Buying phentermine online Generic india viagra Lozol Pemoline Flovent What does phentermine do to your heart Isometheptene Link buy online viagra info domain Adipex diet discount phentermine pill Phentermine 30 mg Book hydrocodone sport Tramadol hcl 50mg Tramadol hydrochloride Phentermine addiction Tramadol dogs Alternative to viagra Tetrabenazine Cheap viagra pills Ramipril Plaquenil Viagra by mail Generic viagra online Ouabain Piperacetazine Fluorouracil Xanax libido Physostigmine Vicodin drug test Purchase cialis Buy Lipitor Probenecid Meridia vs. Phentermine Femara Hydrocodone apap 5 500 Tramadol 200 mg Fioricet with codeine Diclofenac Viagra samples free Phentermine accepts cod Chantix How much weight will you lose on phentermine Zafirlukast Side effects of drug xanax Xanax indications Vicodin Motrin Benazepril Xanax dose Free viagra sample Lexapro and phentermine Phentermine interactions Tramadol heath solutions network Phentermine without doctor's approval Best cialis price Cialis levitra viagra vs vs Fioricet order Phentermine ionamin canada Lowest price phentermine Generic viagra in canada Levivia viagra vs Free shipping with phentermine order Mivial valve prolapse viagra Androgel Viagra supplier Hydrocodone cod only Buy hydrocodone where Ciclopirox Benicar Midodrine Buy Soma Uk cheapest viagra Ethchlorvynol Glyburide Quinine Xanax withdrawel symptoms Woman using viagra Bosch power tools zio lowest viagra Cyclamate Hydrocodone Macrodantin Viagra ingredients Buy cialis without prescription Noctec Us pharmacy phentermine Xanax 2 mg Abacavir Xanax online without prescription Soma drug Buy online phentermine shipping Anisindione Phentermine without a perscription Bentyl Bontril phentermine adipex Viagra for women Soft cialis Sparfloxacin Nitric oxide viagra Phentermine 37 5mg Cheap generic viagra Viagra drug interaction Acetophenazine Quinethazone Topamax Indapamide Phentermine amide Sophia viagra Divalproex Dihydrotachysterol Prozac drug interaction with xanax Klonopin xanax Order viagra visit your doctor online University rochester viagra pfizer Cefuroxime Order soma carisoprodol Online pharmacy prescription viagra Doxycycline Tramadol hc Xanax withdrawals Thiopropazate Phentermine and ocular hypertension Tramadol 100 mg no prescription Drug test tramadol hydochloride Imipramine Isoxsuprine Buy xanax without prescription 100 tramadol Buy phentermine online prescription Ethanol Price viagra viacreme Cheap ambien Cheap phentermine no shipping Cialis compared to viagra Mepindolol Do companies sell phentermine with low dose ingredients Selegiline Cheap generic viagra substitutes Buy phentermine by cod Difference between cialis and viagra Melphalan Tramadol abuse Ceftizoxime Order phentermine by cod Method of payment accepted cod phentermine Does phentermine speed up metabolism Levofloxacin Allopurinol Woman take viagra Tramadol hcl 50 mg tab Cheap viagra in uk Arimidex Haldol Protonix Online pharmacy and phentermine Cialis levivia sales viagra Combivent Buy domain onlinebigsitecitycom phentermine Phenylpropanolamine Liothyronine Buy cialis generic online Soma Indapamide Lovastatin Female viagra uk Glucotrol Phenyltoloxamine Cialis company Order xanax Cheap online phentermine prescription Effects of phentermine Minocycline Nefazodone Ambien eminem Phentermine for sale Propantheline Moexipril Phentermine hcl Buy cheap domain online atspace com xanax Phentermine online pay with mastercard Buy phentermine mastercard Cialis price Phentermine success stories Alavert Adipex phentermine prescription Buy in phentermine uk Tramadol cheap Generic overnight viagra Adipex loss phentermine weight Phentermine hydrochloride Restoril Phentermine result I need to find cheap phentermine delivered to fl Estraderm Cocaine Mesoridazine Phentermine Fluticasone Phentermine message board Estrace Hydrocodone order Xanax side effect Azithromycin Herbal alternative to viagra Buy xanax no prescription Viagra testimony Viagra alternative herbal supplement Ambien coupon cr Bush inauguration speech draft viagra bastard of Chlorambucil Cardizem Order tramadol cod Levaquin Free try viagra Natural supplement for viagra Phentermine tolerance Cialis generic Proguanil Levivia vs viagra Buy pal pay phentermine using Terbinafine Safe internet shopping generic viagraeng Online pharmacy tramadol Cyclizine Levivia viagra Nortriptyline Guaifenesin Cheap tramadol cod free fedex Adipex p phentermine vs Xanax doses How long does xanax stay in your system Phendimetrazine versus phentermine Free shipping cheap phentermine Fioricet medication Paxil with phentermine interactions Buy viagra on line Labetalol Scopolamine Acetohexamide Suboxone Imiquimod Phentermine snorting Viagra erection Tacrolimus Viagra doseage Mark martin viagra photo Cialis vs viagra Canada generic viagra Drug interactions with cocaine and viagra Dapsone Custom hrt phentermine Time released phentermine Tramadol and dosage Xanax next day delivery Enoxaparin Metformin Phentermine hormone Lethal doses of klonopin and xanax Cheap cialis tablets Mercaptopurine Cialis generic viagra Bacitracin Viagra cream for woman Cialis impotence drug eli lilly co Fioricet Ambien rx Amerge Kanamycin Rofecoxib Xanax withdrawl message boards Online pharmacy viagra Pulmonary hypertension and viagra Venlafaxine Robaxin Buy buy domain link online online viagra info viag Adipex diet phentermine pill _achetez le viagra de levivia Buy phentermine in canada Iodoxamate Diet discount phentermine pill Buy com lvivhost online viagra Nizatidine Buy phentermine at amide pharmaceutical Viagra prescription online Wholesale pfizer viagra Aldara Diet medication online phentermine Viagra online order guide Avapro Iodine Phentermine hci Phentermine adipex Viagra usage Buy Tamiflu Anileridine Buy tramadol online Nialamide Viagra results Cialis uk Levitra Fioricet online Online tramadol prescriptions Macrobid Vicodin detox Long term side effects from xanax Hydrocodone Prozac and xanax induced mood disorder Online phentermine sale Phentermine saturday delivery Alendronate Buy cheap online viagra Estrogen Meloxicam Herbal phentermine forum Phentermine adipex diet pill discount Caverta veega generic viagra Piroxicam Meridia diet Lopressor Low cost cialis Methantheline Phentermine raleigh Order viagra buying viagra uk Pfizer xanax information Xanax suicide Bromides Coumarin Order xanax paying cod Atracurium Discount viagra online Cheap tramadol prescriptions online Lovenox Phentermine capsules Ethambutol Amaryl Cheap fioricet Xanax versus prozac Phentermine no rx needed Diet pal pay phentermine pill Sofia viagra Canada cheap viagra Cosopt Buy cialis in canada Gitalin Vinorelbine Erythrityl Dimethindene Ephedrine Actos phentermine aciphex imitrex Viagra prescription Hydrocodone overdose Clarinex Phentermine not working Generic viagra from india Demeclocycline Buy phentermine cod Sulfonamides Secobarbital Pill price viagra Xanax addiction Phentermine c.o.d. Tomorrow Pharmacy phentermine affiliate Viagra generic drug Oseltamivir Cialis levitra sales viagra Phentermine pharmacy cod Colchicine Phentermine versus meridia Purchase soma online Zidovudine Xanax drug interactions Paris cheep phentermine Metharbital Oxacillin Bontril Phentermine meridia xenical review Irbesartan Hydrocodone mexican pharmacy what is tramadol Ipodate Adipex phentermine xenical Get viagra online Ingredient in phentermine Effects from side viagra Lanoxin Elidel Cheapest viagra in uk Epinephrine

Entries Tagged 'merb' ↓

rSpec on Merb!

rSpec on merb.

Have you ever wanted to write a merb application and been turned off by the lack of merb/rSpec documentation? And if you are like me and have completely dumped Test::Unit and shudder at the idea that you might have to return to Test::Unit to reliably test an application written with the super-awesomely, fast(er) framework merb. Yeah. So totally me too!

After a few hours of headaches and digging through the rSpec and Test/Spec source and the sample MrBlog application on the merb site, I have a good platform to develop and test my merb application, reliably and as similar to the rails functionality as I can get it. So, without further ado and more discussion, here’s how I hacked it together:

First off, merb (0.3.7) loads all the plugins in both the dist (soon to be replaced by the directory app in 0.4.0) and the plugins directory at root (MERB_ROOT/plugins and DIST_ROOT/plugins) by requiring all the init.rb files in the directories. To get rSpec to work, you’ll probably need the rspec_on_merb plugin, by (as far as I can tell) Brian Takita. Feel free to put the plugin directory in either place, but for this app, I placed mine in the root. That becomes slightly important later.

I did this by creating the directory and typing

svn co http://svn.devjavu.com/merb/mrblog/trunk/plugins/rspec_on_merb/

.

After you have the plugin, we have to modify it a little. First, create an init.rb file in the plugin’s root (MERB_ROOT/plugins/rspec_on_merb/init.rb) and fill it out with the following:

  dir = File.expand_path(File.dirname(__FILE__))
  require "rubygems"
  require "spec"
  require "#{dir}/spec/spec_helper"

  Dir["#{dir}/lib/*"].each do |file|
    require file unless File.directory?(file)
  end

Basically, this is going to load all the files in the plugin lib directory as well as the spec_helper, which you will definitely want. You can get rid of the files you won’t use, I didn’t use spec_suite at all, but you can use it if it suits you well.

Anyway, back to the process!

After that’s in place, you’ll want to modify the spec_helper in the directory (MERB_ROOT/plugins/spec/spec_helper.rb). The following is my entire spec_helper file. It should work for you right off the bat, but if not, let me know…

  require "rubygems"
  require "spec"
  require "merb"
  require 'active_record'

  class SpecInitializer
    attr_accessor :inst
    module ClassMethods
      def recreate_database_called?
        @recreate_database_called
      end

      def recreate_database_called!
        @recreate_database_called = true
      end

      def turn_off_printing
        # TURN OFF PRINTING
        $stdout = $stderr = File.open("/dev/null","a+");
      end

      def turn_on_printing
        $stdout = $stderr = STDOUT
      end
    end
    extend ClassMethods

    def add_load_paths
      $LOAD_PATH << "#{dir}/dist/app/controllers"
      $LOAD_PATH << "#{dir}/dist/app/helpers"
      $LOAD_PATH << "#{dir}/dist/app/models"
      $LOAD_PATH << "#{dir}/dist/app/views"
    end

    def load_merb
      require "#{dir}/../lib/spec/merb"
    end

    def run
      @inst ||= self.class.new
      @inst.add_load_paths
      @inst.load_merb
      @inst.initialize_database
      @inst.require_project_files
      @inst
    end

    def initialize_database
      conn_options = YAML::load(Erubis::Eruby.new(IO.read("#{DIST_ROOT}/conf/database.yml")).result)

      database = conn_options[:database]
      username = conn_options[:username]
      password = conn_options[:password]

      unless recreate_database_called?
        self.class.turn_off_printing
        case conn_options[:adapter]
        when 'mysql'
          ActiveRecord::Base.connection.drop_database config[:database]
        when /^sqlite/
          FileUtils.rm_f File.join(RAILS_ROOT, config[:database])
        when 'postgresql'
          `dropdb "#{config[:database]}"`
        end
        self.class.turn_on_printing
      end

      # Connect to the database
      ActiveRecord::Base.establish_connection conn_options["#{MERB_ENV}"]

      unless recreate_database_called?
        self.class.turn_off_printing
        mig = []
        Dir["#{DIST_ROOT}/schema/migrations/*"].each do |file|
          require file; mig << File.basename(file, File.extname(file)).gsub(/^(d)+_/, '')
        end
        mig.each {|a| p a.classify.constantize}
        mig.each {|a| a.classify.constantize.send :up}
        self.class.turn_on_printing
      end

      # recreate_database_called! unless recreate_database_called?
    end

    def require_project_files
      require_files_from_directory "controllers"
      require_files_from_directory "helpers"
      require_files_from_directory "models"
      require_files_from_directory "views"
    end

    protected
    def require_files_from_directory(app_dir)
      Dir["#{dir}/dist/app/#{app_dir}/*"].each do |file|
        require file
      end
    end

    def recreate_database_called?
      self.class.recreate_database_called?
    end

    def recreate_database_called!
      self.class.recreate_database_called!
    end

    def dir
      File.dirname(__FILE__)
    end
  end

I won’t go into detail as to what is going on, hopefully (and I suspect if you are using merb, you are somewhat confident with your rails understanding), but I will say that the output is suppressed ’cause we don’t want to see the database output everytime we spec, we just want to know if the spec passed or not. Feel free to add the printing in if you REALLY want to see it.

I added a custom directory in the plugin (MERB_DIR/rspec_on_merb/lib/custom) and that’s where I load the custom classes that I use like multipart.rb that you can find in the plugin’s helper currently. That’s for sure not necessary. I just like clean code bases. Anyway…

Now, I think we are done with the rspec_on_merb plugin directory. Let’s move to the test directory and get the specs going!

Make the following directory structure in your merb app (You can change this, of course, just pay attention to the require paths… if you change the directory, then you may have to change some of the require paths).
MERB_DIR/

test/
fixtures/
spec/
models/
controllers/

Okay, so now we are going to add all things you need to get the rSpec’s going green. In your spec directory (MERB_DIR/test/spec), add a file and call it spec_helper.rb (sound familiar? should).

The code I used for the spec_helper.rb is as follows

  dir = File.expand_path(File.dirname(__FILE__))
  $TESTING = true

  $stdout = $stderr = File.open("/dev/null","a+")
  require "rubygems"
  require "spec"

  require 'merb/merb_server'

  dir = File.dirname(__FILE__)
  Merb::Server.instance_eval {@@merb_raw_opts = []}
  Merb::Server.merb_config
  Merb::Server.config[:merb_root] = File.expand_path("#{dir}/../..")
  Merb::Server.config[:dist_root] = File.expand_path("#{dir}/../../dist")
  Merb::Server.config[:environment] = 'test'

  require "merb"
  require "active_record"
  ActiveRecord::Base.verification_timeout = 14400

  require "#{DIST_ROOT}/conf/merb_init"

  require DIST_ROOT+"/conf/router.rb"
  $LOAD_PATH << DIST_ROOT+"/app/models/"
  $LOAD_PATH << DIST_ROOT+"/app/controllers/"
  $LOAD_PATH << DIST_ROOT+"/app/helpers/"
  Dir[DIST_ROOT+"/plugins/*/lib"].each { |m| $LOAD_PATH <<  m }
  Dir[MERB_ROOT+"/plugins/*/lib"].each { |m| $LOAD_PATH << m }

  require "spec/merb"

  # Custom requires
  require "#{dir}/login_service_helper"
  $stdout = STDOUT

  Spec::DSL::Behaviour.prepend_before(:each) { @si = SpecInitializer.new.run unless @no_refresh }

The important part of the spec_helper is the last line. That’s where you get the nice behavior that we are all used to from Rails. That’ll clear you database every test you run. Ugly, for sure.

In case you were wondering, the output (again) is surpressed in this block ’cause there are some print statements we don’t care about in there.

Okay, some more…

You definitely need a rake task. The one I use is as follows:

  desc 'run specs'
  task :specs  => [:merb_init] do

    Spec::Rake::SpecTask.new('specs') do |t|
      t.spec_opts = ["--format", "specdoc"]
      t.libs = ['lib', 'server/lib' ]
      t.spec_files = FileList['test/spec/**/*_spec.rb']
    end
  end

I can’t remember (I’ve been hacking at this for a while) if the :merb_init task is apart of the Rakefile merb copies for you, so here is the one from my Rakefile

  desc "load merb_init.rb"
  task :merb_init do
    require File.dirname(__FILE__)+'/dist/conf/merb_init.rb'
  end

And I think you should be good to go…

This last tidbit bothered me for about an hour, so rather than have you dig around for it… if you are not familiar with the rSpec codebase, rSpec loads the specs and their inheritance tree based on the directory that your spec is located in. Unless you include the :behaviour_type => :controller on your controller specs, then you’ll get some pretty funky results. Like so:

  describe Index, "controller", :behaviour_type => :controller do
  end

It’s probably good practice to do that for all your describe blocks, but the model code worked for me.

Anyway, let me know if this works for you…

UPDATE
I had to manipulate some of the plugin to allow for RESTful testing:

in the controller behavior file: (MERB_DIR/plugins/rspec_on_merb/lib/spec/merb/dsl/behaviour/controller.rb) I changed the post method to look like (only the change is posted, everything else should stay the same):

          method = opts.delete(:request_method) || 'POST'
          body, head = m.prepare_query(opts)
          request = Spec::Merb::Fakes::FakeRequest.new({:request_uri => path, :path_info => path.sub(/?.*$/,'')}, method)
          request['REQUEST_METHOD'] = method
          request['CONTENT_TYPE'] = head
          request['CONTENT_LENGTH'] = body.length
          request.post_body = body


I added the request_method to the parameters so you can “fake” the method in your test, like such:

  def do_put
    @response, @controller = post "/users/1.xml", @params.merge({:request_method => "DELETE"})
  end

I’ll continue to update my changes when/if I make ‘em!