« Previous -
Version 16/18
(diff) -
Next » -
Current version
Guillermo Gómez, 06/10/2010 05:08 pm
Ruby on Rails¶
Plugins¶
Enlaces útiles:
RPC¶
Configuración¶
Base de datos¶
config/database.yml
Mysql¶
$ gem install mysql
production: adapter: mysql database: redmine encoding: utf8 username: ******** password: ******** host: 127.0.0.1 port: 3306 #host: localhost #socket: /var/lib/mysql/mysql.sock
Testing con Rails¶
Algunos comandos rake disponibles en Rails 2.3.8.
rake db:fixtures:identify # Search for a fixture given a LABEL or ID. rake db:fixtures:load # Load fixtures into the current environment's database. rake db:test:clone # Recreate the test database from the current environment's database schema rake db:test:clone_structure # Recreate the test databases from the development structure rake db:test:load # Recreate the test database from the current schema.rb rake db:test:prepare # Check for pending migrations and load the test schema rake db:test:purge # Empty the test database rake test # Run all unit, functional and integration tests rake test:benchmark # Run tests for benchmarkdb:test:prepare / Benchmark the performance tests rake test:functionals # Run tests for functionalsdb:test:prepare / Run the functional tests in test/functional rake test:integration # Run tests for integrationdb:test:prepare / Run the integration tests in test/integration rake test:plugins # Run tests for pluginsenvironment / Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name) rake test:profile # Run tests for profiledb:test:prepare / Profile the performance tests rake test:recent # Run tests for recentdb:test:prepare / Test recent changes rake test:uncommitted # Run tests for uncommitteddb:test:prepare / Test changes since last checkin (only Subversion and Git) rake test:units # Run tests for unitsdb:test:prepare / Run the unit tests in test/unit
Fixtures¶
Los fixtures son la forma de manejar datos para las pruebas.
test/fixtures/users.yml
1one:
2 email: email1@domain.com
3 name: name1
4 last_name: last_name1
5
6two:
7 email: email2@domain.com
8 name: name2
9 last_name: last_name2
Uso de los fixtures en pruebas unitarias.
1class UserTest < ActiveSupport::TestCase
2
3 fixtures :users # Carga los datos en la BD de prueba
4
5 test "fx" do
6 assert true
7 end
8end
Corriendo pruebas unitarias a los modelos¶
[gomix@fricky pinsales]$ rake test:units (in /home/gomix/pinsales) NOTICE: CREATE TABLE will create implicit sequence "pins_id_seq" for serial column "pins.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pins_pkey" for table "pins" NOTICE: CREATE TABLE will create implicit sequence "roles_id_seq" for serial column "roles.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "roles_pkey" for table "roles" NOTICE: CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users" /usr/bin/ruby -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/pin_test.rb" "test/unit/user_test.rb" "test/unit/helpers/roles_helper_test.rb" "test/unit/helpers/users_helper_test.rb" "test/unit/helpers/home_helper_test.rb" "test/unit/helpers/pins_helper_test.rb" "test/unit/role_test.rb" Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader Started .... Finished in 0.078631 seconds. 4 tests, 4 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite /usr/bin/rake Started Finished in 0.000126 seconds. 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed
Este sitio es patrocinado por http://www.neotechgw.com. Desarrollando la industria nacional del software libre.
