Skip to content

Commit

Permalink
Add support for both Mongoid 2.x and 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bowsersenior committed Sep 9, 2012
1 parent a666bf2 commit 7e637a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ rvm:
- 1.9.3
- jruby
before_script:
- sudo apt-get install graphviz
- sudo apt-get install graphviz mongodb
19 changes: 14 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require 'test/unit'
require 'active_record'

require 'workflow_on_mongoid'

class << Test::Unit::TestCase
Expand Down Expand Up @@ -44,14 +45,22 @@ def default_test
require 'mongoid'
class MongoidTestCase < Test::Unit::TestCase
Mongoid.configure do |config|
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("workflow_on_mongoid")
if config.respond_to?(:connect_to) # 3.x
config.connect_to("workflow_on_mongoid")
else # 2.x
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("workflow_on_momgoid")
end
end

def teardown
Mongoid.master.collections.select do |collection|
collection.name !~ /system/
end.each(&:drop)
if Mongoid.respond_to?(:purge!) # 3.x
Mongoid.purge!
else # 2.x
Mongoid.master.collections.select do |collection|
collection.name !~ /system/
end.each(&:drop)
end
end

def default_test; end
end
2 changes: 1 addition & 1 deletion workflow_on_mongoid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.description = "Lets you use the Workflow gem with your Mongoid documents to add state machine functionality."

s.add_dependency "workflow", '~>0.8'
s.add_dependency "mongoid", '>=2.0.0.rc.1'
s.add_dependency "mongoid", '>=2.0.0'

s.add_development_dependency "rake"
s.add_development_dependency "rspec", '>=2.6.0'
Expand Down

0 comments on commit 7e637a8

Please sign in to comment.