I want to run tests against the current database instead of whatever is in fixtures/ . Looking at my SQL db, I have a Video (model) with ID 1. However, running
ruby functional\videos_cont开发者_运维百科roller_test.rb
gives me the error:
test_check_video_offsets(VideosControllerTest):
ActiveRecord::RecordNotFound: Couldn't find Video with ID=1
app/controllers/videos_controller.rb:16:in `show'
This is all that is in the test right now:
test "check video offsets" do
get :show, :id => "1"
Rails::logger.debug @video
end
Got it:
rake db:seed RAILS_ENV=test
Simply set the database name for your test environment to the one of your active environment (development, production.) in your config/database.yml
base: &base
adapter: mysql2
encoding: utf8
username:
password:
development:
<<: *base
database: app_development
test: &test
<<: *base
database: app_development
精彩评论