small medium large xlarge

Mypicweb_pragsmall
09 Nov 2010, 09:02
Steve Mills (4 posts)

I am unable to do either the Unit Tests or the Functional Tests. What appears to happen is that the Test DB is migrated, the Fixtures are loaded and then just as the first test is about to start the Products table is dropped and the test fails because it doesn’t exist. Even if I run the early steps by hand, and check with Toad that the table is on the DB, this still happens - the table is deleted before the tests can run. I’m using MySQL with ISAM database files. I have the following lines in test_helper which may be relevant:-

fixtures :all self.use_transactional_fixtures = false self.use_instantiated_fixtures = false - I have tried all permutations of these two parameters. I believe the first should be false (for MySQL ISAM) and the second I think should actually be true.

I’m having to continue through the book building but not testing and I’d really like to understand and use TDD.

Generic-user-small
24 Mar 2011, 02:35
Ninju Bohra (4 posts)

I too am having trouble with running the tests and am also using MySQL

PDF version b13

Page 88 Everything work on the scaffold built system…I can view the products and even add a product with the new product being saved to the MySQL database. When I try running rake test I get

C:\intel3\depot>rake test --trace
(in C:/intel3/depot)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute test:prepare
** Execute test:units
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
E
Finished in 2.046888 seconds.

  1) Error:
test_the_truth(ProductTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:414:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

Test run options: --seed 39055
** Invoke test:functionals (first_time)
** Invoke test:prepare
** Execute test:functionals
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
EEEEEEE
Finished in 1.546885 seconds.

  1) Error:
test_should_create_product(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  2) Error:
test_should_destroy_product(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  3) Error:
test_should_get_edit(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  4) Error:
test_should_get_index(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  5) Error:
test_should_get_new(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  6) Error:
test_should_show_product(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

  7) Error:
