0

I am new in Ruby on Rails and I'm a bit confuse right now. I run a rake test and there was an error:

wrong argument number (1 of 0)

Can somebody help me? How can I correct the argument number? See below for my code.

test 'product price must be positive' do
product = Product.new(title:  "My Book Title",
                      description:  "yyy",
                      image_url:    "zzz.jpg" )
product.price = -1
assert product.invalid?
assert_equal ['must be greater than or equal to 0.01'],
             product.errors[:price]

product.price = 0
assert product.invalid?
assert_equal ['must be greater than or equal to 0.01'],
             product.errors[:price]
product.price = 1
assert product.valid?
Jawa
  • 2,336
  • 6
  • 34
  • 39

2 Answers2

0

Check this post out for an explanation of what the error means. Your error message should provide a line or indication as to where the error ocurred. Google the prototype for the method that you are invoking with the wrong number of arguments to see how many arguments you should be passing to it.

Hope that helps!

Community
  • 1
  • 1
MoMo
  • 499
  • 3
  • 12
0

You're getting that error because you're sending an argument function(arg1, arg2) to a method which doesn't support it

Altough I can't see exactly where the error was caused, you'll basically be trying to set something in the wrong place (maybe you've setting an attribute which doesn't exist or something)

As requested in the comments, you'll be best sharing the entire error message (which line etc)

Richard Peck
  • 76,116
  • 9
  • 93
  • 147