After '@tempfile' do if @tempfile @tempfile.close @tempfile.unlink end end After '@config' do |scenario, block| APP_CONFIG.replace @orig_config if @orig_config end # store end of server log for failing scenarios After do |scenario| if scenario.failed? logfile_path = Rails.root + 'tmp' logfile_path += "#{scenario.name.gsub(/\s/, '_')}.log" File.open(logfile_path, 'w') do |test_log| test_log.puts scenario.name test_log.puts "=========================" test_log.puts `tail log/test.log -n 200` end end end # clear all records we created After do names = self.instance_variables.reject do |v| v.to_s.starts_with?('@_') end names.each do |name| record = self.instance_variable_get name if record.is_a?(CouchRest::Model::Base) && record.persisted? record.reload && record.destroy end end end