📄 21 - unit testing your website.rb
字号:
./script/generate model User exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/user.rb aardvark*create test/unit/user_test.rb create test/fixtures/users.yml*aardvark create db/migrate create db/migrate/001_create_users.rb#---./script/generate users list exists app/controllers/ exists app/helpers/ create app/views/users exists test/functional/ create app/controllers/users_controller.rb aardvark*create test/functional/users_controller_test.rb*aardvark create app/helpers/users_helper.rb create app/views/users/list.rhtml#---$ rake(in /home/lucas/mywebapp)/usr/bin/ruby1.8 "test/unit/user_test.rb"Started.Finished in 0.048702 seconds.1 tests, 1 assertions, 0 failures, 0 errors/usr/bin/ruby1.8 "test/functional/users_controller_test.rb"Started.Finished in 0.024615 seconds.1 tests, 1 assertions, 0 failures, 0 errors#---require File.dirname(__FILE__) + '/../test_helper'class UserTest < Test::Unit::TestCase fixtures :users # Replace this with your real tests. def test_truth assert true endend#---class UserTest def test_first assert_kind_of User, users(:first) endend#---first: id: 1another: id: 2#---class UserTest def test_another assert_kind_of User, users(:another) assert_equal 2, users(:another).id assert_not_equal users(:first), users(:another) endend#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -