Hello,
I have this model :
class Product < ActiveRecord::Base
validates :title, :description, :image_url, presence: true
validates :price, numericality: {greater_than_or_equal_to: 0.01}
validates :title, uniqueness: true
validates :image_url, allow_blank: true,
format: { with: %r{\.(gif|jpg|png)\Z}i,
message: 'must be a URL for GIF, JPG or PNG image.'
}
end
So I have made this test
require 'spec_helper'
describe Product do
it "is valid with a productname, description,price and a image_url" do
product = Product.new(
title = "Book 1" ,
description = "This is the first book" ,
price = "1.00")
expect(product).to be_valid
end
end
But as soon as I do rspec I see this output:
MiniTest::Unit::TestCase is now Minitest::Test. From /home/codio/.rbenv/versions/2.1.5/lib/ruby/2.1.0/test/unit/testcase.rb:8:in `<module:Unit>'
Product
is valid with a productname, description,price and a image_url (FAILED - 1)
Failures:
1) Product is valid with a productname, description,price and a image_url
Failure/Error: product = Product.new(
ArgumentError:
wrong number of arguments (3 for 0..2)
# ./spec/model/product_spec.rb:6:in `block (2 levels) in <top (required)>'
Where did i took the wrong turn.
Roelof