Permalink
Browse files

Allowing specs to run outside of a Rails project, had to change one u…

…se of a rspec-rails matcher as rspec-rails requires much more of Rails to be present before it can load properly.

Signed-off-by: Michael Bleigh <michael@intridea.com>
  • Loading branch information...
jqr authored and Michael Bleigh committed Mar 26, 2009
1 parent 08b9d7d commit a9ebf3c94608f32c7a500db931d3fcd0665ab2ad
Showing with 37 additions and 8 deletions.
  1. +2 −1 .gitignore
  2. +8 −2 README
  3. +7 −0 Rakefile
  4. +4 −2 spec/acts_as_taggable_on/tag_spec.rb
  5. +16 −3 spec/spec_helper.rb
View
@@ -1 +1,2 @@
-*.log
+*.log
+test.sqlite3
View
10 README
@@ -55,11 +55,17 @@ Post Installation (Rails)
Testing
=======
-Acts As Taggable On uses RSpec for its test coverage. If you already have RSpec on your
-application, the specs will run while using:
+Acts As Taggable On uses RSpec for its test coverage. Inside the plugin
+directory, you can run the specs with:
+
+rake spec
+
+
+If you already have RSpec on your application, the specs will run while using:
rake spec:plugins
+
Example
=======
View
@@ -0,0 +1,7 @@
+require 'spec/rake/spectask'
+
+desc 'Default: run specs'
+task :default => :spec
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList["spec/**/*_spec.rb"]
+end
@@ -7,9 +7,11 @@
end
it "should require a name" do
- @tag.should have(1).errors_on(:name)
+ @tag.valid?
+ @tag.errors.on(:name).should == "can't be blank"
@tag.name = "something"
- @tag.should have(0).errors_on(:name)
+ @tag.valid?
+ @tag.errors.on(:name).should be_nil
end
it "should equal a tag with the same name" do
View
@@ -1,14 +1,27 @@
-require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
+# require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
+require 'rubygems'
+require 'active_support'
+require 'active_record'
+require 'spec'
module Spec::Example::ExampleGroupMethods
alias :context :describe
end
-plugin_spec_dir = File.dirname(__FILE__)
-ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
+TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
+
+File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
+ActiveRecord::Base.establish_connection(
+ "adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
+)
+
+RAILS_DEFAULT_LOGGER = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
load(File.dirname(__FILE__) + '/schema.rb')
+$: << File.join(File.dirname(__FILE__), '..', 'lib')
+require File.join(File.dirname(__FILE__), '..', 'init')
+
class TaggableModel < ActiveRecord::Base
acts_as_taggable_on :tags, :languages
acts_as_taggable_on :skills

0 comments on commit a9ebf3c

Please sign in to comment.