added some specs, removed neo4j from multiple_dbs feature
This commit is contained in:
parent
8ab0be7c63
commit
17f82853ff
|
@ -14,3 +14,4 @@ before_script:
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis-server
|
||||||
- mongodb
|
- mongodb
|
||||||
|
- neo4j
|
|
@ -1,11 +1,3 @@
|
||||||
Given /^I have setup database cleaner to clean multiple databases using neo4j$/ do
|
|
||||||
#DatabaseCleaner
|
|
||||||
# require "#{File.dirname(__FILE__)}/../../../lib/neo4j_models"
|
|
||||||
#
|
|
||||||
# DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7475'} ]
|
|
||||||
# DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7476'} ]
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I create a widget using neo4j$/ do
|
When /^I create a widget using neo4j$/ do
|
||||||
Neo4jWidget.create!
|
Neo4jWidget.create!
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,9 +47,6 @@ if orm && strategy
|
||||||
when :active_record
|
when :active_record
|
||||||
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseOne} ].strategy = strategy.to_sym
|
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseOne} ].strategy = strategy.to_sym
|
||||||
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseTwo} ].strategy = strategy.to_sym
|
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseTwo} ].strategy = strategy.to_sym
|
||||||
when :neo4j
|
|
||||||
DatabaseCleaner[:neo4j, {:connection => {:type => :server_db, :path => 'http://localhost:7475/'}} ].strategy = strategy.to_sym
|
|
||||||
DatabaseCleaner[:neo4j, {:connection => {:type => :server_db, :path => 'http://localhost:7476/'}} ].strategy = strategy.to_sym
|
|
||||||
else
|
else
|
||||||
DatabaseCleaner[ orm_sym, {:connection => :one} ].strategy = strategy.to_sym
|
DatabaseCleaner[ orm_sym, {:connection => :one} ].strategy = strategy.to_sym
|
||||||
DatabaseCleaner[ orm_sym, {:connection => :two} ].strategy = strategy.to_sym
|
DatabaseCleaner[ orm_sym, {:connection => :two} ].strategy = strategy.to_sym
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'neo4j-core'
|
require 'neo4j-core'
|
||||||
|
DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7474'}]
|
||||||
|
|
||||||
class Neo4jWidget < Neo4j::Node
|
class Neo4jWidget < Neo4j::Node
|
||||||
def self.create!(*args)
|
def self.create!(*args)
|
||||||
|
@ -14,4 +15,4 @@ class Neo4jWidgetUsingDatabaseOne < Neo4jWidget
|
||||||
end
|
end
|
||||||
|
|
||||||
class Neo4jWidgetUsingDatabaseTwo < Neo4jWidget
|
class Neo4jWidgetUsingDatabaseTwo < Neo4jWidget
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,3 @@ Feature: multiple database cleaning
|
||||||
| MongoMapper | truncation |
|
| MongoMapper | truncation |
|
||||||
| DataMapper | transaction |
|
| DataMapper | transaction |
|
||||||
| ActiveRecord | transaction |
|
| ActiveRecord | transaction |
|
||||||
| Neo4j | deletion |
|
|
||||||
| Neo4j | truncation |
|
|
||||||
| Neo4j | transaction |
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ module DatabaseCleaner
|
||||||
private
|
private
|
||||||
|
|
||||||
def default_db
|
def default_db
|
||||||
{type: default_db_type, path: default_db_path}
|
{:type => default_db_type, :path => default_db_path}
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_db_type
|
def default_db_type
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'database_cleaner/data_mapper/transaction'
|
||||||
require 'database_cleaner/mongo_mapper/truncation'
|
require 'database_cleaner/mongo_mapper/truncation'
|
||||||
require 'database_cleaner/mongoid/truncation'
|
require 'database_cleaner/mongoid/truncation'
|
||||||
require 'database_cleaner/couch_potato/truncation'
|
require 'database_cleaner/couch_potato/truncation'
|
||||||
|
require 'database_cleaner/neo4j/transaction'
|
||||||
|
|
||||||
module DatabaseCleaner
|
module DatabaseCleaner
|
||||||
describe Base do
|
describe Base do
|
||||||
|
@ -21,6 +22,7 @@ module DatabaseCleaner
|
||||||
Temp_MP = ::Moped if defined?(::Moped) and not defined?(Temp_MP)
|
Temp_MP = ::Moped if defined?(::Moped) and not defined?(Temp_MP)
|
||||||
Temp_RS = ::Redis if defined?(::Redis) and not defined?(Temp_RS)
|
Temp_RS = ::Redis if defined?(::Redis) and not defined?(Temp_RS)
|
||||||
Temp_OH = ::Ohm if defined?(::Ohm) and not defined?(Temp_OH)
|
Temp_OH = ::Ohm if defined?(::Ohm) and not defined?(Temp_OH)
|
||||||
|
Temp_NJ = ::Neo4j if defined?(::Neo4j) and not defined?(Temp_NJ)
|
||||||
end
|
end
|
||||||
|
|
||||||
#Remove all ORM mocks and restore from cache
|
#Remove all ORM mocks and restore from cache
|
||||||
|
@ -34,6 +36,7 @@ module DatabaseCleaner
|
||||||
Object.send(:remove_const, 'Moped') if defined?(::Moped)
|
Object.send(:remove_const, 'Moped') if defined?(::Moped)
|
||||||
Object.send(:remove_const, 'Ohm') if defined?(::Ohm)
|
Object.send(:remove_const, 'Ohm') if defined?(::Ohm)
|
||||||
Object.send(:remove_const, 'Redis') if defined?(::Redis)
|
Object.send(:remove_const, 'Redis') if defined?(::Redis)
|
||||||
|
Object.send(:remove_const, 'Neo4j') if defined?(::Neo4j)
|
||||||
|
|
||||||
|
|
||||||
# Restore ORMs
|
# Restore ORMs
|
||||||
|
@ -46,6 +49,7 @@ module DatabaseCleaner
|
||||||
::Moped = Temp_MP if defined? Temp_MP
|
::Moped = Temp_MP if defined? Temp_MP
|
||||||
::Ohm = Temp_OH if defined? Temp_OH
|
::Ohm = Temp_OH if defined? Temp_OH
|
||||||
::Redis = Temp_RS if defined? Temp_RS
|
::Redis = Temp_RS if defined? Temp_RS
|
||||||
|
::Neo4j = Temp_NJ if defined? Temp_NJ
|
||||||
end
|
end
|
||||||
|
|
||||||
#reset the orm mocks
|
#reset the orm mocks
|
||||||
|
@ -59,6 +63,7 @@ module DatabaseCleaner
|
||||||
Object.send(:remove_const, 'Moped') if defined?(::Moped)
|
Object.send(:remove_const, 'Moped') if defined?(::Moped)
|
||||||
Object.send(:remove_const, 'Ohm') if defined?(::Ohm)
|
Object.send(:remove_const, 'Ohm') if defined?(::Ohm)
|
||||||
Object.send(:remove_const, 'Redis') if defined?(::Redis)
|
Object.send(:remove_const, 'Redis') if defined?(::Redis)
|
||||||
|
Object.send(:remove_const, 'Neo4j') if defined?(::Neo4j)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:cleaner) { DatabaseCleaner::Base.new :autodetect }
|
let(:cleaner) { DatabaseCleaner::Base.new :autodetect }
|
||||||
|
@ -77,6 +82,7 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :active_record
|
cleaner.orm.should eq :active_record
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
|
@ -91,6 +97,7 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :data_mapper
|
cleaner.orm.should eq :data_mapper
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
|
@ -104,6 +111,7 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :mongo_mapper
|
cleaner.orm.should eq :mongo_mapper
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
|
@ -116,6 +124,7 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :mongoid
|
cleaner.orm.should eq :mongoid
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
|
@ -127,6 +136,7 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :couch_potato
|
cleaner.orm.should eq :couch_potato
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
|
@ -137,27 +147,37 @@ module DatabaseCleaner
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :sequel
|
cleaner.orm.should eq :sequel
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'detects Ohm seventh' do
|
it 'detects Ohm seventh' do
|
||||||
Object.const_set('Ohm', 'Ohm mock')
|
Object.const_set('Ohm', 'Ohm mock')
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :ohm
|
cleaner.orm.should eq :ohm
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'detects Redis last' do
|
it 'detects Redis eighth' do
|
||||||
Object.const_set('Redis', 'Redis mock')
|
Object.const_set('Redis', 'Redis mock')
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :redis
|
cleaner.orm.should eq :redis
|
||||||
cleaner.should be_auto_detected
|
cleaner.should be_auto_detected
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'detects Moped seventh' do
|
it 'detects Neo4j ninth' do
|
||||||
|
Object.const_set('Neo4j', 'Neo4j mock')
|
||||||
|
|
||||||
|
cleaner.orm.should eq :neo4j
|
||||||
|
cleaner.should be_auto_detected
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'detects Moped seventh' do #FIXME
|
||||||
Object.const_set('Moped', 'Moped mock')
|
Object.const_set('Moped', 'Moped mock')
|
||||||
|
|
||||||
cleaner.orm.should eq :moped
|
cleaner.orm.should eq :moped
|
||||||
|
@ -573,6 +593,11 @@ module DatabaseCleaner
|
||||||
cleaner = DatabaseCleaner::Base.new(:redis)
|
cleaner = DatabaseCleaner::Base.new(:redis)
|
||||||
cleaner.strategy.should be_instance_of DatabaseCleaner::Redis::Truncation
|
cleaner.strategy.should be_instance_of DatabaseCleaner::Redis::Truncation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'sets strategy to :transaction for Neo4j' do
|
||||||
|
cleaner = DatabaseCleaner::Base.new(:neo4j)
|
||||||
|
cleaner.strategy.should be_instance_of DatabaseCleaner::Neo4j::Transaction
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -336,5 +336,10 @@ describe ::DatabaseCleaner do
|
||||||
subject.orm_module(:couch_potato).should eq DatabaseCleaner::CouchPotato
|
subject.orm_module(:couch_potato).should eq DatabaseCleaner::CouchPotato
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return DatabaseCleaner::Neo4j for :neo4j" do
|
||||||
|
::DatabaseCleaner::Neo4j = double("nj module") unless defined? ::DatabaseCleaner::Neo4j
|
||||||
|
subject.orm_module(:neo4j).should eq DatabaseCleaner::Neo4j
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'database_cleaner/neo4j/base'
|
||||||
|
require 'database_cleaner/shared_strategy'
|
||||||
|
|
||||||
|
module DatabaseCleaner
|
||||||
|
describe Neo4j do
|
||||||
|
it { should respond_to(:available_strategies) }
|
||||||
|
end
|
||||||
|
|
||||||
|
module Neo4j
|
||||||
|
class ExampleStrategy
|
||||||
|
include ::DatabaseCleaner::Neo4j::Base
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ExampleStrategy do
|
||||||
|
|
||||||
|
it_should_behave_like "a generic strategy"
|
||||||
|
it { should respond_to(:db) }
|
||||||
|
it { should respond_to(:db=) }
|
||||||
|
|
||||||
|
it "should store my describe db" do
|
||||||
|
db_conf = {:connection => {:type => :server_db, :path => 'http://localhost:7474'}}
|
||||||
|
subject.db = db_conf
|
||||||
|
subject.db.should eq db_conf
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should default to nil" do
|
||||||
|
subject.db.should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return default configuration" do
|
||||||
|
subject.database.should eq(:type => :server_db, :path => 'http://localhost:7475/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,26 @@
|
||||||
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||||
|
require 'neo4j-core'
|
||||||
|
require 'database_cleaner/neo4j/transaction'
|
||||||
|
|
||||||
|
|
||||||
|
module DatabaseCleaner
|
||||||
|
module Neo4j
|
||||||
|
|
||||||
|
describe Transaction do
|
||||||
|
before(:all) do
|
||||||
|
DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7474'}]
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like "a generic strategy"
|
||||||
|
it_should_behave_like "a generic transaction strategy"
|
||||||
|
|
||||||
|
describe "start" do
|
||||||
|
it "should start a transaction"
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "clean" do
|
||||||
|
it "should finish a transaction"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue