I have a migration to Rails that inserts a record into a database. The category model depends on this entry. Since RSpec cleans the database before each example, this record is lost and, moreover, is never created, since RSpec does not seem to generate the database from migrations. What is the best way to create / recreate this entry in a database? Will it be used before (: all)?
Itβs not that RSpec cleans the database, it is that Rails rake: db: prepare task copies the schema (but not the contents) of your dev database to your * _test db.
, before(:all), , .
before(:all)
( : - , "dev" "test" . db , rake: db: . .)
, db/migration, , yml, category.yml
def self.up down directory = File.join( File.dirname(__FILE__), "data" ) Fixtures.create_fixtures( directory, "categories" ) end def self.down Category.delete_all end
Source: https://habr.com/ru/post/1699254/More articles:Using Lists in C # - arraylistExtensible Rule Based Access Template - oopSearch an external SharePoint database - searchHow to associate a function with a component programmatically in ActionScript? - flexHow can I determine which WebMethod was called in a web service - c #SSH Automation Without Public Key Authentication Or Waiting (1) - authenticationWhat is the best way to convert a UTC string to a date in Crystal Reports? - stringProvide password with shell script - linuxHow can I generate random integers in a range in Smalltalk? - randomhow to execute c # file - c #All Articles