Hello, I''m new in rails developing and I''m just writing my first application. I already created some controllers and models and it works. But now I want to write some tests for my application, but I got problems. I wrote one unit test for one model: test "test_should_create_a_component" do assert Component.create(:project_id => 1, :category_id => 1, :text => ''Test'') end When I run "rake test" I get this message: D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ Programme/InstantRails-2.0/ruby/lib/rubygems1.8/gems/rake-0.8.7/lib/ rake/rake_test_loader.rb" "test/unit/component_test.rb" Loaded suite D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ rake-0.8. 7/lib/rake/rake_test_loader Started E Finished in 0.453 seconds. 1) Error: test_test_should_create_a_component(ComponentTest): ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''integer'' in ''field list'': INSERT INTO `brands` (`integer`, `id`, `string`) VALUES (NULL, 996332877, NULL) (...after that the lines of the code trace) There is definitely no column integer or string in the model. Why does rails ask for this columns? I don''t know where to look for the problem... To check wether it is an problem of my application or of my rails environment I created another demo application with only one model and one test and there I get another error without description, only this: D:\Programme\InstantRails-2.0\rails_apps\home>rake test (in D:/Programme/InstantRails-2.0/rails_apps/home) D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ rake/rake_test_loader.rb" D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ rake/rake_test_loader.rb" Errors running test:units! I''m confused, can you help me? Thanks in advance :-) bye krani
I am not sure but could this be an error in your test fixture file? It could be trying to load the test database from the fixture and failing because the syntax of your fixture yml file is wrong. Colin 2009/5/19 krani <christian.kranert-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> > Hello, > > I''m new in rails developing and I''m just writing my first application. > I already created some controllers and models and it works. > But now I want to write some tests for my application, but I got > problems. > > I wrote one unit test for one model: > > test "test_should_create_a_component" do > assert Component.create(:project_id => 1, :category_id => 1, :text > => ''Test'') > end > > When I run "rake test" I get this message: > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > Programme/InstantRails-2.0/ruby/lib/rubygems1.8/gems/rake-0.8.7/lib/ > rake/rake_test_loader.rb" "test/unit/component_test.rb" > Loaded suite D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ > rake-0.8. > 7/lib/rake/rake_test_loader > Started > E > Finished in 0.453 seconds. > > 1) Error: > test_test_should_create_a_component(ComponentTest): > ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''integer'' > in ''field list'': INSERT INTO `brands` (`integer`, `id`, `string`) > VALUES (NULL, 996332877, NULL) > > (...after that the lines of the code trace) > > There is definitely no column integer or string in the model. Why does > rails ask for this columns? > I don''t know where to look for the problem... > > To check wether it is an problem of my application or of my rails > environment I created another demo application with only one model and > one test and there I get another error without description, only this: > > D:\Programme\InstantRails-2.0\rails_apps\home>rake test > (in D:/Programme/InstantRails-2.0/rails_apps/home) > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > rake/rake_test_loader.rb" > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > rake/rake_test_loader.rb" > > Errors running test:units! > > I''m confused, can you help me? > Thanks in advance :-) > > bye > krani > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, thanks for your reply I don''t think that there is a problem with my fixtures. I have only one: one: project_id:1 category_id:1 name: text:KN Airintake Kit created_at: updated_at: regards krani On 19 Mai, 22:33, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I am not sure but could this be an error in your test fixture file? It > could be trying to load the test database from the fixture and failing > because the syntax of your fixture yml file is wrong. > > Colin > > 2009/5/19 krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > > > > Hello, > > > I''m new in rails developing and I''m just writing my first application. > > I already created some controllers and models and it works. > > But now I want to write some tests for my application, but I got > > problems. > > > I wrote one unit test for one model: > > > test "test_should_create_a_component" do > > assert Component.create(:project_id => 1, :category_id => 1, :text > > => ''Test'') > > end > > > When I run "rake test" I get this message: > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > Programme/InstantRails-2.0/ruby/lib/rubygems1.8/gems/rake-0.8.7/lib/ > > rake/rake_test_loader.rb" "test/unit/component_test.rb" > > Loaded suite D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ > > rake-0.8. > > 7/lib/rake/rake_test_loader > > Started > > E > > Finished in 0.453 seconds. > > > 1) Error: > > test_test_should_create_a_component(ComponentTest): > > ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''integer'' > > in ''field list'': INSERT INTO `brands` (`integer`, `id`, `string`) > > VALUES (NULL, 996332877, NULL) > > > (...after that the lines of the code trace) > > > There is definitely no column integer or string in the model. Why does > > rails ask for this columns? > > I don''t know where to look for the problem... > > > To check wether it is an problem of my application or of my rails > > environment I created another demo application with only one model and > > one test and there I get another error without description, only this: > > > D:\Programme\InstantRails-2.0\rails_apps\home>rake test > > (in D:/Programme/InstantRails-2.0/rails_apps/home) > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > rake/rake_test_loader.rb" > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > rake/rake_test_loader.rb" > > > Errors running test:units! > > > I''m confused, can you help me? > > Thanks in advance :-) > > > bye > > krani
I did not look carefully enough at the output, I see now that it has actually started the test and is in test_test_should_create_a_component. You should be able to see from the trace where in your application it generated the faulty sql, though sometimes you have to examine the trace carefully to find the bits that are in your code and the bits that are in Rails. This might give you a clue. If you can''t work it out post the trace. It would also be worth having a look at db/schema.rb just to check what it thinks the tables should look like. Post that also if necessary. Colin 2009/5/20 krani <christian.kranert-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> > Hi, > > thanks for your reply > > I don''t think that there is a problem with my fixtures. I have only > one: > > one: > project_id:1 > category_id:1 > name: > text:KN Airintake Kit > created_at: > updated_at: > > regards > krani > > On 19 Mai, 22:33, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > I am not sure but could this be an error in your test fixture file? It > > could be trying to load the test database from the fixture and failing > > because the syntax of your fixture yml file is wrong. > > > > Colin > > > > 2009/5/19 krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > > > > > > > > Hello, > > > > > I''m new in rails developing and I''m just writing my first application. > > > I already created some controllers and models and it works. > > > But now I want to write some tests for my application, but I got > > > problems. > > > > > I wrote one unit test for one model: > > > > > test "test_should_create_a_component" do > > > assert Component.create(:project_id => 1, :category_id => 1, :text > > > => ''Test'') > > > end > > > > > When I run "rake test" I get this message: > > > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > Programme/InstantRails-2.0/ruby/lib/rubygems1.8/gems/rake-0.8.7/lib/ > > > rake/rake_test_loader.rb" "test/unit/component_test.rb" > > > Loaded suite D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ > > > rake-0.8. > > > 7/lib/rake/rake_test_loader > > > Started > > > E > > > Finished in 0.453 seconds. > > > > > 1) Error: > > > test_test_should_create_a_component(ComponentTest): > > > ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''integer'' > > > in ''field list'': INSERT INTO `brands` (`integer`, `id`, `string`) > > > VALUES (NULL, 996332877, NULL) > > > > > (...after that the lines of the code trace) > > > > > There is definitely no column integer or string in the model. Why does > > > rails ask for this columns? > > > I don''t know where to look for the problem... > > > > > To check wether it is an problem of my application or of my rails > > > environment I created another demo application with only one model and > > > one test and there I get another error without description, only this: > > > > > D:\Programme\InstantRails-2.0\rails_apps\home>rake test > > > (in D:/Programme/InstantRails-2.0/rails_apps/home) > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > > rake/rake_test_loader.rb" > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > > rake/rake_test_loader.rb" > > > > > Errors running test:units! > > > > > I''m confused, can you help me? > > > Thanks in advance :-) > > > > > bye > > > krani > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi thanks for your help :) The complete trace: D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/connection_adapters/ abstract_adapter.rb:188:in `log'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/connection_adapters/ mysql_adapter.rb:309:in `execute'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/connection_adapters/abstract/ database_statements.rb:147:in `insert_fixture'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:640:in `insert_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:577:in `each'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:577:in `insert_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:520:in `create_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:520:in `each'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:520:in `create_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/connection_adapters/abstract/ database_statements.rb:66:in `transaction'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:518:in `create_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/connection_adapters/ mysql_adapter.rb:254:in `disable_referential_integrity'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:509:in `create_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/base.rb:1398:in `silence'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:508:in `create_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:964:in `load_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.2.2/lib/active_record/fixtures.rb:930:in `setup_fixtures'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `send'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `evaluate_method'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:166:in `call'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `run'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `each'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `send'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `run'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/callbacks.rb:277:in `run_callbacks'' D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb: 58:in `run'' Unfortunately I don''t understand what rails want to tell me with this trace... I don''t think that there is a problem in schema.rb. This is the definition for the component model: create_table "components", :force => true do |t| t.integer "project_id" t.integer "category_id" t.string "name" t.text "text" t.datetime "created_at" t.datetime "updated_at" end bye krani On 20 Mai, 18:28, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I did not look carefully enough at the output, I see now that it has > actually started the test and is in test_test_should_create_a_component. > You should be able to see from the trace where in your application it > generated the faulty sql, though sometimes you have to examine the trace > carefully to find the bits that are in your code and the bits that are in > Rails. This might give you a clue. If you can''t work it out post the > trace. > > It would also be worth having a look at db/schema.rb just to check what it > thinks the tables should look like. Post that also if necessary. > > Colin > > 2009/5/20 krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > > > > Hi, > > > thanks for your reply > > > I don''t think that there is a problem with my fixtures. I have only > > one: > > > one: > > project_id:1 > > category_id:1 > > name: > > text:KN Airintake Kit > > created_at: > > updated_at: > > > regards > > krani > > > On 19 Mai, 22:33, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > I am not sure but could this be an error in your test fixture file? It > > > could be trying to load the test database from the fixture and failing > > > because the syntax of your fixture yml file is wrong. > > > > Colin > > > > 2009/5/19 krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > > > > Hello, > > > > > I''m new in rails developing and I''m just writing my first application. > > > > I already created some controllers and models and it works. > > > > But now I want to write some tests for my application, but I got > > > > problems. > > > > > I wrote one unit test for one model: > > > > > test "test_should_create_a_component" do > > > > assert Component.create(:project_id => 1, :category_id => 1, :text > > > > => ''Test'') > > > > end > > > > > When I run "rake test" I get this message: > > > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > > Programme/InstantRails-2.0/ruby/lib/rubygems1.8/gems/rake-0.8.7/lib/ > > > > rake/rake_test_loader.rb" "test/unit/component_test.rb" > > > > Loaded suite D:/Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/ > > > > rake-0.8. > > > > 7/lib/rake/rake_test_loader > > > > Started > > > > E > > > > Finished in 0.453 seconds. > > > > > 1) Error: > > > > test_test_should_create_a_component(ComponentTest): > > > > ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''integer'' > > > > in ''field list'': INSERT INTO `brands` (`integer`, `id`, `string`) > > > > VALUES (NULL, 996332877, NULL) > > > > > (...after that the lines of the code trace) > > > > > There is definitely no column integer or string in the model. Why does > > > > rails ask for this columns? > > > > I don''t know where to look for the problem... > > > > > To check wether it is an problem of my application or of my rails > > > > environment I created another demo application with only one model and > > > > one test and there I get another error without description, only this: > > > > > D:\Programme\InstantRails-2.0\rails_apps\home>rake test > > > > (in D:/Programme/InstantRails-2.0/rails_apps/home) > > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > > > rake/rake_test_loader.rb" > > > > D:/Programme/InstantRails-2.0/ruby/bin/ruby.exe -I"lib;test" "D:/ > > > > Programme/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/ > > > > rake/rake_test_loader.rb" > > > > > Errors running test:units! > > > > > I''m confused, can you help me? > > > > Thanks in advance :-) > > > > > bye > > > > krani
On May 24, 7:19 pm, krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Unfortunately I don''t understand what rails want to tell me with this > trace... > > I don''t think that there is a problem in schema.rb. This is the > definition for the component model: > > create_table "components", :force => true do |t| > t.integer "project_id" > t.integer "category_id" > t.string "name" > t.text "text" > t.datetime "created_at" > t.datetime "updated_at" > end >The error occurs when loading the fixtures for brand. You should probably look at the fixtures file or schema for that table. Fred
Thank you! For whatever reason there were faulty definitions in the fixtures of other models. Now it works :) Thanks everybody who tried to help me! On 24 Mai, 20:25, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 24, 7:19 pm, krani <christian.kran...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Unfortunately I don''t understand what rails want to tell me with this > > trace... > > > I don''t think that there is a problem in schema.rb. This is the > > definition for the component model: > > > create_table "components", :force => true do |t| > > t.integer "project_id" > > t.integer "category_id" > > t.string "name" > > t.text "text" > > t.datetime "created_at" > > t.datetime "updated_at" > > end > > The error occurs when loading the fixtures for brand. You should > probably look at the fixtures file or schema for that table. > > Fred