Ok, so I'm working from a book called Agile Web Developement with Rails 4th Edition. I got up to page 83 where they have us running tests to ensure proper validation of our code up to this point. So I have checked and rechecked to make sure my code is identical to theirs. I keep getting an error. This is the test:
test "product attributes must not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.errors[:image_url].any?
end
This is the error I get:
====================================
/home/mint/Documents/depot/test/unit/product_test.rb:1:in `test': wrong number of arguments (1 for 2) (ArgumentError)
from /home/mint/Documents/depot/test/unit/product_test.rb:1:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `each'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `select'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/var/lib/gems/1.9.1/gems/rake-10.0.3/lib" "/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]
Tasks: TOP => test:units
(See full trace by running task with --trace)
========================================
So I proceed to comment out one line at a time inside the test to see if this changes anything. Everything stays the same. Finaly, I change the text inside the quotes at the top of the argument. When I remove all but the double quotes, I get this:
==========================================
/home/mint/Documents/depot/test/unit/product_test.rb:1:in `test': can't convert String into Integer (TypeError)
from /home/mint/Documents/depot/test/unit/product_test.rb:1:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `each'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `select'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/var/lib/gems/1.9.1/gems/rake-10.0.3/lib" "/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]
Tasks: TOP => test:units
(See full trace by running task with --trace)
============================================
When I get rid of the quotes as well, I get this:
===========================================
/home/mint/Documents/depot/test/unit/product_test.rb:1:in `test': wrong number of arguments (0 for 2..3) (ArgumentError)
from /home/mint/Documents/depot/test/unit/product_test.rb:1:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:251:in `require'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `each'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `select'
from /var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/var/lib/gems/1.9.1/gems/rake-10.0.3/lib" "/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]
Tasks: TOP => test:units
(See full trace by running task with --trace)
=============================================
I checked the forum for this book, and so far only one person has had anything even remotely similar to my issue, but several pages forward, and no one has responded to him from way back in June of this year. So I turn to you, my friends. What do they mean "wrong number of arguments (1 for 2) and (0 for 2..3)? Apparently the only thing that affects this error report is what is between the quotes. I've tried using single quotes and got the same error. I tried replacing the text with numbers and got a different error. Help me Dani Won kenobi. You're my only hope. And thank you very veyr much. =)