From 12abeae48bd559486ba91633acd573793c3c699e Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sun, 5 Apr 2020 12:05:02 -0700 Subject: [PATCH] strip down cucumber scenarios to just use the two most popular adapter gems, and reenable to validate the end-to-end UX. --- .travis.yml | 2 + Gemfile | 2 + Rakefile | 4 +- database_cleaner-core.gemspec | 5 + examples/features/example.feature | 2 +- .../step_definitions/activerecord_steps.rb | 4 +- .../step_definitions/couchpotato_steps.rb | 31 ---- .../step_definitions/datamapper_steps.rb | 37 ----- .../step_definitions/mongoid_steps.rb | 23 --- .../step_definitions/mongomapper_steps.rb | 31 ---- .../features/step_definitions/neo4j_steps.rb | 23 --- .../features/step_definitions/ohm_steps.rb | 31 ---- examples/features/support/env.rb | 38 ++--- examples/lib/couchpotato_models.rb | 61 -------- examples/lib/datamapper_models.rb | 50 ------- examples/lib/mongoid_models.rb | 44 ------ examples/lib/mongomapper_models.rb | 51 ------- examples/lib/neo4j_models.rb | 17 --- examples/lib/ohm_models.rb | 43 ------ examples/lib/sequel_models.rb | 9 -- features/cleaning.feature | 38 ----- features/cleaning_default_strategy.feature | 25 ---- features/cleaning_multiple_dbs.feature | 31 +--- features/cleaning_multiple_orms.feature | 132 ------------------ .../database_cleaner_steps.rb | 6 +- features/support/feature_runner.rb | 4 +- 26 files changed, 33 insertions(+), 711 deletions(-) delete mode 100644 examples/features/step_definitions/couchpotato_steps.rb delete mode 100644 examples/features/step_definitions/datamapper_steps.rb delete mode 100644 examples/features/step_definitions/mongoid_steps.rb delete mode 100644 examples/features/step_definitions/mongomapper_steps.rb delete mode 100644 examples/features/step_definitions/neo4j_steps.rb delete mode 100644 examples/features/step_definitions/ohm_steps.rb delete mode 100644 examples/lib/couchpotato_models.rb delete mode 100644 examples/lib/datamapper_models.rb delete mode 100644 examples/lib/mongoid_models.rb delete mode 100644 examples/lib/mongomapper_models.rb delete mode 100644 examples/lib/neo4j_models.rb delete mode 100644 examples/lib/ohm_models.rb delete mode 100644 examples/lib/sequel_models.rb diff --git a/.travis.yml b/.travis.yml index 2d533c9..970327f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: ruby +services: + - redis rvm: - 2.5 - 2.6 diff --git a/Gemfile b/Gemfile index 3b81906..dfc4aef 100644 --- a/Gemfile +++ b/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" diff --git a/Rakefile b/Rakefile index 7efc873..e0ba1b1 100644 --- a/Rakefile +++ b/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" diff --git a/database_cleaner-core.gemspec b/database_cleaner-core.gemspec index 467710f..db8cfa7 100644 --- a/database_cleaner-core.gemspec +++ b/database_cleaner-core.gemspec @@ -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 diff --git a/examples/features/example.feature b/examples/features/example.feature index 7559bd7..907287a 100644 --- a/examples/features/example.feature +++ b/examples/features/example.feature @@ -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 diff --git a/examples/features/step_definitions/activerecord_steps.rb b/examples/features/step_definitions/activerecord_steps.rb index ed7399f..1fac045 100644 --- a/examples/features/step_definitions/activerecord_steps.rb +++ b/examples/features/step_definitions/activerecord_steps.rb @@ -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 diff --git a/examples/features/step_definitions/couchpotato_steps.rb b/examples/features/step_definitions/couchpotato_steps.rb deleted file mode 100644 index df19c3a..0000000 --- a/examples/features/step_definitions/couchpotato_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/step_definitions/datamapper_steps.rb b/examples/features/step_definitions/datamapper_steps.rb deleted file mode 100644 index 08ee6a1..0000000 --- a/examples/features/step_definitions/datamapper_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/step_definitions/mongoid_steps.rb b/examples/features/step_definitions/mongoid_steps.rb deleted file mode 100644 index 27c8137..0000000 --- a/examples/features/step_definitions/mongoid_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/step_definitions/mongomapper_steps.rb b/examples/features/step_definitions/mongomapper_steps.rb deleted file mode 100644 index f5e059c..0000000 --- a/examples/features/step_definitions/mongomapper_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/step_definitions/neo4j_steps.rb b/examples/features/step_definitions/neo4j_steps.rb deleted file mode 100644 index d0ae558..0000000 --- a/examples/features/step_definitions/neo4j_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/step_definitions/ohm_steps.rb b/examples/features/step_definitions/ohm_steps.rb deleted file mode 100644 index b20aeb0..0000000 --- a/examples/features/step_definitions/ohm_steps.rb +++ /dev/null @@ -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 diff --git a/examples/features/support/env.rb b/examples/features/support/env.rb index bb6350f..efdafb5 100644 --- a/examples/features/support/env.rb +++ b/examples/features/support/env.rb @@ -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 + require "database_cleaner-#{orm.underscore}" if another_orm require "#{File.dirname(__FILE__)}/../../lib/#{another_orm.downcase}_models" - if use_gems - require "database_cleaner-#{another_orm.underscore}" - end + require "database_cleaner-#{another_orm.underscore}" 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 diff --git a/examples/lib/couchpotato_models.rb b/examples/lib/couchpotato_models.rb deleted file mode 100644 index 03b3cc3..0000000 --- a/examples/lib/couchpotato_models.rb +++ /dev/null @@ -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 diff --git a/examples/lib/datamapper_models.rb b/examples/lib/datamapper_models.rb deleted file mode 100644 index 896f347..0000000 --- a/examples/lib/datamapper_models.rb +++ /dev/null @@ -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! diff --git a/examples/lib/mongoid_models.rb b/examples/lib/mongoid_models.rb deleted file mode 100644 index 2d1fd2c..0000000 --- a/examples/lib/mongoid_models.rb +++ /dev/null @@ -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 diff --git a/examples/lib/mongomapper_models.rb b/examples/lib/mongomapper_models.rb deleted file mode 100644 index 667de31..0000000 --- a/examples/lib/mongomapper_models.rb +++ /dev/null @@ -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 diff --git a/examples/lib/neo4j_models.rb b/examples/lib/neo4j_models.rb deleted file mode 100644 index 8019cfe..0000000 --- a/examples/lib/neo4j_models.rb +++ /dev/null @@ -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 diff --git a/examples/lib/ohm_models.rb b/examples/lib/ohm_models.rb deleted file mode 100644 index 12dd93d..0000000 --- a/examples/lib/ohm_models.rb +++ /dev/null @@ -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 diff --git a/examples/lib/sequel_models.rb b/examples/lib/sequel_models.rb deleted file mode 100644 index bd7a279..0000000 --- a/examples/lib/sequel_models.rb +++ /dev/null @@ -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 diff --git a/features/cleaning.feature b/features/cleaning.feature index 2e7e858..8cdd5cb 100644 --- a/features/cleaning.feature +++ b/features/cleaning.feature @@ -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 - And the 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 | diff --git a/features/cleaning_default_strategy.feature b/features/cleaning_default_strategy.feature index 60a530d..7d64b4d 100644 --- a/features/cleaning_default_strategy.feature +++ b/features/cleaning_default_strategy.feature @@ -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 - 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 | diff --git a/features/cleaning_multiple_dbs.feature b/features/cleaning_multiple_dbs.feature index d637a08..febdbb9 100644 --- a/features/cleaning_multiple_dbs.feature +++ b/features/cleaning_multiple_dbs.feature @@ -11,30 +11,9 @@ Feature: multiple database cleaning Then I should see all green Examples: - | ORM | Strategy | - | ActiveRecord | truncation | - | ActiveRecord | deletion | - | ActiveRecord | transaction | - | DataMapper | truncation | - | DataMapper | transaction | - | MongoMapper | truncation | - | Sequel | truncation | - | Sequel | transaction | + | ORM | Strategy | + | ActiveRecord | truncation | + | ActiveRecord | deletion | + | ActiveRecord | transaction | + | Redis | truncation | - Scenario Outline: ruby app - Given I am using - And the 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 | diff --git a/features/cleaning_multiple_orms.feature b/features/cleaning_multiple_orms.feature index bfda4fb..43292e0 100644 --- a/features/cleaning_multiple_orms.feature +++ b/features/cleaning_multiple_orms.feature @@ -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 and - - 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 | diff --git a/features/step_definitions/database_cleaner_steps.rb b/features/step_definitions/database_cleaner_steps.rb index 5fb77a8..c003ab3 100644 --- a/features/step_definitions/database_cleaner_steps.rb +++ b/features/step_definitions/database_cleaner_steps.rb @@ -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 diff --git a/features/support/feature_runner.rb b/features/support/feature_runner.rb index 8d09025..10974e6 100644 --- a/features/support/feature_runner.rb +++ b/features/support/feature_runner.rb @@ -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