[rspec-users] Unexplainable failure...at least for me

Chris Olsen lists at ruby-forum.com
Wed Nov 7 09:49:12 EST 2007

That is the problem, which is clear now that I tested it with the 
script/console in test mode rather than development.

So now the question is, why does the data not exist in the test 
database.  The country and province data inserts exist within the 
migration files, ex for countries:

class CreateCountries < ActiveRecord::Migration
  def self.up
    create_table :countries do |t|
      t.column :country_id, :integer
      t.column :name2, :string, :limit => 2
      t.column :name3, :string, :limit => 3
      t.column :name, :string
      t.column :district_name, :string
      t.column :code_name, :string
      t.column :strength, :integer

    country_data = [
      [124, 'CA', 'CAN', 'Canada', 'Province', 'Postal Code', 100],
      [840, 'US', 'USA', 'United States', 'State', 'ZipCode', 50],
      #along with many other countries
     ].each do |c|

      insert_params = {
        :country_id => c[0],
        :name2 => c[1],
        :name3 => c[2],
        :name => c[3],
        :district_name => c[4],
        :code_name => c[5],
        :strength => c[6]


Thanks for the help.

> The question is where this country and province with id 1 are defined. I
> don't see anything in your spec to indicate that they are ever created.
> If you are using fixtures then you'll need to explicitly include them.
> Otherwise they may or may not still be loaded in the test database and
> at best you'll get a clear failure and at worst inconsistent results.
> describe Address do
>   fixtures :provinces, countries
>   before ... etc
> Kind regards,
> Hans

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list