testing - How do I load seed.rb within a Rails test environment using rpec? -


i have following seeds.rb file:

state.create  [    {:name => "alabama", :abbreviation => "al" },    {:name => "alaska", :abbreviation => "ak" },    {:name => "arizona", :abbreviation => "az" },    {:name => "arkansas", :abbreviation => "ar" },    {:name => "california", :abbreviation => "ca" },    {:name => "colorado", :abbreviation => "co" },    {:name => "connecticut", :abbreviation => "ct" },    {:name => "delaware", :abbreviation => "de" },    {:name => "district of columbia", :abbreviation => "dc" },    {:name => "florida", :abbreviation => "fl" },    {:name => "georgia", :abbreviation => "ga" },    {:name => "hawaii", :abbreviation => "hi" },    {:name => "idaho", :abbreviation => "id" },    {:name => "illinois", :abbreviation => "il" },    {:name => "indiana", :abbreviation => "in" },    {:name => "iowa", :abbreviation => "ia" },    {:name => "kansas", :abbreviation => "ks" },    {:name => "kentucky", :abbreviation => "ky" },    {:name => "louisiana", :abbreviation => "la" },    {:name => "maine", :abbreviation => "me" },    {:name => "maryland", :abbreviation => "md" },    {:name => "massachusetts", :abbreviation => "ma" },    {:name => "michigan", :abbreviation => "mi" },    {:name => "minnesota", :abbreviation => "mn" },    {:name => "mississippi", :abbreviation => "ms" },    {:name => "missouri", :abbreviation => "mo" },    {:name => "montana", :abbreviation => "mt" },    {:name => "nebraska", :abbreviation => "ne" },    {:name => "nevada", :abbreviation => "nv" },    {:name => "new hampshire", :abbreviation => "nh" },    {:name => "new jersey", :abbreviation => "nj" },    {:name => "new mexico", :abbreviation => "nm" },    {:name => "new york", :abbreviation => "ny" },    {:name => "north carolina", :abbreviation => "nc" },    {:name => "north dakota", :abbreviation => "nd" },    {:name => "ohio", :abbreviation => "oh" },    {:name => "oklahoma", :abbreviation => "ok" },    {:name => "oregon", :abbreviation => "or" },    {:name => "pennsylvania", :abbreviation => "pa" },    {:name => "rhode island", :abbreviation => "ri" },    {:name => "south carolina", :abbreviation => "sc" },    {:name => "south dakota", :abbreviation => "sd" },    {:name => "tennessee", :abbreviation => "tn" },    {:name => "texas", :abbreviation => "tx" },    {:name => "utah", :abbreviation => "ut" },    {:name => "vermont", :abbreviation => "vt" },    {:name => "virginia", :abbreviation => "va" },    {:name => "washington", :abbreviation => "wa" },    {:name => "west virginia", :abbreviation => "wv" },    {:name => "wisconsin", :abbreviation => "wi" },    {:name => "wyoming", :abbreviation => "wy"} ] 

i able seed data development environment rake db:seed command, i'm confused how within test environment. using rspec , rake test:prepare command, sets empty database.

is there way seed data once test environment while running rake test:prepare?

if want run rake db:seed in test environment, can run command:

rake rails_env=test db:seed 

in fact, can pass rails environment rails_env option


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -