mirror of
				https://github.com/DatabaseCleaner/database_cleaner
				synced 2023-03-27 23:22:03 -04:00 
			
		
		
		
	repair features and support to all pass for cleaning single orms/dbs, so legacy works, theres also some preperation for other modes
This commit is contained in:
		
							parent
							
								
									27a11f1d83
								
							
						
					
					
						commit
						688b720591
					
				
					 4 changed files with 49 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -4,13 +4,4 @@ end
 | 
			
		|||
 | 
			
		||||
Then /^I should see 1 widget$/ do
 | 
			
		||||
  Widget.count.should == 1
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
When /^I create a sneaky widget$/ do
 | 
			
		||||
  SneakyWidget.create!
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Then /^I should see 1 sneaky widget$/ do
 | 
			
		||||
  SneakyWidget.count.should == 1
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -10,7 +10,7 @@ if orm && strategy
 | 
			
		|||
 | 
			
		||||
  begin            
 | 
			
		||||
    require "#{File.dirname(__FILE__)}/../../lib/#{orm}_models"
 | 
			
		||||
  rescue LoadError
 | 
			
		||||
  rescue LoadError => e   
 | 
			
		||||
    raise "You don't have the #{orm} ORM installed"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,25 +1,31 @@
 | 
			
		|||
 | 
			
		||||
Given /^I am using (ActiveRecord|DataMapper|MongoMapper|CouchPotato)$/ do |orm|
 | 
			
		||||
  @orm = orm
 | 
			
		||||
  @feature_runner = FeatureRunner.new
 | 
			
		||||
  @feature_runner.orm = orm
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Given /^I am using (ActiveRecord|DataMapper|MongoMapper|CouchPotato) and (ActiveRecord|DataMapper|MongoMapper|CouchPotato)$/ do |orm1,orm2|
 | 
			
		||||
  @feature_runner = FeatureRunner.new
 | 
			
		||||
  @feature_runner.orm         = orm1
 | 
			
		||||
  @feature_runner.another_orm = orm2
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Given /^the (.+) cleaning strategy$/ do |strategy|
 | 
			
		||||
  @strategy = strategy
 | 
			
		||||
  @feature_runner.strategy = strategy
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
When "I run my scenarios that rely on a clean database" do
 | 
			
		||||
  full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/")
 | 
			
		||||
  Dir.chdir(full_dir) do
 | 
			
		||||
    ENV['ORM'] = @orm.downcase
 | 
			
		||||
    ENV['STRATEGY'] = @strategy
 | 
			
		||||
    @out = `#{"jruby -S " if defined?(JRUBY_VERSION)}cucumber features`
 | 
			
		||||
    @status = $?.exitstatus
 | 
			
		||||
  end
 | 
			
		||||
  @feature_runner.go 'example'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
When "I run my scenarios that rely on clean databases using multiple orms" do
 | 
			
		||||
  @feature_runner.go 'example_multiple_orms'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
When "I run my scenarios that rely on clean databases using multiple orms" do
 | 
			
		||||
  @feature_runner.go 'example_multiple_orms'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Then "I should see all green" do
 | 
			
		||||
  unless @status == 0
 | 
			
		||||
    raise "Expected to see all green but we saw FAIL! Output:\n#{@out}"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  fail "Feature failed with :#{@feature_runner.output}" unless @feature_runner.exit_status == 0
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										26
									
								
								features/support/feature_runner.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								features/support/feature_runner.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
class FeatureRunner
 | 
			
		||||
  attr_accessor :orm
 | 
			
		||||
  attr_accessor :another_orm
 | 
			
		||||
  attr_accessor :strategy
 | 
			
		||||
  attr_accessor :exit_status
 | 
			
		||||
  attr_accessor :output
 | 
			
		||||
  
 | 
			
		||||
  def strategy
 | 
			
		||||
    @strategy || 'truncation'
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def go feature
 | 
			
		||||
    full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/")
 | 
			
		||||
    Dir.chdir(full_dir) do
 | 
			
		||||
 | 
			
		||||
      ENV['ORM']         = orm.downcase
 | 
			
		||||
      ENV['ANOTHER_ORM'] = another_orm.downcase if another_orm
 | 
			
		||||
      ENV['STRATEGY']    = strategy
 | 
			
		||||
 | 
			
		||||
      self.output = `#{"jruby -S " if defined?(JRUBY_VERSION)}cucumber features/#{feature}.feature`
 | 
			
		||||
 | 
			
		||||
      self.exit_status = $?.exitstatus  
 | 
			
		||||
    end    
 | 
			
		||||
  end
 | 
			
		||||
    
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue