Hi All,
I was able to match the development database and migration will when
running rake db:migrate
I am trying to understand the error logs generated when running rake.
$ rake
(in /home/user/projects/emporium)
/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/
lib/rake/rake_test_loader.rb" "test/unit/author_test.rb" "test/unit/
helpers/about_helper_test.rb"
./test/unit/author_test.rb:4: undefined method `fixtures' for
AuthorTest:Class (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader.rb:5:in `load'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader.rb:5
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader.rb:5:in `each'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader.rb:5
/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/
lib/rake/rake_test_loader.rb" "test/functional/
about_controller_test.rb"
Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader
Started
Now I am not sure anymore if I was not able to define the fixtures or
where should it be corrected.
D
Hi All,
Now I am not sure anymore if I was not able to define the fixtures or
where should it be corrected.
What does author_test.rb look like ? (Additionally these days you
might as well just stick fixtures :all in test_helper.rb rather than
specifying them in individual test files)
Fred
author_test.rb
require File.dirname(__FILE__) + '/../test_helper'
class AuthorTest < Test::Unit::TestCase
fixtures :authors
def test_name
author = Author.create(:first_name => 'Joel',:last_name => 'Spolsky')
assert_equal 'Joel Spolsky', [author.name](http://author.name)
end
end
*author_test.rb*
require File.dirname(__FILE__) + '/../test_helper'
class AuthorTest < Test::Unit::TestCase
fixtures :authors
Pre Rails 2.3 rails used to add a bunch of methods to
Test::Unit::TestCase (such as stuff to do with fixtures).
Post Rails 2.3 it no longer does that. If you want your test cases to
have access to rails specific stuff, your test cases should inherit
from ActiveSupport::TestCase
Fred
Thanks Freddie - it worked.
There is another error which I am currently searching for answer but maybe you already have?
Processing ApplicationController#index (for 127.0.0.1 at 2009-12-22 03:15:41) [GET]
ActionController::RoutingError (No route matches “/admin/author/new” with {:method=>:get}):
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in
run’
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in
start’
/usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in
start’
/usr/lib/ruby/1.8/webrick/server.rb:92:in each' /usr/lib/ruby/1.8/webrick/server.rb:92:in
start’
/usr/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/lib/ruby/1.8/webrick/server.rb:82:in
start’
Rendering rescues/layout (not_found)
D
11155
(-- --)
December 21, 2009, 7:39pm
6
Dwhitekiss Dwhitekiss wrote:
*author_test.rb*
require File.dirname(__FILE__) + '/../test_helper'
class AuthorTest < Test::Unit::TestCase
fixtures :authors
Rails fixtures are horrible things. Avoid them. Use Machinist or
similar. Also consider RSpec instead of Test::Unit.
def test_name
author = Author.create(:first_name => 'Joel',:last_name =>
'Spolsky')
assert_equal 'Joel Spolsky', author.name
end
end
Best,
Thanks Freddie - it worked.
There is another error which I am currently searching for answer but maybe
you already have?
That's just rails' equivalent of a 404.
Fred