user3447780
user3447780

Reputation: 175

ActiveRecord::Fixture::FormatError: a YAML error occurred parsing

I 'm trying to make a of my first application on ruby ... Thats's my test file

   require File.dirname(__FILE__) + '/../test_helper'

   class SupplierTest < ActiveSupport::TestCase
        fixtures :suppliers
        def test_name
           supplier=Supplier.create(:name => 'juan' , :province => nil)
           assert_equal 'juan' , supplier.get_name
        end
   end

and the fixture

   juan: 
     id:1
     name:juan
     province:nil

and the result is

    Psych::SyntaxError: (<unknown>): could not find expected ':' while scanning    a  simple key at line 8 column 1

Upvotes: 0

Views: 1956

Answers (1)

Uri Agassi
Uri Agassi

Reputation: 37409

YAML requires a space between the : and the value, so try updating your fixture to:

juan: 
  id: 1
  name: juan
  province: 

(writing nil in province will result in the value "nil". Leaving it empty will result in a true nil value)

Upvotes: 1

Related Questions