test_should_update_product(ProductsControllerTest):
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'depot_test.products' doesn't exist: DELETE FROM `products`
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
    .
    .
    .
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:424:in `_run_setup_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

7 tests, 0 assertions, 0 failures, 7 errors, 0 skips

Test run options: --seed 57821
** Invoke test:integration (first_time)
** Invoke test:prepare
** Execute test:integration
Errors running test:units, test:functionals!

Is there some configuration that I need to do to setup the test database? I saw that I needed to adjust the database.yaml file (since I have a MySQL password). My file look like

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
#   gem install mysql2
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: depot_development
  pool: 5
  username: root
  password: root
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: depot_test
  pool: 5
  username: root
  password: root
  host: localhost

Please advise

Generic-user-small
23 Mar 2011, 22:17
Ninju Bohra (4 posts)

Okay…I got something strange going on Rails builds the TEST database structure off a file called schema.rb which should be updated with every rake db:migrate call I tried the following:

C:\intel3\depot>rake db:migrate VERSION=0
(in C:/intel3/depot)
==  CreateProducts: reverting =================================================
-- drop_table(:products)
   -> 0.0000s
==  CreateProducts: reverted (0.0000s) ========================================


C:\intel3\depot>rake db:migrate --trace
(in C:/intel3/depot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateProducts: migrating =================================================
-- create_table(:products)
   -> 0.0156s
==  CreateProducts: migrated (0.0156s) ========================================

** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump

but the schema.rb file shows:

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110323130706) do

# Could not dump table "products" because of following ArgumentError
#   invalid date

end

I don’t know if it related to the MySQL’s interpretation of the attributes on the Products model. Here is my only migration:

class CreateProducts < ActiveRecord::Migration
  def self.up
    create_table :products do |t|
      t.string :title
      t.text :description
      t.string :image_url
      t.decimal :price, :precision => 8, :scale => 2

      t.timestamps
    end
  end

  def self.down
    drop_table :products
  end
end

And again everything works okay with the application AFAIK.

I looked inside the sample code (C:\rails4-code\code\depot_c\db\schema.rb) and copied its contents to my \depot\db\schema.rb file and this is what I got when I tried running the tests

C:\intel3\depot>rake test --trace
(in C:/intel3/depot)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute test:prepare
** Execute test:units
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
.
Finished in 2.203139 seconds.

1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 25030
** Invoke test:functionals (first_time)
** Invoke test:prepare
** Execute test:functionals
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
E.....E
Finished in 2.343765 seconds.

  1) Error:
test_should_create_product(ProductsControllerTest):
TypeError: can't copy BigDecimal
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `initialize_copy'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `initialize_dup'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `dup'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `updated_at='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1558:in `block in attributes='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1554:in `each'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1554:in `attributes='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1406:in `initialize'
    C:/intel3/depot/app/controllers/products_controller.rb:43:in `new'
    C:/intel3/depot/app/controllers/products_controller.rb:43:in `create'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/base.rb:150:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/rendering.rb:11:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:435:in `_run__873284088__process_action__112419314__callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:93:in `run_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/callbacks.rb:17:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `block in instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/rescue.rb:17:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/base.rb:119:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/rendering.rb:41:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:412:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:47:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:355:in `post'
    test/functional/products_controller_test.rb:21:in `block (2 levels) in <class:ProductsControllerTest>'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/testing/assertions.rb:42:in `assert_difference'
    test/functional/products_controller_test.rb:20:in `block in <class:ProductsControllerTest>'

  2) Error:
test_should_update_product(ProductsControllerTest):
TypeError: can't copy BigDecimal
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `initialize_copy'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `initialize_dup'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `dup'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/attribute_methods/time_zone_conversion.rb:41:in `updated_at='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1558:in `block in attributes='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1554:in `each'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1554:in `attributes='
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/persistence.rb:127:in `block in update_attributes'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/transactions.rb:207:in `transaction'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/persistence.rb:126:in `update_attributes'
    C:/intel3/depot/app/controllers/products_controller.rb:62:in `block in update'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/mime_responds.rb:264:in `call'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/mime_responds.rb:264:in `retrieve_response_from_mimes'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/mime_responds.rb:191:in `respond_to'
    C:/intel3/depot/app/controllers/products_controller.rb:61:in `update'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/base.rb:150:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/rendering.rb:11:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:435:in `_run__873284088__process_action__306252543__callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:93:in `run_callbacks'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/callbacks.rb:17:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `block in instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `instrument'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/rescue.rb:17:in `process_action'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/base.rb:119:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/abstract_controller/rendering.rb:41:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:412:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:47:in `process'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/test_case.rb:360:in `put'
    test/functional/products_controller_test.rb:38:in `block in <class:ProductsControllerTest>'

7 tests, 7 assertions, 0 failures, 2 errors, 0 skips

Test run options: --seed 627
** Invoke test:integration (first_time)
** Invoke test:prepare
** Execute test:integration
Errors running test:functionals!

So the ‘unit’ test are running but the ‘functional’ are not…probably because they hit the database for real

Generic-user-small
23 Mar 2011, 23:49
Ninju Bohra (4 posts)

Okay…got it to work (sorta :-))

I took the db\schema.rb from the samples directory and saved it as my own.

I then removed the , :scale => 2 from the t.decimal :price attribute. The new schema.rb is as follows:

ActiveRecord::Schema.define(:version => 20110323130706) do

  create_table "products", :force => true do |t|
    t.string   "title"
    t.text     "description"
    t.string   "image_url"
    t.decimal  "price",       :precision => 8
    t.datetime "created_at"
    t.datetime "updated_at"
  end

end

And then I was able to run all the tests successfully:

C:\intel3\depot>rake test
(in C:/intel3/depot)
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
.....
Finished in 2.468750 seconds.

5 tests, 23 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 37496
Loaded suite C:/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader
Started
.......
Finished in 2.437500 seconds.

7 tests, 10 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 54900

C:\intel3\depot>

The strange is that I am still NOT able to correctly generate the schema.rb file via the rake db:migrate call.

I have even tried adjusting the migration.rb so that it no longer has the :scale => 2 parameter but I still get same ‘error’ output in the generated schema.rb

For now I just need to remember that after applying a new migration (and running rake db:migrate) that I need to reload the schema.rb from the samples directory and remove the :scale => 2 parameter

For reference here is my complete configuration setting

Windows XP 32bit
C:\intel3\depot>ruby -v
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

C:\intel3\depot>rails -v
Rails 3.0.5

C:\intel3\depot>gem -v
1.5.2

C:\intel3\depot>gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.5)
actionpack (3.0.5)
activemodel (3.0.5)
activerecord (3.0.5)
activeresource (3.0.5)
activesupport (3.0.5)
arel (2.0.9)
builder (2.1.2)
bundler (1.0.10)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.15)
mime-types (1.16)
minitest (1.6.0)
mysql2 (0.2.6 x86-mingw32)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.5)
railties (3.0.5)
rake (0.8.7)
rdoc (2.5.8)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.25)

C:\intel3\depot>
<\pre>
You must be logged in to comment