mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
strip down cucumber scenarios to just use the two most popular adapter gems, and reenable to validate the end-to-end UX.
This commit is contained in:
parent
592f2e23ef
commit
12abeae48b
26 changed files with 33 additions and 711 deletions
|
@ -1,4 +1,6 @@
|
|||
language: ruby
|
||||
services:
|
||||
- redis
|
||||
rvm:
|
||||
- 2.5
|
||||
- 2.6
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -3,3 +3,5 @@ source "https://rubygems.org"
|
|||
gemspec name: "database_cleaner-core"
|
||||
|
||||
gem "byebug"
|
||||
gem "database_cleaner-active_record", git: "https://github.com/DatabaseCleaner/database_cleaner-active_record"
|
||||
gem "database_cleaner-redis", git: "https://github.com/DatabaseCleaner/database_cleaner-redis"
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -1,7 +1,9 @@
|
|||
# testing
|
||||
require "rspec/core/rake_task"
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
task :default => :spec
|
||||
require "cucumber/rake/task"
|
||||
Cucumber::Rake::Task.new(:features)
|
||||
task :default => [:spec, :features]
|
||||
|
||||
# releasing
|
||||
require "rake/clean"
|
||||
|
|
|
@ -25,5 +25,10 @@ Gem::Specification.new do |spec|
|
|||
spec.add_development_dependency 'guard-rspec'
|
||||
spec.add_development_dependency "listen"
|
||||
spec.add_development_dependency "rspec"
|
||||
|
||||
spec.add_development_dependency "cucumber"
|
||||
spec.add_development_dependency "activesupport"
|
||||
spec.add_development_dependency "database_cleaner-active_record"
|
||||
spec.add_development_dependency "sqlite3"
|
||||
spec.add_development_dependency "database_cleaner-redis"
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Feature: example
|
||||
In order to test DataBase Cleaner
|
||||
In order to test DatabaseCleaner
|
||||
Here are some scenarios that rely on the DB being clean!
|
||||
|
||||
Scenario: dirty the db
|
||||
|
|
|
@ -2,8 +2,8 @@ Given /^I have setup database cleaner to clean multiple databases using activere
|
|||
#DatabaseCleaner
|
||||
# require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
|
||||
#
|
||||
# DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
|
||||
# DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
|
||||
# DatabaseCleaner[:active_record, connection: :one].strategy = :truncation
|
||||
# DatabaseCleaner[:active_record, connection: :two].strategy = :truncation
|
||||
end
|
||||
|
||||
When /^I create a widget using activerecord$/ do
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
Given /^I have setup database cleaner to clean multiple databases using couchpotato$/ do
|
||||
#DatabaseCleaner
|
||||
# require "#{File.dirname(__FILE__)}/../../../lib/couchpotato_models"
|
||||
#
|
||||
# DatabaseCleaner[:couchpotato, {:connection => :one} ].strategy = :truncation
|
||||
# DatabaseCleaner[:couchpotato, {:connection => :two} ].strategy = :truncation
|
||||
end
|
||||
|
||||
When /^I create a widget using couchpotato$/ do
|
||||
CouchPotatoWidget.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using couchpotato$/ do |widget_count|
|
||||
expect(CouchPotatoWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using couchpotato$/ do
|
||||
CouchPotatoWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using couchpotato$/ do
|
||||
CouchPotatoWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using couchpotato$/ do |widget_count|
|
||||
expect(CouchPotatoWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using couchpotato$/ do |widget_count|
|
||||
expect(CouchPotatoWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
Given /^I have setup database cleaner to clean multiple databases using datamapper$/ do
|
||||
#DatabaseCleaner
|
||||
# require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
|
||||
#
|
||||
# DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
|
||||
# DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
|
||||
end
|
||||
|
||||
When /^I create a widget using datamapper$/ do
|
||||
DataMapperWidget.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using datamapper$/ do |widget_count|
|
||||
expect(DataMapperWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using datamapper$/ do
|
||||
begin
|
||||
DataMapperWidgetUsingDatabaseOne.create!
|
||||
rescue StandardError => e
|
||||
BREAK = e.backtrace
|
||||
debugger
|
||||
DataMapperWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using datamapper$/ do
|
||||
DataMapperWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using datamapper$/ do |widget_count|
|
||||
expect(DataMapperWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using datamapper$/ do |widget_count|
|
||||
expect(DataMapperWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
When /^I create a widget using mongoid$/ do
|
||||
MongoidWidget.create!( :id => rand(1000)+1000)
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using mongoid$/ do |widget_count|
|
||||
expect(MongoidWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using mongoid$/ do
|
||||
MongoidWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using mongoid$/ do
|
||||
MongoidWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using mongoid$/ do |widget_count|
|
||||
expect(MongoidWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using mongoid$/ do |widget_count|
|
||||
expect(MongoidWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
Given /^I have setup database cleaner to clean multiple databases using mongomapper$/ do
|
||||
#DatabaseCleaner
|
||||
# require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
|
||||
#
|
||||
# DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
|
||||
# DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
|
||||
end
|
||||
|
||||
When /^I create a widget using mongomapper$/ do
|
||||
MongoMapperWidget.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using mongomapper$/ do |widget_count|
|
||||
expect(MongoMapperWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using mongomapper$/ do
|
||||
MongoMapperWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using mongomapper$/ do
|
||||
MongoMapperWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using mongomapper$/ do |widget_count|
|
||||
expect(MongoMapperWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using mongomapper$/ do |widget_count|
|
||||
expect(MongoMapperWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
When /^I create a widget using neo4j$/ do
|
||||
Neo4jWidget.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using neo4j$/ do |widget_count|
|
||||
expect(Neo4jWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using neo4j$/ do
|
||||
Neo4jWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using neo4j$/ do
|
||||
Neo4jWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using neo4j$/ do |widget_count|
|
||||
expect(Neo4jWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using neo4j$/ do |widget_count|
|
||||
expect(Neo4jWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
Given /^I have setup database cleaner to clean multiple databases using ohm$/ do
|
||||
#DatabaseCleaner
|
||||
# require "#{File.dirname(__FILE__)}/../../../lib/ohm_models"
|
||||
#
|
||||
# DatabaseCleaner[:ohm, {:connection => ENV['REDIS_URL_ONE']} ].strategy = :truncation
|
||||
# DatabaseCleaner[:ohm, {:connection => ENV['REDIS_URL_TWO']} ].strategy = :truncation
|
||||
end
|
||||
|
||||
When /^I create a widget using ohm$/ do
|
||||
OhmWidget.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget using ohm$/ do |widget_count|
|
||||
expect(OhmWidget.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
When /^I create a widget in one db using ohm$/ do
|
||||
OhmWidgetUsingDatabaseOne.create!
|
||||
end
|
||||
|
||||
When /^I create a widget in another db using ohm$/ do
|
||||
OhmWidgetUsingDatabaseTwo.create!
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in one db using ohm$/ do |widget_count|
|
||||
expect(OhmWidgetUsingDatabaseOne.count).to eq widget_count.to_i
|
||||
end
|
||||
|
||||
Then /^I should see ([\d]+) widget in another db using ohm$/ do |widget_count|
|
||||
expect(OhmWidgetUsingDatabaseTwo.count).to eq widget_count.to_i
|
||||
end
|
|
@ -1,6 +1,3 @@
|
|||
#Hilarious as it seems, this is necessary so bundle exec cucumber works for mongoid cukeage (I'm assuming mongomapper is automatically present because its a git repo)
|
||||
Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
|
||||
|
||||
require 'bundler'
|
||||
|
||||
Bundler.setup
|
||||
|
@ -9,7 +6,6 @@ require 'rspec/expectations'
|
|||
|
||||
DB_DIR = "#{File.dirname(__FILE__)}/../../db"
|
||||
|
||||
use_gems = ENV['USE_GEMS']
|
||||
orm = ENV['ORM']
|
||||
another_orm = ENV['ANOTHER_ORM']
|
||||
strategy = ENV['STRATEGY']
|
||||
|
@ -24,48 +20,34 @@ require "active_support/core_ext/string/inflections"
|
|||
|
||||
if orm && strategy
|
||||
require "#{File.dirname(__FILE__)}/../../lib/#{orm.downcase}_models"
|
||||
if use_gems
|
||||
require "database_cleaner-#{orm.underscore}"
|
||||
else
|
||||
$:.unshift(File.dirname(__FILE__) + '/../../../lib')
|
||||
require "database_cleaner-core"
|
||||
end
|
||||
|
||||
if another_orm
|
||||
require "#{File.dirname(__FILE__)}/../../lib/#{another_orm.downcase}_models"
|
||||
if use_gems
|
||||
require "database_cleaner-#{another_orm.underscore}"
|
||||
end
|
||||
end
|
||||
|
||||
require 'database_cleaner/cucumber'
|
||||
|
||||
if multiple_db
|
||||
DatabaseCleaner.app_root = "#{File.dirname(__FILE__)}/../.."
|
||||
orm_sym = orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym
|
||||
|
||||
case orm_sym
|
||||
when :mongo_mapper
|
||||
DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_one'} ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_two'} ].strategy = strategy.to_sym
|
||||
when :redis, :ohm
|
||||
DatabaseCleaner[ orm_sym, {:connection => ENV['REDIS_URL_ONE']} ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[ orm_sym, {:connection => ENV['REDIS_URL_TWO']} ].strategy = strategy.to_sym
|
||||
when :redis
|
||||
DatabaseCleaner[orm_sym, connection: ENV['REDIS_URL_ONE']].strategy = strategy.to_sym
|
||||
DatabaseCleaner[orm_sym, connection: ENV['REDIS_URL_TWO']].strategy = strategy.to_sym
|
||||
when :active_record
|
||||
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseOne} ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseTwo} ].strategy = strategy.to_sym
|
||||
else
|
||||
DatabaseCleaner[ orm_sym, {:connection => :one} ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[ orm_sym, {:connection => :two} ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[:active_record, model: ActiveRecordWidgetUsingDatabaseOne].strategy = strategy.to_sym
|
||||
DatabaseCleaner[:active_record, model: ActiveRecordWidgetUsingDatabaseTwo].strategy = strategy.to_sym
|
||||
end
|
||||
|
||||
elsif another_orm
|
||||
DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[ another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
|
||||
DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym].strategy = strategy.to_sym
|
||||
DatabaseCleaner[another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym].strategy = strategy.to_sym
|
||||
else
|
||||
DatabaseCleaner.strategy = strategy.to_sym unless strategy == "default"
|
||||
end
|
||||
|
||||
else
|
||||
raise "Run 'ORM=ActiveRecord|DataMapper|MongoMapper|CouchPotato|Ohm|Redis [ANOTHER_ORM=...] [MULTIPLE_DBS=true] STRATEGY=transaction|truncation|default cucumber examples/features'"
|
||||
raise "Run 'ORM=ActiveRecord|Redis [ANOTHER_ORM=...] [MULTIPLE_DBS=true] STRATEGY=transaction|truncation|default cucumber examples/features'"
|
||||
end
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
require 'couch_potato'
|
||||
require 'json/pure' unless defined? ::JSON
|
||||
::CouchPotato::Config.database_name = 'couch_potato_test'
|
||||
|
||||
class CouchPotatoWidget
|
||||
include CouchPotato::Persistence
|
||||
|
||||
property :name
|
||||
view :by_name, :key => :name
|
||||
|
||||
|
||||
# mimic the AR interface used in example_steps
|
||||
|
||||
def self.create!(attrs = {})
|
||||
CouchPotato.database.save(self.new)
|
||||
end
|
||||
|
||||
def self.count
|
||||
CouchPotato.database.view(self.by_name).size
|
||||
end
|
||||
end
|
||||
|
||||
class CouchPotatoWidgetUsingDatabaseOne
|
||||
include CouchPotato::Persistence
|
||||
|
||||
database_name = 'couch_potato_test_one'
|
||||
|
||||
property :name
|
||||
view :by_name, :key => :name
|
||||
|
||||
|
||||
# mimic the AR interface used in example_steps
|
||||
|
||||
def self.create!(attrs = {})
|
||||
CouchPotato.database.save(self.new)
|
||||
end
|
||||
|
||||
def self.count
|
||||
CouchPotato.database.view(self.by_name).size
|
||||
end
|
||||
end
|
||||
|
||||
class CouchPotatoWidgetUsingDatabaseTwo
|
||||
include CouchPotato::Persistence
|
||||
|
||||
database_name = 'couch_potato_test_two'
|
||||
|
||||
property :name
|
||||
view :by_name, :key => :name
|
||||
|
||||
|
||||
# mimic the AR interface used in example_steps
|
||||
|
||||
def self.create!(attrs = {})
|
||||
CouchPotato.database.save(self.new)
|
||||
end
|
||||
|
||||
def self.count
|
||||
CouchPotato.database.view(self.by_name).size
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
require "dm-core"
|
||||
require "dm-transactions"
|
||||
|
||||
#Datamapper 1.0 requires you to require dm-migrations to automigrate
|
||||
require "dm-migrations"
|
||||
|
||||
# only to please activerecord API used in database_cleaner/examples/features/step_definitions
|
||||
# yes, i know that's lazy ...
|
||||
|
||||
require "dm-validations"
|
||||
require "dm-aggregates"
|
||||
|
||||
DataMapper.setup(:default, "sqlite3:#{DB_DIR}/datamapper_default.db")
|
||||
DataMapper.setup(:one, "sqlite3:#{DB_DIR}/datamapper_one.db")
|
||||
DataMapper.setup(:two, "sqlite3:#{DB_DIR}/datamapper_two.db")
|
||||
|
||||
class DataMapperWidget
|
||||
include DataMapper::Resource
|
||||
|
||||
property :id, Serial
|
||||
property :name, String
|
||||
end
|
||||
|
||||
class DataMapperWidgetUsingDatabaseOne
|
||||
include DataMapper::Resource
|
||||
|
||||
def self.default_repository_name
|
||||
:one
|
||||
end
|
||||
|
||||
property :id, Serial
|
||||
property :name, String
|
||||
|
||||
end
|
||||
|
||||
class DataMapperWidgetUsingDatabaseTwo
|
||||
include DataMapper::Resource
|
||||
|
||||
def self.default_repository_name
|
||||
:two
|
||||
end
|
||||
|
||||
property :id, Serial
|
||||
property :name, String
|
||||
|
||||
end
|
||||
|
||||
DataMapperWidget.auto_migrate!
|
||||
DataMapperWidgetUsingDatabaseOne.auto_migrate!
|
||||
DataMapperWidgetUsingDatabaseTwo.auto_migrate!
|
|
@ -1,44 +0,0 @@
|
|||
require 'mongoid'
|
||||
|
||||
Mongoid.configure do |config|
|
||||
config.master = Mongo::Connection.new.db('database_cleaner_test')
|
||||
end
|
||||
|
||||
class MongoidWidget
|
||||
include Mongoid::Document
|
||||
field :id, :type => Integer
|
||||
field :name
|
||||
|
||||
class << self
|
||||
#mongoid doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MongoidWidgetUsingDatabaseOne
|
||||
include Mongoid::Document
|
||||
field :id, :type => Integer
|
||||
field :name
|
||||
|
||||
class << self
|
||||
#mongoid doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MongoidWidgetUsingDatabaseTwo
|
||||
include Mongoid::Document
|
||||
field :id, :type => Integer
|
||||
field :name
|
||||
|
||||
class << self
|
||||
#mongoid doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'mongo_mapper'
|
||||
|
||||
::MongoMapper.connection = Mongo::Connection.new('127.0.0.1')
|
||||
::MongoMapper.database = 'database_cleaner_test'
|
||||
|
||||
class MongoMapperWidget
|
||||
include MongoMapper::Document
|
||||
key :id, Integer
|
||||
key :name, String
|
||||
|
||||
class << self
|
||||
#mongomapper doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MongoMapperWidgetUsingDatabaseOne
|
||||
include MongoMapper::Document
|
||||
|
||||
connection = Mongo::Connection.new('127.0.0.1')
|
||||
set_database_name = 'database_cleaner_test_one'
|
||||
|
||||
key :id, Integer
|
||||
key :name, String
|
||||
|
||||
class << self
|
||||
#mongomapper doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MongoMapperWidgetUsingDatabaseTwo
|
||||
include MongoMapper::Document
|
||||
|
||||
connection = Mongo::Connection.new('127.0.0.1')
|
||||
set_database_name = 'database_cleaner_test_two'
|
||||
|
||||
key :id, Integer
|
||||
key :name, String
|
||||
|
||||
class << self
|
||||
#mongomapper doesn't seem to provide this...
|
||||
def create!(*args)
|
||||
new(*args).save!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
require 'neo4j-core'
|
||||
|
||||
class Neo4jWidget < Neo4j::Node
|
||||
def self.create!(*args)
|
||||
create(*args)
|
||||
end
|
||||
|
||||
def self.count
|
||||
Neo4j::Session.query.match('n').pluck('COUNT(n)').first
|
||||
end
|
||||
end
|
||||
|
||||
class Neo4jWidgetUsingDatabaseOne < Neo4jWidget
|
||||
end
|
||||
|
||||
class Neo4jWidgetUsingDatabaseTwo < Neo4jWidget
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
require 'ohm'
|
||||
|
||||
Ohm.connect :url => ENV['REDIS_URL']
|
||||
|
||||
class OhmWidget < Ohm::Model
|
||||
attribute :name
|
||||
|
||||
def self.create!(attrs = {})
|
||||
new({:name => 'some widget'}.merge(attrs)).save
|
||||
end
|
||||
|
||||
def self.count
|
||||
all.count
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class OhmWidgetUsingDatabaseOne < Ohm::Model
|
||||
connect :url => ENV['REDIS_URL_ONE']
|
||||
attribute :name
|
||||
|
||||
def self.create!(attrs = {})
|
||||
new({:name => 'a widget using database one'}.merge(attrs)).save
|
||||
end
|
||||
|
||||
def self.count
|
||||
all.count
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class OhmWidgetUsingDatabaseTwo < Ohm::Model
|
||||
connect :url => ENV['REDIS_URL_TWO']
|
||||
attribute :name
|
||||
|
||||
def self.create!(attrs = {})
|
||||
new({:name => 'a widget using database two'}.merge(attrs)).save
|
||||
end
|
||||
|
||||
def self.count
|
||||
all.count
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
require 'sequel'
|
||||
|
||||
db = Sequel.sqlite # memory database
|
||||
|
||||
db.run 'DROP TABLE IF EXISTS "sequel_widgets"'
|
||||
|
||||
db.create_table :sequel_widgets do
|
||||
String :name
|
||||
end
|
|
@ -15,42 +15,4 @@ Feature: database cleaning
|
|||
| ActiveRecord | transaction |
|
||||
| ActiveRecord | truncation |
|
||||
| ActiveRecord | deletion |
|
||||
| CouchPotato | truncation |
|
||||
| DataMapper | transaction |
|
||||
| DataMapper | truncation |
|
||||
| Mongoid | truncation |
|
||||
| MongoMapper | truncation |
|
||||
| Neo4j | deletion |
|
||||
| Neo4j | truncation |
|
||||
| Neo4j | transaction |
|
||||
| Ohm | truncation |
|
||||
| Redis | truncation |
|
||||
| Sequel | transaction |
|
||||
| Sequel | truncation |
|
||||
| Sequel | deletion |
|
||||
|
||||
Scenario Outline: ruby app
|
||||
Given I am using <ORM>
|
||||
And the <Strategy> cleaning strategy
|
||||
|
||||
When I run my scenarios that rely on a clean database
|
||||
Then I should see all green
|
||||
|
||||
Examples:
|
||||
| ORM | Strategy |
|
||||
| ActiveRecord | transaction |
|
||||
| ActiveRecord | truncation |
|
||||
| ActiveRecord | deletion |
|
||||
| DataMapper | transaction |
|
||||
| DataMapper | truncation |
|
||||
| Sequel | transaction |
|
||||
| Sequel | truncation |
|
||||
| Sequel | deletion |
|
||||
| MongoMapper | truncation |
|
||||
| Mongoid | truncation |
|
||||
| CouchPotato | truncation |
|
||||
| Redis | truncation |
|
||||
| Ohm | truncation |
|
||||
| Neo4j | deletion |
|
||||
| Neo4j | truncation |
|
||||
| Neo4j | transaction |
|
||||
|
|
|
@ -13,30 +13,5 @@ Feature: database cleaning
|
|||
Examples:
|
||||
| ORM |
|
||||
| ActiveRecord |
|
||||
| CouchPotato |
|
||||
| DataMapper |
|
||||
| Mongoid |
|
||||
| MongoMapper |
|
||||
| Neo4j |
|
||||
| Ohm |
|
||||
| Redis |
|
||||
| Sequel |
|
||||
|
||||
Scenario Outline: ruby app
|
||||
Given I am using <ORM>
|
||||
And the default cleaning strategy
|
||||
|
||||
When I run my scenarios that rely on a clean database
|
||||
Then I should see all green
|
||||
|
||||
Examples:
|
||||
| ORM |
|
||||
| ActiveRecord |
|
||||
| DataMapper |
|
||||
| Sequel |
|
||||
| MongoMapper |
|
||||
| Mongoid |
|
||||
| CouchPotato |
|
||||
| Redis |
|
||||
| Ohm |
|
||||
| Neo4j |
|
||||
|
|
|
@ -15,26 +15,5 @@ Feature: multiple database cleaning
|
|||
| ActiveRecord | truncation |
|
||||
| ActiveRecord | deletion |
|
||||
| ActiveRecord | transaction |
|
||||
| DataMapper | truncation |
|
||||
| DataMapper | transaction |
|
||||
| MongoMapper | truncation |
|
||||
| Sequel | truncation |
|
||||
| Sequel | transaction |
|
||||
| Redis | truncation |
|
||||
|
||||
Scenario Outline: ruby app
|
||||
Given I am using <ORM>
|
||||
And the <Strategy> cleaning strategy
|
||||
|
||||
When I run my scenarios that rely on clean databases
|
||||
Then I should see all green
|
||||
|
||||
Examples:
|
||||
| ORM | Strategy |
|
||||
| ActiveRecord | truncation |
|
||||
| ActiveRecord | deletion |
|
||||
| DataMapper | truncation |
|
||||
| Sequel | truncation |
|
||||
| MongoMapper | truncation |
|
||||
| DataMapper | transaction |
|
||||
| ActiveRecord | transaction |
|
||||
| Sequel | transaction |
|
||||
|
|
|
@ -11,138 +11,6 @@ Feature: database cleaning using multiple ORMs
|
|||
|
||||
Examples:
|
||||
| ORM1 | ORM2 |
|
||||
| ActiveRecord | CouchPotato |
|
||||
| ActiveRecord | DataMapper |
|
||||
| ActiveRecord | Mongoid |
|
||||
| ActiveRecord | MongoMapper |
|
||||
| ActiveRecord | Neo4j |
|
||||
| ActiveRecord | Ohm |
|
||||
| ActiveRecord | Redis |
|
||||
| ActiveRecord | Sequel |
|
||||
| CouchPotato | ActiveRecord |
|
||||
| CouchPotato | DataMapper |
|
||||
| CouchPotato | Mongoid |
|
||||
| CouchPotato | MongoMapper |
|
||||
| CouchPotato | Neo4j |
|
||||
| CouchPotato | Ohm |
|
||||
| CouchPotato | Redis |
|
||||
| CouchPotato | Sequel |
|
||||
| DataMapper | ActiveRecord |
|
||||
| DataMapper | CouchPotato |
|
||||
| DataMapper | Mongoid |
|
||||
| DataMapper | MongoMapper |
|
||||
| DataMapper | Neo4j |
|
||||
| DataMapper | Ohm |
|
||||
| DataMapper | Redis |
|
||||
| DataMapper | Sequel |
|
||||
| Mongoid | ActiveRecord |
|
||||
| Mongoid | CouchPotato |
|
||||
| Mongoid | DataMapper |
|
||||
| Mongoid | MongoMapper |
|
||||
| Mongoid | Neo4j |
|
||||
| Mongoid | Ohm |
|
||||
| Mongoid | Redis |
|
||||
| Mongoid | Sequel |
|
||||
| MongoMapper | ActiveRecord |
|
||||
| MongoMapper | CouchPotato |
|
||||
| MongoMapper | DataMapper |
|
||||
| MongoMapper | Mongoid |
|
||||
| MongoMapper | Neo4j |
|
||||
| MongoMapper | Ohm |
|
||||
| MongoMapper | Redis |
|
||||
| MongoMapper | Sequel |
|
||||
| Neo4j | ActiveRecord |
|
||||
| Neo4j | CouchPotato |
|
||||
| Neo4j | DataMapper |
|
||||
| Neo4j | Mongoid |
|
||||
| Neo4j | MongoMapper |
|
||||
| Neo4j | Ohm |
|
||||
| Neo4j | Redis |
|
||||
| Neo4j | Sequel |
|
||||
| Ohm | ActiveRecord |
|
||||
| Ohm | CouchPotato |
|
||||
| Ohm | DataMapper |
|
||||
| Ohm | Mongoid |
|
||||
| Ohm | MongoMapper |
|
||||
| Ohm | Neo4j |
|
||||
| Ohm | Redis |
|
||||
| Ohm | Sequel |
|
||||
| Redis | ActiveRecord |
|
||||
| Redis | CouchPotato |
|
||||
| Redis | DataMapper |
|
||||
| Redis | Mongoid |
|
||||
| Redis | MongoMapper |
|
||||
| Redis | Neo4j |
|
||||
| Redis | Ohm |
|
||||
| Redis | Sequel |
|
||||
| Sequel | ActiveRecord |
|
||||
| Sequel | CouchPotato |
|
||||
| Sequel | DataMapper |
|
||||
| Sequel | Mongoid |
|
||||
| Sequel | MongoMapper |
|
||||
| Sequel | Neo4j |
|
||||
| Sequel | Ohm |
|
||||
| Sequel | Redis |
|
||||
|
||||
Scenario Outline: ruby app
|
||||
Given I am using <ORM1> and <ORM2>
|
||||
|
||||
When I run my scenarios that rely on clean databases using multiple orms
|
||||
Then I should see all green
|
||||
|
||||
Examples:
|
||||
| ORM1 | ORM2 |
|
||||
| ActiveRecord | DataMapper |
|
||||
| ActiveRecord | Sequel |
|
||||
| ActiveRecord | MongoMapper |
|
||||
| ActiveRecord | Mongoid |
|
||||
| ActiveRecord | CouchPotato |
|
||||
| ActiveRecord | Ohm |
|
||||
| ActiveRecord | Redis |
|
||||
| DataMapper | ActiveRecord |
|
||||
| DataMapper | Sequel |
|
||||
| DataMapper | MongoMapper |
|
||||
| DataMapper | Mongoid |
|
||||
| DataMapper | CouchPotato |
|
||||
| DataMapper | Ohm |
|
||||
| DataMapper | Redis |
|
||||
| Sequel | ActiveRecord |
|
||||
| Sequel | DataMapper |
|
||||
| Sequel | MongoMapper |
|
||||
| Sequel | Mongoid |
|
||||
| Sequel | CouchPotato |
|
||||
| Sequel | Ohm |
|
||||
| Sequel | Redis |
|
||||
| MongoMapper | ActiveRecord |
|
||||
| MongoMapper | DataMapper |
|
||||
| MongoMapper | Sequel |
|
||||
| MongoMapper | Mongoid |
|
||||
| MongoMapper | CouchPotato |
|
||||
| MongoMapper | Ohm |
|
||||
| MongoMapper | Redis |
|
||||
| CouchPotato | ActiveRecord |
|
||||
| CouchPotato | DataMapper |
|
||||
| CouchPotato | Sequel |
|
||||
| CouchPotato | MongoMapper |
|
||||
| CouchPotato | Mongoid |
|
||||
| CouchPotato | Ohm |
|
||||
| CouchPotato | Redis |
|
||||
| Ohm | ActiveRecord |
|
||||
| Ohm | DataMapper |
|
||||
| Ohm | Sequel |
|
||||
| Ohm | MongoMapper |
|
||||
| Ohm | Mongoid |
|
||||
| Ohm | CouchPotato |
|
||||
| Redis | ActiveRecord |
|
||||
| Redis | DataMapper |
|
||||
| Redis | Sequel |
|
||||
| Redis | MongoMapper |
|
||||
| Redis | Mongoid |
|
||||
| Redis | CouchPotato |
|
||||
| Redis | Ohm |
|
||||
| Neo4j | ActiveRecord |
|
||||
| Neo4j | DataMapper |
|
||||
| Neo4j | Sequel |
|
||||
| Neo4j | Redis |
|
||||
| Neo4j | Ohm |
|
||||
| Neo4j | MongoMapper |
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
orms_pattern = /(ActiveRecord|DataMapper|Sequel|MongoMapper|Mongoid|CouchPotato|Redis|Ohm|Neo4j)/
|
||||
|
||||
Given /^I am using #{orms_pattern}( from its adapter gem)?$/ do |orm, from_gems|
|
||||
Given /^I am using #{orms_pattern} from its adapter gem$/ do |orm|
|
||||
@feature_runner = FeatureRunner.new
|
||||
@feature_runner.use_gems = !!from_gems
|
||||
@feature_runner.orm = orm
|
||||
end
|
||||
|
||||
Given /^I am using #{orms_pattern} and #{orms_pattern}( from their adapter gems)?$/ do |orm1, orm2, from_gems|
|
||||
Given /^I am using #{orms_pattern} and #{orms_pattern} from their adapter gems$/ do |orm1, orm2|
|
||||
@feature_runner = FeatureRunner.new
|
||||
@feature_runner.use_gems = !!from_gems
|
||||
@feature_runner.orm = orm1
|
||||
@feature_runner.another_orm = orm2
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class FeatureRunner
|
||||
attr_accessor :use_gems
|
||||
attr_accessor :orm
|
||||
attr_accessor :another_orm
|
||||
attr_accessor :multiple_databases
|
||||
|
@ -16,7 +15,6 @@ class FeatureRunner
|
|||
Dir.chdir(full_dir) do
|
||||
|
||||
|
||||
ENV['USE_GEMS'] = use_gems ? "true" : nil
|
||||
ENV['ORM'] = orm
|
||||
ENV['STRATEGY'] = strategy
|
||||
|
||||
|
@ -32,7 +30,7 @@ class FeatureRunner
|
|||
ENV['MULTIPLE_DBS'] = nil
|
||||
end
|
||||
|
||||
self.output = `#{"jruby -S " if defined?(JRUBY_VERSION)}cucumber features/#{feature}.feature`
|
||||
self.output = `cucumber features/#{feature}.feature`
|
||||
|
||||
self.exit_status = $?.exitstatus
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue