From 251b8803dce2f7784ddd69a342ae9ac9f1d7ff4c Mon Sep 17 00:00:00 2001 From: Lori Holden Date: Mon, 22 Dec 2008 12:01:11 -0800 Subject: [PATCH] General cleanup. Startup Merb environment for specs --- merb_sequel/spec/merb_sequel_session_spec.rb | 18 +--------- merb_sequel/spec/sequel_ext_spec.rb | 2 +- merb_sequel/spec/spec_helper.rb | 36 +++++++++++++++----- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/merb_sequel/spec/merb_sequel_session_spec.rb b/merb_sequel/spec/merb_sequel_session_spec.rb index ee7998e..14a8c8e 100644 --- a/merb_sequel/spec/merb_sequel_session_spec.rb +++ b/merb_sequel/spec/merb_sequel_session_spec.rb @@ -1,20 +1,4 @@ -$:.push File.join(File.dirname(__FILE__), '..', 'lib') -require 'rubygems' -require 'merb-core' -require 'merb-core/test' -require 'merb-core/test/helpers' - -Merb::BootLoader.before_app_loads do - require 'sequel' - DB = Sequel.sqlite - require "merb/session/sequel_session" -end - -Merb.start :environment => 'test', :adapter => 'runner', :session_store => 'sequel' - -Spec::Runner.configure do |config| - config.include Merb::Test::RequestHelper -end +require File.dirname(__FILE__) + "/spec_helper" # # Load up the shared specs from merb-core # if (gem_spec = Gem.source_index.search(Gem::Dependency.new('merb-core', '>=0.9.6')).last) && diff --git a/merb_sequel/spec/sequel_ext_spec.rb b/merb_sequel/spec/sequel_ext_spec.rb index 1e5d7d7..36c58c3 100644 --- a/merb_sequel/spec/sequel_ext_spec.rb +++ b/merb_sequel/spec/sequel_ext_spec.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + "/spec_helper" describe 'Sequel::Model#new_record?' do - it_should_behave_like "having a spec model" + it_should_behave_like "it has a SpecModel" it "is defined" do SpecModel.instance_methods.should include 'new_record?' diff --git a/merb_sequel/spec/spec_helper.rb b/merb_sequel/spec/spec_helper.rb index 62449cc..ed16e7c 100644 --- a/merb_sequel/spec/spec_helper.rb +++ b/merb_sequel/spec/spec_helper.rb @@ -1,13 +1,34 @@ $:.push File.join(File.dirname(__FILE__), "..", "lib") require 'rubygems' require 'spec' +require 'sequel' require 'merb-core' require 'merb-core/test' require 'merb-core/test/helpers' +require "merb/session/sequel_session" require File.join( File.dirname(__FILE__), "..", "lib", 'merb_sequel') -require 'sequel' -DB = Sequel.sqlite +module Merb + module Orms + module Sequel + class << self + def connect + ::Sequel.connect(:adapter => 'sqlite') + end + end + end + end +end + +Merb.start :environment => 'test', :adapter => 'runner', :session_store => 'sequel' + +Spec::Runner.configure do |config| + config.include Merb::Test::RequestHelper +end + + +class SpecModel < Sequel::Model +end class CreateSpecModel < Sequel::Migration def up @@ -22,16 +43,15 @@ def down end end -describe "having a spec model", :shared => true do +describe "it has a SpecModel", :shared => true do before(:each) do - CreateSpecModel.apply(DB, :up) + CreateSpecModel.apply(SpecModel.db, :up) end after(:each) do - CreateSpecModel.apply(DB, :down) + CreateSpecModel.apply(SpecModel.db, :down) end end -class SpecModel < Sequel::Model - set_dataset DB[:spec_models] -end + +