diff --git a/.gitignore b/.gitignore index 2288186..5c9c325 100644 --- a/.gitignore +++ b/.gitignore @@ -26,17 +26,17 @@ pkg # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line) # # For MacOS: -# -#.DS_Store -# + +.DS_Store + # For TextMate -#*.tmproj -#tmtags -# +*.tmproj +tmtags + # For emacs: -#*~ -#\#* -#.\#* -# +*~ +\#* +.\#* + # For vim: -#*.swp +*.swp diff --git a/Gemfile b/Gemfile index bdb0a5f..c300cdc 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,9 @@ source "http://rubygems.org" # Add dependencies to develop your gem here. # Include everything needed to run rake, tests, features, etc. group :development do - gem "shoulda", ">= 0" + gem "mongoid", "2.0.0.rc.7" + gem 'database_cleaner', '~> 0.6.0' + gem 'rspec', '~> 2.5.0' gem "bundler", "~> 1.0.0" gem "jeweler", "~> 1.5.2" - gem "rcov", ">= 0" end diff --git a/Gemfile.lock b/Gemfile.lock index 07df601..ded064f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,46 @@ GEM remote: http://rubygems.org/ specs: + activemodel (3.0.5) + activesupport (= 3.0.5) + builder (~> 2.1.2) + i18n (~> 0.4) + activesupport (3.0.5) + bson (1.2.4) + builder (2.1.2) + database_cleaner (0.6.6) + diff-lcs (1.1.2) git (1.2.5) + i18n (0.5.0) jeweler (1.5.2) bundler (~> 1.0.0) git (>= 1.2.5) rake + mongo (1.2.4) + bson (>= 1.2.4) + mongoid (2.0.0.rc.7) + activemodel (~> 3.0) + mongo (~> 1.2) + tzinfo (~> 0.3.22) + will_paginate (~> 3.0.pre) rake (0.8.7) - rcov (0.9.9) - shoulda (2.11.3) + rspec (2.5.0) + rspec-core (~> 2.5.0) + rspec-expectations (~> 2.5.0) + rspec-mocks (~> 2.5.0) + rspec-core (2.5.1) + rspec-expectations (2.5.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.5.0) + tzinfo (0.3.24) + will_paginate (3.0.pre2) PLATFORMS ruby DEPENDENCIES bundler (~> 1.0.0) + database_cleaner (~> 0.6.0) jeweler (~> 1.5.2) - rcov - shoulda + mongoid (= 2.0.0.rc.7) + rspec (~> 2.5.0) diff --git a/Rakefile b/Rakefile index 5c8d00a..021d6b8 100644 --- a/Rakefile +++ b/Rakefile @@ -8,6 +8,7 @@ rescue Bundler::BundlerError => e exit e.status_code end require 'rake' +require 'rspec/core/rake_task' require 'jeweler' Jeweler::Tasks.new do |gem| @@ -26,28 +27,10 @@ Jeweler::Tasks.new do |gem| end Jeweler::RubygemsDotOrgTasks.new -require 'rake/testtask' -Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true -end -require 'rcov/rcovtask' -Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true +desc "Run all tests" +RSpec::Core::RakeTask.new(:spec) do |spec| + spec.pattern = "spec/**/*_spec.rb" end -task :default => :test - -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "mongoid_fulltext #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end +task :default => :spec diff --git a/spec/models/artist.rb b/spec/models/artist.rb new file mode 100644 index 0000000..f9c1d5c --- /dev/null +++ b/spec/models/artist.rb @@ -0,0 +1,7 @@ +class Artist + include Mongoid::Document + include Mongoid::FullTextSearch + + field :title + +end diff --git a/spec/models/artwork.rb b/spec/models/artwork.rb new file mode 100644 index 0000000..d47ecc8 --- /dev/null +++ b/spec/models/artwork.rb @@ -0,0 +1,7 @@ +class Artwork + include Mongoid::Document + include Mongoid::FullTextSearch + + field :title + +end diff --git a/spec/mongoid/fulltext_spec.rb b/spec/mongoid/fulltext_spec.rb new file mode 100644 index 0000000..4dd4bb5 --- /dev/null +++ b/spec/mongoid/fulltext_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +module Mongoid + describe FullTextSearch do + + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..26df21b --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,20 @@ +require 'rubygems' +require 'bundler/setup' +require 'rspec' + +require 'mongoid' +require 'database_cleaner' + +Mongoid.configure do |config| + name = "mongoid_fulltext_test" + config.master = Mongo::Connection.new.db(name) +end + +require File.expand_path("../../lib/mongoid_fulltext", __FILE__) +Dir["#{File.dirname(__FILE__)}/models/*.rb"].each { |f| require f } + +Rspec.configure do |c| + c.before(:all) { DatabaseCleaner.strategy = :truncation } + c.before(:each) { DatabaseCleaner.clean } +end + diff --git a/test/helper.rb b/test/helper.rb deleted file mode 100644 index 495a561..0000000 --- a/test/helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rubygems' -require 'bundler' -begin - Bundler.setup(:default, :development) -rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts "Run `bundle install` to install missing gems" - exit e.status_code -end -require 'test/unit' -require 'shoulda' - -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -$LOAD_PATH.unshift(File.dirname(__FILE__)) -require 'mongoid_fulltext' - -class Test::Unit::TestCase -end diff --git a/test/test_mongoid_fulltext.rb b/test/test_mongoid_fulltext.rb deleted file mode 100644 index 7ff7e25..0000000 --- a/test/test_mongoid_fulltext.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'helper' - -class TestMongoidFulltext < Test::Unit::TestCase - should "probably rename this file and start testing for real" do - flunk "hey buddy, you should probably rename this file and start testing for real" - end -end