Skip to content

Commit

Permalink
Spec for base.rb...rcov looks good, calling it a day on specs
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Apr 26, 2009
1 parent c6703c2 commit b65033d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
.DS_Store
*.gem
coverage
tmp

spec/db/log/*.log
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -42,6 +42,7 @@ end

desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.rcov = true
t.spec_opts = ["--format", "specdoc", "--colour"]
t.spec_files = FileList["spec/**/*_spec.rb"]
end
24 changes: 24 additions & 0 deletions spec/acts_as_archive/base_spec.rb
@@ -0,0 +1,24 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe ActsAsArchive::Base do

before(:all) do
establish_test_db
end

describe 'acts_as_archive' do

it "should add self.acts_as_archive? to the model" do
Article.respond_to?(:acts_as_archive?).should == true
end

it "should add self.archive_indexes to the model" do
Article.respond_to?(:archive_indexes).should == true
Article.archive_indexes.should == [ 'id', 'deleted_at' ]
end

it "should add Archive class to the model" do
defined?(Article::Archive).should == "constant"
end
end
end
9 changes: 4 additions & 5 deletions spec/spec_helper.rb
@@ -1,5 +1,5 @@
$TESTING=true
SPEC = File.dirname(__FILE__)
SPEC = File.expand_path(File.dirname(__FILE__))

require 'rubygems'
require 'active_record'
Expand Down Expand Up @@ -72,17 +72,16 @@ def establish_test_db
logger_file.sync = true
@logger = Logger.new(logger_file)
ActiveRecord::Base.logger = @logger
# Drop articles and archived_articles
# The database should have only a simple articles table
connection.execute("DROP TABLE IF EXISTS articles")
connection.execute("DROP TABLE IF EXISTS archived_articles")
connection.execute("DROP TABLE IF EXISTS schema_migrations")
# Create articles table
connection.create_table(:articles) do |t|
t.string :title
t.string :body
end
# Load model
require "#{SPEC}/db/models/article"
# Load the model
load "#{SPEC}/db/models/article.rb"
end

def indexes
Expand Down

0 comments on commit b65033d

Please sign in to comment.