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


-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/d9c08679-6c9d-4504-b756-844ee6479a2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to