30 Jun 2013, 23:37
Generic-user-small

Nikola Savic (3 posts)

When i try to run the image url test i get an error. Not sure why, I practically copied and pasted from the pdf.

my code:

def new_product(image_url)

Product.new(title: “My book title”, description: “yyy”, price: 1, image_url: image_url) end

test “image url” do

ok = %w{ fred.gif fred.jpg fred.png FRED.JPG FRED.Jpg http://a.b.c/x/y/z/fred.gif } bad = %w{ fred.doc fred.gif/more fred.gif.more }

ok.each do |name| assert new_product(name).valid?, “#{name} shouldn’t be invalid” end

bad.each do |name| assert new_product(name).invalid?, “#{name} shouldn’t be valid” end end

my error: rake aborted! unknown command ‘i’ /Users/admin/Dropbox/code/rails/depot/test/models/product_test.rb:39:in test' /Users/admin/Dropbox/code/rails/depot/test/models/product_test.rb:39:in <top (required)>’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in require' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in block in require’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:213:in load_dependency' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in require’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in block (3 levels) in define' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in each’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in block (2 levels) in define' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:72:in each’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:72:in block in define' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in call’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in block in execute' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in each’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in execute' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:175:in block in invoke_with_call_chain’ /Users/admin/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:168:in invoke_with_call_chain’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:197:in block in invoke_prerequisites' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:195:in each’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:195:in invoke_prerequisites' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:174:in block in invoke_with_call_chain’ /Users/admin/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:168:in invoke_with_call_chain’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:161:in invoke' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/testing.rake:61:in block in <top (required)>’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in call' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in block in execute’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in each' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in execute’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:175:in block in invoke_with_call_chain' /Users/admin/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:168:in invoke_with_call_chain' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:161:in invoke’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:149:in invoke_task' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in block (2 levels) in top_level’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in each' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in block in top_level’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:115:in run_with_threads' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:100:in top_level’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:78:in block in run' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:165:in standard_exception_handling’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:75:in run' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/bin/rake:33:in <top (required)>’ /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/bin/rake:23:in load' /Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/bin/rake:23:in ' Tasks: TOP => test:run => test:units

01 Jul 2013, 20:25
Generic-user-small

Nikola Savic (3 posts)

I found my mistake. All of the tests need to be inside of class ProductTest < ActiveSupport::TestCase … end

The last two I added weren’t.

  You must be logged in to comment