Permalink
Browse files

Added spec for Model#new?

  • Loading branch information...
1 parent 177970a commit e0c44b8b8f2ee987a697100478c25cb60844fb57 Lori Holden committed Dec 22, 2008
Showing with 52 additions and 0 deletions.
  1. +22 −0 merb_sequel/spec/sequel_ext_spec.rb
  2. +30 −0 merb_sequel/spec/spec_helper.rb
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + "/spec_helper"
+
+describe 'Sequel::Model#new?' do
+ before(:each) do
+ spec_model_up
+ end
+
+ after(:each) do
+ spec_model_down
+ end
+
+ it "is defined" do
+ SpecModel.instance_methods.should include 'new?'
+ end
+
+ it "Returns true or new model" do
+ a = SpecModel.new
+ a.should be_new
+ a.save
+ a.should_not be_new
+ end
+end
@@ -2,4 +2,34 @@
require 'rubygems'
require 'spec'
require 'merb-core'
+require 'merb-core/test'
+require 'merb-core/test/helpers'
require File.join( File.dirname(__FILE__), "..", "lib", 'merb_sequel')
+
+require 'sequel'
+DB = Sequel.sqlite
+
+class CreateSpecModel < Sequel::Migration
+ def up
+ create_table! :spec_models do
+ primary_key :id
+ text :name
+ end
+ end
+
+ def down
+ drop_table :spec_models
+ end
+end
+
+def spec_model_up
+ CreateSpecModel.apply(DB, :up)
+end
+def spec_model_down
+ CreateSpecModel.apply(DB, :up)
+end
+
+class SpecModel < Sequel::Model
+ set_dataset DB[:spec_models]
+
+end

0 comments on commit e0c44b8

Please sign in to comment.